Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -109,7 +109,7 @@ def get_last_mp3_file(output_dir):
|
|
| 109 |
# Return the most recent .mp3 file
|
| 110 |
return mp3_files_with_path[0]
|
| 111 |
|
| 112 |
-
def infer(genre_txt_content, lyrics_txt_content):
|
| 113 |
# Create temporary files
|
| 114 |
genre_txt_path = create_temp_file(genre_txt_content, prefix="genre_")
|
| 115 |
lyrics_txt_path = create_temp_file(lyrics_txt_content, prefix="lyrics_")
|
|
@@ -131,12 +131,12 @@ def infer(genre_txt_content, lyrics_txt_content):
|
|
| 131 |
"--stage2_model", "m-a-p/YuE-s2-1B-general",
|
| 132 |
"--genre_txt", f"{genre_txt_path}",
|
| 133 |
"--lyrics_txt", f"{lyrics_txt_path}",
|
| 134 |
-
"--run_n_segments", "
|
| 135 |
"--stage2_batch_size", "8", # Increased from 4 to 8
|
| 136 |
"--output_dir", f"{output_dir}",
|
| 137 |
"--cuda_idx", "0",
|
| 138 |
-
"--max_new_tokens", "
|
| 139 |
-
|
| 140 |
]
|
| 141 |
|
| 142 |
# Set up environment variables for CUDA with optimized settings
|
|
@@ -192,13 +192,30 @@ with gr.Blocks() as demo:
|
|
| 192 |
with gr.Column():
|
| 193 |
genre_txt = gr.Textbox(label="Genre")
|
| 194 |
lyrics_txt = gr.Textbox(label="Lyrics")
|
| 195 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 196 |
with gr.Column():
|
|
|
|
|
|
|
|
|
|
| 197 |
music_out = gr.Audio(label="Audio Result")
|
| 198 |
|
| 199 |
submit_btn.click(
|
| 200 |
fn = infer,
|
| 201 |
-
inputs = [genre_txt, lyrics_txt],
|
| 202 |
outputs = [music_out]
|
| 203 |
)
|
| 204 |
demo.queue().launch(show_api=False, show_error=True)
|
|
|
|
| 109 |
# Return the most recent .mp3 file
|
| 110 |
return mp3_files_with_path[0]
|
| 111 |
|
| 112 |
+
def infer(genre_txt_content, lyrics_txt_content, num_segments, max_new_tokens):
|
| 113 |
# Create temporary files
|
| 114 |
genre_txt_path = create_temp_file(genre_txt_content, prefix="genre_")
|
| 115 |
lyrics_txt_path = create_temp_file(lyrics_txt_content, prefix="lyrics_")
|
|
|
|
| 131 |
"--stage2_model", "m-a-p/YuE-s2-1B-general",
|
| 132 |
"--genre_txt", f"{genre_txt_path}",
|
| 133 |
"--lyrics_txt", f"{lyrics_txt_path}",
|
| 134 |
+
"--run_n_segments", f"{num_segments}",
|
| 135 |
"--stage2_batch_size", "8", # Increased from 4 to 8
|
| 136 |
"--output_dir", f"{output_dir}",
|
| 137 |
"--cuda_idx", "0",
|
| 138 |
+
"--max_new_tokens", f"{max_new_tokens}",
|
| 139 |
+
"--disable_offload_model"
|
| 140 |
]
|
| 141 |
|
| 142 |
# Set up environment variables for CUDA with optimized settings
|
|
|
|
| 192 |
with gr.Column():
|
| 193 |
genre_txt = gr.Textbox(label="Genre")
|
| 194 |
lyrics_txt = gr.Textbox(label="Lyrics")
|
| 195 |
+
gr.Examples(
|
| 196 |
+
examples = [
|
| 197 |
+
[
|
| 198 |
+
"female blues airy vocal bright vocal piano sad romantic guitar jazz",
|
| 199 |
+
"""
|
| 200 |
+
[chorus]
|
| 201 |
+
Don't let this moment fade, hold me close tonight
|
| 202 |
+
With you here beside me, everything's alright
|
| 203 |
+
Can't imagine life alone, don't want to let you go
|
| 204 |
+
Stay with me forever, let our love just flow
|
| 205 |
+
"""
|
| 206 |
+
]
|
| 207 |
+
],
|
| 208 |
+
inputs = [genre_txt, lyrics_txt]
|
| 209 |
+
)
|
| 210 |
with gr.Column():
|
| 211 |
+
num_segments = gr.Number(label="Number of Song Segments", info="number of paragraphs", value=1, interactive=False)
|
| 212 |
+
max_new_tokens = gr.Slider(label="Max New Tokens / Duration", info="1000 token = 10 seconds", minimum=500, maximum="24000", step=500, value=1500, interactive=False)
|
| 213 |
+
submit_btn = gr.Button("Submit")
|
| 214 |
music_out = gr.Audio(label="Audio Result")
|
| 215 |
|
| 216 |
submit_btn.click(
|
| 217 |
fn = infer,
|
| 218 |
+
inputs = [genre_txt, lyrics_txt, num_segments, max_new_tokens],
|
| 219 |
outputs = [music_out]
|
| 220 |
)
|
| 221 |
demo.queue().launch(show_api=False, show_error=True)
|