Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -118,18 +118,19 @@ def split_lyrics(lyrics: str):
|
|
118 |
structured_lyrics = [f"[{seg[0]}]\n{seg[1].strip()}\n\n" for seg in segments]
|
119 |
return structured_lyrics
|
120 |
|
121 |
-
@spaces.GPU(duration=
|
122 |
def generate_music(
|
123 |
genre_txt=None,
|
124 |
lyrics_txt=None,
|
125 |
run_n_segments=2,
|
126 |
-
max_new_tokens=
|
127 |
use_audio_prompt=False,
|
128 |
audio_prompt_path="",
|
129 |
prompt_start_time=0.0,
|
130 |
prompt_end_time=30.0,
|
131 |
cuda_idx=0,
|
132 |
rescale=False,
|
|
|
133 |
):
|
134 |
"""
|
135 |
Generates music based on given genre and lyrics, optionally using an audio prompt.
|
@@ -139,7 +140,7 @@ def generate_music(
|
|
139 |
if use_audio_prompt and not audio_prompt_path:
|
140 |
raise FileNotFoundError("Please provide an audio prompt file when 'Use Audio Prompt' is enabled!")
|
141 |
cuda_idx = cuda_idx
|
142 |
-
max_new_tokens = max_new_tokens * 100
|
143 |
|
144 |
with tempfile.TemporaryDirectory() as output_dir:
|
145 |
stage1_output_dir = os.path.join(output_dir, f"stage1")
|
@@ -332,7 +333,7 @@ with gr.Blocks() as demo:
|
|
332 |
audio_prompt_input = gr.Audio(type="filepath", label="Audio Prompt (Optional)")
|
333 |
with gr.Column():
|
334 |
num_segments = gr.Number(label="Number of Segments", value=2, interactive=True)
|
335 |
-
max_new_tokens = gr.Slider(label="Duration of song", minimum=1, maximum=
|
336 |
submit_btn = gr.Button("Submit")
|
337 |
music_out = gr.Audio(label="Mixed Audio Result")
|
338 |
with gr.Accordion(label="Vocal and Instrumental Result", open=False):
|
|
|
118 |
structured_lyrics = [f"[{seg[0]}]\n{seg[1].strip()}\n\n" for seg in segments]
|
119 |
return structured_lyrics
|
120 |
|
121 |
+
@spaces.GPU(duration=178)
|
122 |
def generate_music(
|
123 |
genre_txt=None,
|
124 |
lyrics_txt=None,
|
125 |
run_n_segments=2,
|
126 |
+
max_new_tokens=50,
|
127 |
use_audio_prompt=False,
|
128 |
audio_prompt_path="",
|
129 |
prompt_start_time=0.0,
|
130 |
prompt_end_time=30.0,
|
131 |
cuda_idx=0,
|
132 |
rescale=False,
|
133 |
+
progress=gr.Progress()
|
134 |
):
|
135 |
"""
|
136 |
Generates music based on given genre and lyrics, optionally using an audio prompt.
|
|
|
140 |
if use_audio_prompt and not audio_prompt_path:
|
141 |
raise FileNotFoundError("Please provide an audio prompt file when 'Use Audio Prompt' is enabled!")
|
142 |
cuda_idx = cuda_idx
|
143 |
+
max_new_tokens = int(max_new_tokens * (100/run_n_segments))
|
144 |
|
145 |
with tempfile.TemporaryDirectory() as output_dir:
|
146 |
stage1_output_dir = os.path.join(output_dir, f"stage1")
|
|
|
333 |
audio_prompt_input = gr.Audio(type="filepath", label="Audio Prompt (Optional)")
|
334 |
with gr.Column():
|
335 |
num_segments = gr.Number(label="Number of Segments", value=2, interactive=True)
|
336 |
+
max_new_tokens = gr.Slider(label="Duration of song", minimum=1, maximum=50, step=1, value=30, interactive=True)
|
337 |
submit_btn = gr.Button("Submit")
|
338 |
music_out = gr.Audio(label="Mixed Audio Result")
|
339 |
with gr.Accordion(label="Vocal and Instrumental Result", open=False):
|