dskill Claude commited on
Commit
82fd78f
·
1 Parent(s): 24cde4f

Simplify music generation interface by removing audio prompts

Browse files

- Removed audio prompt tab and related functionality
- Switched to text-only prompts with default value
- Updated Best Practices guide to reflect text prompt format
- Fixed typo in "coming soon" text

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>

Files changed (1) hide show
  1. app.py +13 -48
app.py CHANGED
@@ -31,7 +31,7 @@ cfm, tokenizer, muq, vae = prepare_model(device)
31
  cfm = torch.compile(cfm)
32
 
33
  @spaces.GPU(duration=20)
34
- def infer_music(lrc, ref_audio_path, text_prompt, current_prompt_type, seed=42, randomize_seed=False, steps=32, cfg_strength=4.0, file_type='wav', odeint_method='euler', max_frames=2048, device='cuda'):
35
 
36
  if randomize_seed:
37
  seed = random.randint(0, MAX_SEED)
@@ -40,10 +40,7 @@ def infer_music(lrc, ref_audio_path, text_prompt, current_prompt_type, seed=42,
40
  vocal_flag = False
41
  try:
42
  lrc_prompt, start_time = get_lrc_token(lrc, tokenizer, device)
43
- if current_prompt_type == 'audio':
44
- style_prompt, vocal_flag = get_audio_style_prompt(muq, ref_audio_path)
45
- else:
46
- style_prompt = get_text_style_prompt(muq, text_prompt)
47
  except Exception as e:
48
  raise gr.Error(f"Error: {str(e)}")
49
  negative_style_prompt = get_negative_style_prompt(device)
@@ -188,22 +185,11 @@ with gr.Blocks(css=css) as demo:
188
  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"""
189
  )
190
 
191
- current_prompt_type = gr.State(value="audio")
192
- with gr.Tabs() as inside_tabs:
193
- with gr.Tab("Audio Prompt"):
194
- audio_prompt = gr.Audio(label="Audio Prompt", type="filepath", value="./src/prompt/default.wav")
195
- with gr.Tab("Text Prompt"):
196
- text_prompt = gr.Textbox(
197
- label="Text Prompt",
198
- placeholder="Enter the Text Prompt, eg: emotional piano pop",
199
- )
200
- def update_prompt_type(evt: gr.SelectData):
201
- return "audio" if evt.index == 0 else "text"
202
-
203
- inside_tabs.select(
204
- fn=update_prompt_type,
205
- outputs=current_prompt_type
206
- )
207
 
208
  with gr.Column():
209
  with gr.Accordion("Best Practices Guide", open=True):
@@ -218,13 +204,13 @@ with gr.Blocks(css=css) as demo:
218
  2. **Generation Duration Limits**
219
  - Current version supports maximum **95 seconds** of music generation
220
  - Total timestamps should not exceed 01:35.00 (95 seconds)
221
- 3. **Audio Prompt Requirements**
222
- - Reference audio should be 1 second, audio >10 seconds will be randomly clipped into 10 seconds
223
- - For optimal results, the 10-second clips should be carefully selected
224
- - Shorter clips may lead to incoherent generation
225
  4. **Supported Languages**
226
  - **Chinese and English**
227
- - More languages comming soon
228
 
229
  5. **Others**
230
  - If loading audio result is slow, you can select Output Format as mp3 in Advanced Settings.
@@ -265,27 +251,6 @@ with gr.Blocks(css=css) as demo:
265
  file_type = gr.Dropdown(["wav", "mp3", "ogg"], label="Output Format", value="wav")
266
 
267
 
268
- gr.Examples(
269
- examples=[
270
- ["./src/prompt/pop_cn.wav"],
271
- ["./src/prompt/pop_en.wav"],
272
- ["./src/prompt/rock_cn.wav"],
273
- ["./src/prompt/rock_en.wav"],
274
- ["./src/prompt/country_cn.wav"],
275
- ["./src/prompt/country_en.wav"],
276
- ["./src/prompt/classic_cn.wav"],
277
- ["./src/prompt/classic_en.wav"],
278
- ["./src/prompt/jazz_cn.wav"],
279
- ["./src/prompt/jazz_en.wav"],
280
- ["./src/prompt/rap_cn.wav"],
281
- ["./src/prompt/rap_en.wav"],
282
- ["./src/prompt/default.wav"]
283
- ],
284
- inputs=[audio_prompt],
285
- label="Audio Examples",
286
- examples_per_page=13,
287
- elem_id="audio-examples-container"
288
- )
289
 
290
  gr.Examples(
291
  examples=[
@@ -403,7 +368,7 @@ with gr.Blocks(css=css) as demo:
403
 
404
  lyrics_btn.click(
405
  fn=infer_music,
406
- inputs=[lrc, audio_prompt, text_prompt, current_prompt_type, seed, randomize_seed, steps, cfg_strength, file_type, odeint_method],
407
  outputs=audio_output
408
  )
409
 
 
31
  cfm = torch.compile(cfm)
32
 
33
  @spaces.GPU(duration=20)
34
+ def infer_music(lrc, text_prompt, seed=42, randomize_seed=False, steps=32, cfg_strength=4.0, file_type='wav', odeint_method='euler', max_frames=2048, device='cuda'):
35
 
36
  if randomize_seed:
37
  seed = random.randint(0, MAX_SEED)
 
40
  vocal_flag = False
41
  try:
42
  lrc_prompt, start_time = get_lrc_token(lrc, tokenizer, device)
43
+ style_prompt = get_text_style_prompt(muq, text_prompt)
 
 
 
44
  except Exception as e:
45
  raise gr.Error(f"Error: {str(e)}")
46
  negative_style_prompt = get_negative_style_prompt(device)
 
185
  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"""
186
  )
187
 
188
+ text_prompt = gr.Textbox(
189
+ label="Text Prompt",
190
+ placeholder="Enter the Text Prompt, eg: emotional piano pop",
191
+ value="Pop Emotional Piano"
192
+ )
 
 
 
 
 
 
 
 
 
 
 
193
 
194
  with gr.Column():
195
  with gr.Accordion("Best Practices Guide", open=True):
 
204
  2. **Generation Duration Limits**
205
  - Current version supports maximum **95 seconds** of music generation
206
  - Total timestamps should not exceed 01:35.00 (95 seconds)
207
+ 3. **Text Prompt Format**
208
+ - Use descriptive terms for style like "pop", "rock", "jazz"
209
+ - Add emotions like "emotional", "upbeat", "melancholic"
210
+ - Include instruments like "piano", "guitar", "orchestral"
211
  4. **Supported Languages**
212
  - **Chinese and English**
213
+ - More languages coming soon
214
 
215
  5. **Others**
216
  - If loading audio result is slow, you can select Output Format as mp3 in Advanced Settings.
 
251
  file_type = gr.Dropdown(["wav", "mp3", "ogg"], label="Output Format", value="wav")
252
 
253
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
254
 
255
  gr.Examples(
256
  examples=[
 
368
 
369
  lyrics_btn.click(
370
  fn=infer_music,
371
+ inputs=[lrc, text_prompt, seed, randomize_seed, steps, cfg_strength, file_type, odeint_method],
372
  outputs=audio_output
373
  )
374