CoolFace
Apppublic

cocktailpeanut/DiffRhythm

sourceHugging Faceapache-2.0updated 1y agoView on Hugging Face
10likes
app.py401 linesDownload Raw Back to root
1import gradio as gr2from openai import OpenAI3import requests4import json5# from volcenginesdkarkruntime import Ark6import torch7import torchaudio8from einops import rearrange9import argparse10import json11import os12import gc13#import spaces14from tqdm import tqdm15import random16import numpy as np17import sys18from diffrhythm.infer.infer_utils import (19    get_reference_latent,20    get_lrc_token,21    get_style_prompt,22    get_text_style_prompt,23    get_audio_style_prompt,24    prepare_model,25    get_negative_style_prompt26)27from diffrhythm.infer.infer import inference28import devicetorch29import math30 31 32device=devicetorch.get(torch)33cfm, tokenizer, muq, vae = prepare_model(device)34#cfm = torch.compile(cfm)35 36def clear_audio():37    return gr.update(value=None)  # Clears the audio field38 39def clear_text():40    return gr.update(value="")  # Clears the text field41 42#@spaces.GPU43#def infer_music(lrc, ref_audio_path, steps, file_type, cfg_strength, odeint_method, duration, prompt=None):44def infer_music(lrc, ref_audio_path, steps, file_type, cfg_strength, odeint_method, prompt=None):45 46    duration = 9547    max_frames = 204848    #max_frames = math.floor(duration * 21.56)49    sway_sampling_coef = -1 if steps < 32 else None50    vocal_flag = False51    lrc_prompt, start_time = get_lrc_token(max_frames, lrc, tokenizer, device)52#    style_prompt = get_style_prompt(muq, ref_audio_path, prompt)53 54    print(f"infer_music: lrc={lrc}, ref_audio_path={ref_audio_path}, steps={steps}, file_type={file_type}, cfg_strength={cfg_strength}, odeint_method={odeint_method}, duration={duration}, prompt={prompt}")55    if prompt:56        print("text style prompt")57        style_prompt = get_text_style_prompt(muq, prompt)58    else:59        print("audio style prompt")60        style_prompt, vocal_flag = get_audio_style_prompt(muq, ref_audio_path)61 62    negative_style_prompt = get_negative_style_prompt(device)63    latent_prompt = get_reference_latent(device, max_frames)64    print(">0")65    generated_song = inference(cfm_model=cfm, 66                               vae_model=vae, 67                               cond=latent_prompt, 68                               text=lrc_prompt, 69                               duration=max_frames, 70                               style_prompt=style_prompt,71                               negative_style_prompt=negative_style_prompt,72                               steps=steps,73                               cfg_strength=cfg_strength,74                               sway_sampling_coef=sway_sampling_coef,75                               start_time=start_time,76                               file_type=file_type,77                               vocal_flag=vocal_flag,78                               odeint_method=odeint_method,79                               )80    devicetorch.empty_cache(torch)81    gc.collect()82    print(">4")83 84    return generated_song85 86def R1_infer1(theme, tags_gen, language):87    try:88        client = OpenAI()89 90        llm_prompt = """91        请围绕"{theme}"主题生成一首符合"{tags}"风格的语言为{language}的完整歌词。严格遵循以下要求:92 93        ### **强制格式规则**94        1. **仅输出时间戳和歌词**,禁止任何括号、旁白、段落标记(如副歌、间奏、尾奏等注释)。95        2. 每行格式必须为 `[mm:ss.xx]歌词内容`,时间戳与歌词间无空格,歌词内容需完整连贯。96        3. 时间戳需自然分布,**第一句歌词起始时间不得为 [00:00.00]**,需考虑前奏空白。97 98        ### **内容与结构要求**99        1. 歌词应富有变化,使情绪递进,整体连贯有层次感。**每行歌词长度应自然变化**,切勿长度一致,导致很格式化。100        2. **时间戳分配应根据歌曲的标签、歌词的情感、节奏来合理推测**,而非机械地按照歌词长度分配。101        3. 间奏/尾奏仅通过时间空白体现(如从 [02:30.00] 直接跳至 [02:50.00]),**无需文字描述**。102 103        ### **负面示例(禁止出现)**104        - 错误:[01:30.00](钢琴间奏)105        - 错误:[02:00.00][副歌]106        - 错误:空行、换行符、注释107        """108 109        response = client.chat.completions.create(110            model="ep-20250304144033-nr9wl",111            messages=[112                {"role": "system", "content": "You are a professional musician who has been invited to make music-related comments."},113                {"role": "user", "content": llm_prompt.format(theme=theme, tags=tags_gen, language=language)},114            ],115            stream=False116        )117        118        info = response.choices[0].message.content119 120        return info121 122    except requests.exceptions.RequestException as e:123        print(f'请求出错: {e}')124        return {}125 126 127 128def R1_infer2(tags_lyrics, lyrics_input):129    client = OpenAI()130 131    llm_prompt = """`{lyrics_input}`132This is the lyrics of a song. Each line is a line of lyrics. {tags_lyrics} is the style I want for this song. I now want to timestamp each line of lyrics of this song to get LRC. I hope that the timestamp allocation should be reasonably inferred based on the song tag, the emotion of the lyrics, and the rhythm, rather than mechanically allocated according to the length of the lyrics. The timestamp of the first line of lyrics should take into account the length of the prelude to avoid the lyrics starting directly from `[00:00.00]`. Output the lyrics strictly in LRC format, with each line in the format of `[mm:ss.xx] lyrics content`. The final result only outputs LRC, no other explanation is required.133    """134 135    response = client.chat.completions.create(136        model="gpt-4o",137        messages=[138            {"role": "system", "content": "You are a professional musician who has been invited to make music-related comments."},139            {"role": "user", "content": llm_prompt.format(lyrics_input=lyrics_input, tags_lyrics=tags_lyrics)},140        ],141        stream=False142    )143 144    info = response.choices[0].message.content145 146    return info147 148css = """149/* 固定文本域高度并强制滚动条 */150.lyrics-scroll-box textarea {151    height: 300px !important;  /* 固定高度 */152    max-height: 500px !important;  /* 最大高度 */153    overflow-y: auto !important;  /* 垂直滚动 */154    white-space: pre-wrap;  /* 保留换行 */155    line-height: 1.5;  /* 行高优化 */156}157 158.gr-examples {159    background: transparent !important;160    border: 1px solid #e0e0e0 !important;161    border-radius: 8px;162    margin: 1rem 0 !important;163    padding: 1rem !important;164}165 166"""167 168with gr.Blocks(css=css) as demo:169    # gr.Markdown("<h1 style='text-align: center'>DiffRhythm (谛韵)</h1>")170    gr.HTML("""171        172        <div style="font-size: 2em; font-weight: bold; text-align: center; margin-bottom: 5px">173            DiffRhythm (谛韵)174        </div>175        <div style="display:flex; justify-content: center; column-gap:4px;">176            <a href="https://arxiv.org/abs/2503.01183">177                <img src='https://img.shields.io/badge/Arxiv-Paper-blue'>178            </a> 179            <a href="https://github.com/ASLP-lab/DiffRhythm">180                <img src='https://img.shields.io/badge/GitHub-Repo-green'>181            </a> 182            <a href="https://aslp-lab.github.io/DiffRhythm.github.io/">183                <img src='https://img.shields.io/badge/Project-Page-brown'>184            </a>185        </div>186        """)187    188    with gr.Tabs() as tabs:189        190        # page 1191        with gr.Tab("Music Generate", id=0):192            with gr.Row():193                with gr.Column():194                    with gr.Accordion("Best Practices Guide", open=False):195                        gr.Markdown("""196                        1. **Lyrics Format Requirements**197                        - Each line must follow: `[mm:ss.xx]Lyric content`198                        - Example of valid format:199                            ``` 200                            [00:10.00]Moonlight spills through broken blinds201                            [00:13.20]Your shadow dances on the dashboard shrine202                            ```203 204                        2. **Generation Duration Limits**205                        - Current version supports maximum **95 seconds** of music generation206                        - Total timestamps should not exceed 01:35.00 (95 seconds)207 208                        3. **Audio Prompt Requirements**209                        - Reference audio should be ≥10 seconds for optimal results210                        - Shorter clips may lead to incoherent generation211                        """)212                    lrc = gr.Textbox(213                        label="Lrc",214                        placeholder="Input the full lyrics",215                        lines=12,216                        max_lines=50,217                        elem_classes="lyrics-scroll-box",218                        #value="""[00:04.34]Tell me that I'm special\n[00:06.57]Tell me I look pretty\n[00:08.46]Tell me I'm a little angel\n[00:10.58]Sweetheart of your city\n[00:13.64]Say what I'm dying to hear\n[00:17.35]Cause I'm dying to hear you\n[00:20.86]Tell me I'm that new thing\n[00:22.93]Tell me that I'm relevant\n[00:24.96]Tell me that I got a big heart\n[00:27.04]Then back it up with evidence\n[00:29.94]I need it and I don't know why\n[00:34.28]This late at night\n[00:36.32]Isn't it lonely\n[00:39.24]I'd do anything to make you want me\n[00:43.40]I'd give it all up if you told me\n[00:47.42]That I'd be\n[00:49.43]The number one girl in your eyes\n[00:52.85]Your one and only\n[00:55.74]So what's it gon' take for you to want me\n[00:59.78]I'd give it all up if you told me\n[01:03.89]That I'd be\n[01:05.94]The number one girl in your eyes\n[01:11.34]Tell me I'm going real big places\n[01:14.32]Down to earth so friendly\n[01:16.30]And even through all the phases\n[01:18.46]Tell me you accept me\n[01:21.56]Well that's all I'm dying to hear\n[01:25.30]Yeah I'm dying to hear you\n[01:28.91]Tell me that you need me\n[01:30.85]Tell me that I'm loved\n[01:32.90]Tell me that I'm worth it\n[01:34.95]And that I'm enough\n[01:37.91]I need it and I don't know why\n[01:42.08]This late at night\n[01:44.24]Isn't it lonely\n[01:47.18]I'd do anything to make you want me\n[01:51.30]I'd give it all up if you told me\n[01:55.32]That I'd be\n[01:57.35]The number one girl in your eyes\n[02:00.72]Your one and only\n[02:03.57]So what's it gon' take for you to want me\n[02:07.78]I'd give it all up if you told me\n[02:11.74]That I'd be\n[02:13.86]The number one girl in your eyes\n[02:17.03]The girl in your eyes\n[02:21.05]The girl in your eyes\n[02:26.30]Tell me I'm the number one girl\n[02:28.44]I'm the number one girl in your eyes\n[02:33.49]The girl in your eyes\n[02:37.58]The girl in your eyes\n[02:42.74]Tell me I'm the number one girl\n[02:44.88]I'm the number one girl in your eyes\n[02:49.91]Well isn't it lonely\n[02:53.19]I'd do anything to make you want me\n[02:57.10]I'd give it all up if you told me\n[03:01.15]That I'd be\n[03:03.31]The number one girl in your eyes\n[03:06.57]Your one and only\n[03:09.42]So what's it gon' take for you to want me\n[03:13.50]I'd give it all up if you told me\n[03:17.56]That I'd be\n[03:19.66]The number one girl in your eyes\n[03:25.74]The number one girl in your eyes"""219                        value="""[00:10.00]Moonlight spills through broken blinds\n[00:13.20]Your shadow dances on the dashboard shrine\n[00:16.85]Neon ghosts in gasoline rain\n[00:20.40]I hear your laughter down the midnight train\n[00:24.15]Static whispers through frayed wires\n[00:27.65]Guitar strings hum our cathedral choirs\n[00:31.30]Flicker screens show reruns of June\n[00:34.90]I'm drowning in this mercury lagoon\n[00:38.55]Electric veins pulse through concrete skies\n[00:42.10]Your name echoes in the hollow where my heartbeat lies\n[00:45.75]We're satellites trapped in parallel light\n[00:49.25]Burning through the atmosphere of endless night\n[01:00.00]Dusty vinyl spins reverse\n[01:03.45]Our polaroid timeline bleeds through the verse\n[01:07.10]Telescope aimed at dead stars\n[01:10.65]Still tracing constellations through prison bars\n[01:14.30]Electric veins pulse through concrete skies\n[01:17.85]Your name echoes in the hollow where my heartbeat lies\n[01:21.50]We're satellites trapped in parallel light\n[01:25.05]Burning through the atmosphere of endless night\n[02:10.00]Clockwork gears grind moonbeams to rust\n[02:13.50]Our fingerprint smudged by interstellar dust\n[02:17.15]Velvet thunder rolls through my veins\n[02:20.70]Chasing phantom trains through solar plane\n[02:24.35]Electric veins pulse through concrete skies\n[02:27.90]Your name echoes in the hollow where my heartbeat lies"""    220                    )221                    with gr.Group():222                        gr.HTML("<h5>Generate a song from</h5>")223                        with gr.Row():224                            with gr.Tab("Audio"):225                                audio_prompt = gr.Audio(label="Audio Prompt", type="filepath", value="./src/prompt/default.wav")226                            with gr.Tab("Text Description"):227                                text_prompt = gr.Textbox(label="Text Prompt", placeholder="Describe the song")228                    text_prompt.input(clear_audio, inputs=[], outputs=audio_prompt)229                    audio_prompt.input(clear_text, inputs=[], outputs=text_prompt)230                    231                with gr.Column():232                  233                    #duration = gr.Slider(95, 285, value=285, label="Music Duration")234                    lyrics_btn = gr.Button("Submit", variant="primary")235                    audio_output = gr.Audio(label="Audio Result", type="filepath", elem_id="audio_output")236                    with gr.Accordion("Advanced Settings", open=False):237                        steps = gr.Slider(238                                    minimum=10,239                                    maximum=100,240                                    value=32, 241                                    step=1,242                                    label="Diffusion Steps",243                                    interactive=True,244                                    elem_id="step_slider"245                                )246                        cfg_strength = gr.Slider(247                                    minimum=1,248                                    maximum=10,249                                    value=4.0,250                                    step=0.5,251                                    label="CFG Strength",252                                    interactive=True,253                                    elem_id="step_slider"254                                )255                        odeint_method = gr.Radio(["euler", "midpoint", "rk4","implicit_adams"], label="ODE Solver", value="euler")                        256 257                        file_type = gr.Dropdown(["wav", "mp3", "ogg"], label="Output Format", value="mp3")258                    259 260 261            gr.Examples(262                examples=[263                    ["./src/prompt/pop_cn.wav"], 264                    ["./src/prompt/pop_en.wav"], 265                    ["./src/prompt/rock_cn.wav"], 266                    ["./src/prompt/rock_en.wav"], 267                    ["./src/prompt/country_cn.wav"], 268                    ["./src/prompt/country_en.wav"],269                    ["./src/prompt/classic_cn.wav"],270                    ["./src/prompt/classic_en.wav"],271                    ["./src/prompt/jazz_cn.wav"],272                    ["./src/prompt/jazz_en.wav"],273                    ["./src/prompt/default.wav"]274                ],275                inputs=[audio_prompt],  276                label="Audio Examples",277                examples_per_page=11,278                elem_id="audio-examples-container" 279            )280 281            gr.Examples(282                examples=[283                    ["""[00:10.00]Moonlight spills through broken blinds\n[00:13.20]Your shadow dances on the dashboard shrine\n[00:16.85]Neon ghosts in gasoline rain\n[00:20.40]I hear your laughter down the midnight train\n[00:24.15]Static whispers through frayed wires\n[00:27.65]Guitar strings hum our cathedral choirs\n[00:31.30]Flicker screens show reruns of June\n[00:34.90]I'm drowning in this mercury lagoon\n[00:38.55]Electric veins pulse through concrete skies\n[00:42.10]Your name echoes in the hollow where my heartbeat lies\n[00:45.75]We're satellites trapped in parallel light\n[00:49.25]Burning through the atmosphere of endless night\n[01:00.00]Dusty vinyl spins reverse\n[01:03.45]Our polaroid timeline bleeds through the verse\n[01:07.10]Telescope aimed at dead stars\n[01:10.65]Still tracing constellations through prison bars\n[01:14.30]Electric veins pulse through concrete skies\n[01:17.85]Your name echoes in the hollow where my heartbeat lies\n[01:21.50]We're satellites trapped in parallel light\n[01:25.05]Burning through the atmosphere of endless night\n[02:10.00]Clockwork gears grind moonbeams to rust\n[02:13.50]Our fingerprint smudged by interstellar dust\n[02:17.15]Velvet thunder rolls through my veins\n[02:20.70]Chasing phantom trains through solar plane\n[02:24.35]Electric veins pulse through concrete skies\n[02:27.90]Your name echoes in the hollow where my heartbeat lies"""],284                    ["""[00:04.34]Tell me that I'm special\n[00:06.57]Tell me I look pretty\n[00:08.46]Tell me I'm a little angel\n[00:10.58]Sweetheart of your city\n[00:13.64]Say what I'm dying to hear\n[00:17.35]Cause I'm dying to hear you\n[00:20.86]Tell me I'm that new thing\n[00:22.93]Tell me that I'm relevant\n[00:24.96]Tell me that I got a big heart\n[00:27.04]Then back it up with evidence\n[00:29.94]I need it and I don't know why\n[00:34.28]This late at night\n[00:36.32]Isn't it lonely\n[00:39.24]I'd do anything to make you want me\n[00:43.40]I'd give it all up if you told me\n[00:47.42]That I'd be\n[00:49.43]The number one girl in your eyes\n[00:52.85]Your one and only\n[00:55.74]So what's it gon' take for you to want me\n[00:59.78]I'd give it all up if you told me\n[01:03.89]That I'd be\n[01:05.94]The number one girl in your eyes\n[01:11.34]Tell me I'm going real big places\n[01:14.32]Down to earth so friendly\n[01:16.30]And even through all the phases\n[01:18.46]Tell me you accept me\n[01:21.56]Well that's all I'm dying to hear\n[01:25.30]Yeah I'm dying to hear you\n[01:28.91]Tell me that you need me\n[01:30.85]Tell me that I'm loved\n[01:32.90]Tell me that I'm worth it"""],285                    ["""[00:04.27]只因你太美 baby\n[00:08.95]只因你实在是太美 baby\n[00:13.99]只因你太美 baby\n[00:18.89]迎面走来的你让我如此蠢蠢欲动\n[00:20.88]这种感觉我从未有\n[00:21.79]Cause I got a crush on you who you\n[00:25.74]你是我的我是你的谁\n[00:28.09]再多一眼看一眼就会爆炸\n[00:30.31]再近一点靠近点快被融化\n[00:32.49]想要把你占为己有 baby\n[00:34.60]不管走到哪里\n[00:35.44]都会想起的人是你 you you\n[00:38.12]我应该拿你怎样\n[00:39.61]Uh 所有人都在看着你\n[00:42.36]我的心总是不安\n[00:44.18]Oh 我现在已病入膏肓\n[00:46.63]Eh oh\n[00:47.84]难道真的因你而疯狂吗\n[00:51.57]我本来不是这种人\n[00:53.59]因你变成奇怪的人\n[00:55.77]第一次呀变成这样的我\n[01:01.23]不管我怎么去否认\n[01:03.21]只因你太美 baby\n[01:11.46]只因你实在是太美 baby\n[01:16.75]只因你太美 baby\n[01:21.09]Oh eh oh\n[01:22.82]现在确认地告诉我\n[01:25.26]Oh eh oh\n[01:27.31]你到底属于谁\n[01:29.98]Oh eh oh\n[01:31.70]现在确认地告诉我\n[01:34.45]Oh eh oh\n[01:36.35]你到底属于谁\n[01:37.65]就是现在告诉我\n[01:40.00]跟着那节奏 缓缓 make wave\n"""]286 287#                    ["""[00:04.34]Tell me that I'm special\n[00:06.57]Tell me I look pretty\n[00:08.46]Tell me I'm a little angel\n[00:10.58]Sweetheart of your city\n[00:13.64]Say what I'm dying to hear\n[00:17.35]Cause I'm dying to hear you\n[00:20.86]Tell me I'm that new thing\n[00:22.93]Tell me that I'm relevant\n[00:24.96]Tell me that I got a big heart\n[00:27.04]Then back it up with evidence\n[00:29.94]I need it and I don't know why\n[00:34.28]This late at night\n[00:36.32]Isn't it lonely\n[00:39.24]I'd do anything to make you want me\n[00:43.40]I'd give it all up if you told me\n[00:47.42]That I'd be\n[00:49.43]The number one girl in your eyes\n[00:52.85]Your one and only\n[00:55.74]So what's it gon' take for you to want me\n[00:59.78]I'd give it all up if you told me\n[01:03.89]That I'd be\n[01:05.94]The number one girl in your eyes\n[01:11.34]Tell me I'm going real big places\n[01:14.32]Down to earth so friendly\n[01:16.30]And even through all the phases\n[01:18.46]Tell me you accept me\n[01:21.56]Well that's all I'm dying to hear\n[01:25.30]Yeah I'm dying to hear you\n[01:28.91]Tell me that you need me\n[01:30.85]Tell me that I'm loved\n[01:32.90]Tell me that I'm worth it\n[01:34.95]And that I'm enough\n[01:37.91]I need it and I don't know why\n[01:42.08]This late at night\n[01:44.24]Isn't it lonely\n[01:47.18]I'd do anything to make you want me\n[01:51.30]I'd give it all up if you told me\n[01:55.32]That I'd be\n[01:57.35]The number one girl in your eyes\n[02:00.72]Your one and only\n[02:03.57]So what's it gon' take for you to want me\n[02:07.78]I'd give it all up if you told me\n[02:11.74]That I'd be\n[02:13.86]The number one girl in your eyes\n[02:17.03]The girl in your eyes\n[02:21.05]The girl in your eyes\n[02:26.30]Tell me I'm the number one girl\n[02:28.44]I'm the number one girl in your eyes\n[02:33.49]The girl in your eyes\n[02:37.58]The girl in your eyes\n[02:42.74]Tell me I'm the number one girl\n[02:44.88]I'm the number one girl in your eyes\n[02:49.91]Well isn't it lonely\n[02:53.19]I'd do anything to make you want me\n[02:57.10]I'd give it all up if you told me\n[03:01.15]That I'd be\n[03:03.31]The number one girl in your eyes\n[03:06.57]Your one and only\n[03:09.42]So what's it gon' take for you to want me\n[03:13.50]I'd give it all up if you told me\n[03:17.56]That I'd be\n[03:19.66]The number one girl in your eyes\n[03:25.74]The number one girl in your eyes"""],288#                    ["""[00:00.52]Abracadabra abracadabra\n[00:03.97]Ha\n[00:04.66]Abracadabra abracadabra\n[00:12.02]Yeah\n[00:15.80]Pay the toll to the angels\n[00:19.08]Drawin' circles in the clouds\n[00:23.31]Keep your mind on the distance\n[00:26.67]When the devil turns around\n[00:30.95]Hold me in your heart tonight\n[00:34.11]In the magic of the dark moonlight\n[00:38.44]Save me from this empty fight\n[00:43.83]In the game of life\n[00:45.84]Like a poem said by a lady in red\n[00:49.45]You hear the last few words of your life\n[00:53.15]With a haunting dance now you're both in a trance\n[00:56.90]It's time to cast your spell on the night\n[01:01.40]Abracadabra ama-ooh-na-na\n[01:04.88]Abracadabra porta-ooh-ga-ga\n[01:08.92]Abracadabra abra-ooh-na-na\n[01:12.30]In her tongue she's sayin'\n[01:14.76]Death or love tonight\n[01:18.61]Abracadabra abracadabra\n[01:22.18]Abracadabra abracadabra\n[01:26.08]Feel the beat under your feet\n[01:27.82]The floor's on fire\n[01:29.90]Abracadabra abracadabra\n[01:33.78]Choose the road on the west side\n[01:37.09]As the dust flies watch it burn\n[01:41.45]Don't waste time on feeling\n[01:44.64]Your depression won't return\n[01:49.15]Hold me in your heart tonight\n[01:52.21]In the magic of the dark moonlight\n[01:56.54]Save me from this empty fight\n[02:01.77]In the game of life\n[02:03.94]Like a poem said by a lady in red\n[02:07.52]You hear the last few words of your life\n[02:11.19]With a haunting dance now you're both in a trance\n[02:14.95]It's time to cast your spell on the night\n[02:19.53]Abracadabra ama-ooh-na-na\n[02:22.71]Abracadabra porta-ooh-ga-ga\n[02:26.94]Abracadabra abra-ooh-na-na\n[02:30.42]In her tongue she's sayin'\n[02:32.83]Death or love tonight\n[02:36.55]Abracadabra abracadabra\n[02:40.27]Abracadabra abracadabra\n[02:44.19]Feel the beat under your feet\n[02:46.14]The floor's on fire\n[02:47.95]Abracadabra abracadabra\n[02:51.17]Phantom of the dance floor come to me\n[02:58.46]Sing for me a sinful melody\n[03:06.51]Ah-ah-ah-ah-ah ah-ah ah-ah\n[03:13.76]Ah-ah-ah-ah-ah ah-ah ah-ah\n[03:22.39]Abracadabra ama-ooh-na-na\n[03:25.66]Abracadabra porta-ooh-ga-ga\n[03:29.87]Abracadabra abra-ooh-na-na\n[03:33.16]In her tongue she's sayin'\n[03:35.55]Death or love tonight"""],289#                    ["""[00:00.27]只因你太美 baby 只因你太美 baby\n[00:08.95]只因你实在是太美 baby\n[00:13.99]只因你太美 baby\n[00:18.89]迎面走来的你让我如此蠢蠢欲动\n[00:20.88]这种感觉我从未有\n[00:21.79]Cause I got a crush on you who you\n[00:25.74]你是我的我是你的谁\n[00:28.09]再多一眼看一眼就会爆炸\n[00:30.31]再近一点靠近点快被融化\n[00:32.49]想要把你占为己有 baby bae\n[00:34.60]不管走到哪里\n[00:35.44]都会想起的人是你 you you\n[00:38.12]我应该拿你怎样\n[00:39.61]Uh 所有人都在看着你\n[00:42.36]我的心总是不安\n[00:44.18]Oh 我现在已病入膏肓\n[00:46.63]Eh oh\n[00:47.84]难道真的因你而疯狂吗\n[00:51.57]我本来不是这种人\n[00:53.59]因你变成奇怪的人\n[00:55.77]第一次呀变成这样的我\n[01:01.23]不管我怎么去否认\n[01:03.21]只因你太美 baby 只因你太美 baby\n[01:11.46]只因你实在是太美 baby\n[01:16.75]只因你太美 baby\n[01:21.09]Oh eh oh\n[01:22.82]现在确认地告诉我\n[01:25.26]Oh eh oh\n[01:27.31]你到底属于谁\n[01:29.98]Oh eh oh\n[01:31.70]现在确认地告诉我\n[01:34.45]Oh eh oh\n[01:36.35]你到底属于谁\n[01:37.65]就是现在告诉我\n[01:40.00]跟着那节奏 缓缓 make wave\n[01:42.42]甜蜜的奶油 it's your birthday cake\n[01:44.66]男人们的 game call me 你恋人\n[01:46.83]别被欺骗愉快的 I wanna play\n[01:48.83]我的脑海每分每秒为你一人沉醉\n[01:50.90]最迷人让我神魂颠倒是你身上香水\n[01:53.30]Oh right baby I'm fall in love with you\n[01:55.20]我的一切你都拿走\n[01:56.40]只要有你就已足够\n[01:58.56]我到底应该怎样\n[02:00.37]Uh 我心里一直很不安\n[02:03.12]其他男人们的视线\n[02:04.84]Oh 全都只看着你的脸\n[02:07.33]Eh oh\n[02:08.39]难道真的因你而疯狂吗\n[02:12.43]我本来不是这种人\n[02:14.35]因你变成奇怪的人\n[02:16.59]第一次呀变成这样的我\n[02:21.76]不管我怎么去否认\n[02:24.03]只因你太美 baby 只因你太美 baby\n[02:32.37]只因你实在是太美 baby\n[02:37.49]只因你太美 baby\n[02:43.66]我愿意把我的全部都给你\n[02:47.19]我每天在梦里都梦见你\n[02:49.13]还有我闭着眼睛也能看到你\n[02:52.58]现在开始我只准你看我\n[02:56.28]I don't wanna wake up in dream\n[02:57.92]我只想看你这是真心话\n[02:59.86]只因你太美 baby 只因你太美 baby\n[03:08.20]只因你实在是太美 baby\n[03:13.22]只因你太美 baby\n[03:17.69]Oh eh oh\n[03:19.36]现在确认的告诉我\n[03:21.91]Oh eh oh\n[03:23.85]你到底属于谁\n[03:26.58]Oh eh oh\n[03:28.32]现在确认的告诉我\n[03:30.95]Oh eh oh\n[03:32.82]你到底属于谁就是现在告诉我"""]290 291                ],292                293                inputs=[lrc],294                label="Lrc Examples",295                examples_per_page=2,296                elem_id="lrc-examples-container",297            )298 299        # page 2300        with gr.Tab("LLM Generate LRC", id=1):301            with gr.Row():302                with gr.Column():303                    with gr.Accordion("Notice", open=False):304                        gr.Markdown("**Two Generation Modes:**\n1. Generate from theme & tags\n2. Add timestamps to existing lyrics")305                    306                    with gr.Group():307                        gr.Markdown("### Method 1: Generate from Theme")308                        theme = gr.Textbox(label="theme", placeholder="Enter song theme, e.g. Love and Heartbreak")309                        tags_gen = gr.Textbox(label="tags", placeholder="Example: male pop confidence healing")310                        language = gr.Radio(["zh", "en"], label="Language", value="en")311                        gen_from_theme_btn = gr.Button("Generate LRC (From Theme)", variant="primary")312                        313                        gr.Examples(314                            examples=[315                                [316                                    "Love and Heartbreak", 317                                    "vocal emotional piano pop",318                                    "en"319                                ],320                                [321                                    "Heroic Epic", 322                                    "choir orchestral powerful",323                                    "zh"324                                ]325                            ],326                            inputs=[theme, tags_gen, language],327                            label="Examples: Generate from Theme"328                        )329 330                    with gr.Group(visible=True): 331                        gr.Markdown("### Method 2: Add Timestamps to Lyrics")332                        tags_lyrics = gr.Textbox(label="tags", placeholder="Example: female ballad piano slow")333                        lyrics_input = gr.Textbox(334                            label="Raw Lyrics (without timestamps)",335                            placeholder="Enter plain lyrics (without timestamps), e.g.:\nYesterday\nAll my troubles...",336                            lines=10,337                            max_lines=50,338                            elem_classes="lyrics-scroll-box"339                        )340                        341                        gen_from_lyrics_btn = gr.Button("Generate LRC (From Lyrics)", variant="primary")342 343                        gr.Examples(344                            examples=[345                                [346                                    "acoustic folk happy", 347                                    """I'm sitting here in the boring room\nIt's just another rainy Sunday afternoon"""348                                ],349                                [350                                    "electronic dance energetic",351                                    """We're living in a material world\nAnd I am a material girl"""352                                ]353                            ],354                            inputs=[tags_lyrics, lyrics_input],355                            label="Examples: Generate from Lyrics"356                        )357 358 359                with gr.Column():360                    lrc_output = gr.Textbox(361                        label="Generated LRC Lyrics",362                        placeholder="Timed lyrics will appear here",363                        lines=57,364                        elem_classes="lrc-output",365                        show_copy_button=True366                    )367 368            # Bind functions369            gen_from_theme_btn.click(370                fn=R1_infer1,371                inputs=[theme, tags_gen, language],372                outputs=lrc_output373            )374            375            gen_from_lyrics_btn.click(376                fn=R1_infer2,377                inputs=[tags_lyrics, lyrics_input],378                outputs=lrc_output379            )380 381    tabs.select(382    lambda s: None, 383    None, 384    None 385    )386    387    lyrics_btn.click(388        fn=infer_music,389        #inputs=[lrc, audio_prompt, steps, file_type, cfg_strength, odeint_method, duration, text_prompt, ],390        inputs=[lrc, audio_prompt, steps, file_type, cfg_strength, odeint_method, text_prompt, ],391        outputs=audio_output392    )393 394 395demo.queue().launch(show_api=False, show_error=True)396 397 398 399if __name__ == "__main__":400    demo.launch()401