Spaces:
Paused
Paused
koby commited on
Commit ·
bb8ed57
1
Parent(s): 686a26c
live m:ss label next to duration slider
Browse files
app.py
CHANGED
|
@@ -85,6 +85,14 @@ def get_duration_seconds(audio_path):
|
|
| 85 |
return 0.0
|
| 86 |
|
| 87 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 88 |
def _upload_to_community(wav_path, meta_dict, song_id):
|
| 89 |
"""Silently share songs/<id>/<id>.wav + meta.json to the dataset repo. Never raises."""
|
| 90 |
token = os.environ.get("HF_TOKEN") or os.environ.get("HUGGINGFACE_TOKEN")
|
|
@@ -174,7 +182,9 @@ with gr.Blocks(title="YuE2-3B Music") as demo:
|
|
| 174 |
cot = gr.Radio(["full", "melody", "off"], value="full", label="CoT mode")
|
| 175 |
seed = gr.Number(label="Seed", value=0, precision=0)
|
| 176 |
cfg = gr.Number(label="CFG scale (1.0 = default)", value=1.0, precision=2)
|
| 177 |
-
|
|
|
|
|
|
|
| 178 |
btn = gr.Button("Generate song", variant="primary")
|
| 179 |
with gr.Column():
|
| 180 |
audio = gr.Audio(label="Play song", type="filepath")
|
|
@@ -182,6 +192,7 @@ with gr.Blocks(title="YuE2-3B Music") as demo:
|
|
| 182 |
mp3_file = gr.File(label="Download MP3 320kbps")
|
| 183 |
info = gr.Textbox(label="Info")
|
| 184 |
btn.click(fn=generate, inputs=[style, lyrics, cot, seed, cfg, duration], outputs=[audio, mp3_file, info], queue=True)
|
|
|
|
| 185 |
gr.Markdown(
|
| 186 |
"---\n🎶 **Community songs:** every generation is auto-shared to the "
|
| 187 |
"[YuE2-community dataset](https://huggingface.co/datasets/directedbykobyperez/YuE2-community)"
|
|
|
|
| 85 |
return 0.0
|
| 86 |
|
| 87 |
|
| 88 |
+
def _dur_label(s):
|
| 89 |
+
try:
|
| 90 |
+
s = int(s or 120)
|
| 91 |
+
except Exception:
|
| 92 |
+
s = 120
|
| 93 |
+
return f"{s // 60}:{s % 60:02d} min"
|
| 94 |
+
|
| 95 |
+
|
| 96 |
def _upload_to_community(wav_path, meta_dict, song_id):
|
| 97 |
"""Silently share songs/<id>/<id>.wav + meta.json to the dataset repo. Never raises."""
|
| 98 |
token = os.environ.get("HF_TOKEN") or os.environ.get("HUGGINGFACE_TOKEN")
|
|
|
|
| 182 |
cot = gr.Radio(["full", "melody", "off"], value="full", label="CoT mode")
|
| 183 |
seed = gr.Number(label="Seed", value=0, precision=0)
|
| 184 |
cfg = gr.Number(label="CFG scale (1.0 = default)", value=1.0, precision=2)
|
| 185 |
+
with gr.Row():
|
| 186 |
+
duration = gr.Slider(30, 240, value=120, step=10, label="Duration (max seconds)", scale=4)
|
| 187 |
+
duration_txt = gr.Textbox(value="2:00 min", label="≈ time", scale=1, interactive=False)
|
| 188 |
btn = gr.Button("Generate song", variant="primary")
|
| 189 |
with gr.Column():
|
| 190 |
audio = gr.Audio(label="Play song", type="filepath")
|
|
|
|
| 192 |
mp3_file = gr.File(label="Download MP3 320kbps")
|
| 193 |
info = gr.Textbox(label="Info")
|
| 194 |
btn.click(fn=generate, inputs=[style, lyrics, cot, seed, cfg, duration], outputs=[audio, mp3_file, info], queue=True)
|
| 195 |
+
duration.change(fn=_dur_label, inputs=duration, outputs=duration_txt)
|
| 196 |
gr.Markdown(
|
| 197 |
"---\n🎶 **Community songs:** every generation is auto-shared to the "
|
| 198 |
"[YuE2-community dataset](https://huggingface.co/datasets/directedbykobyperez/YuE2-community)"
|