Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -291,43 +291,50 @@ def gradio_interface(audio_file, lyrics, output_name, fps=30, vidwidth=1280, vid
|
|
291 |
def update_srt_output_visibility(haslyrics):
|
292 |
return gr.update(visible=haslyrics)
|
293 |
|
294 |
-
with gr.Blocks() as
|
295 |
gr.Markdown('Upload an MP3 file and configure parameters to create a visualization video.\nOptionally upload a word or line synced lyric file\nEnsure a blank line at the end to avoid conversion errors')
|
296 |
-
with gr.Accordion(label="Audio Settings", open=True):
|
297 |
-
gr.Markdown('#Load your mp3 and lyrics file here')
|
298 |
-
audio_file = gr.components.File(label="Upload your MP3 file", file_count='single', file_types=['mp3'])
|
299 |
-
lyrics_file = gr.components.File(label="(Optional) Upload Lyrics as LRC or SRT", file_count='single', file_types=['lrc', 'srt'])
|
300 |
-
|
301 |
-
with gr.Accordion(label="Video Output Settings"):
|
302 |
-
gr.Markdown('#Configure Video Output Here')
|
303 |
-
output_name = gr.components.Textbox(label="Output Video Name", value='video')
|
304 |
-
fps_slider = gr.components.Slider(label="Frames per Second", minimum=20, maximum=60, step=1, value=30)
|
305 |
-
vidwidth_slider = gr.components.Slider(label="Output Video Width", minimum=100, maximum=2000, value=1280, step=2)
|
306 |
-
vidheight_slider = gr.components.Slider(label="Output Video Height", minimum=100, maximum=2000, value=720, step=2)
|
307 |
-
|
308 |
-
with gr.Accordion(label="Advanced Options"):
|
309 |
-
oscres_slider = gr.components.Slider(label="Number of Visualization Segments", minimum=256, maximum=2048, step=2, value=512)
|
310 |
-
|
311 |
-
with gr.Accordion(label="Mp3 Metadata"):
|
312 |
-
gr.Markdown('#Add Metadata here if your mp3 does not have one')
|
313 |
-
cover_img = gr.components.Image(label='Cover Art')
|
314 |
-
title_input = gr.components.Textbox(label='Title')
|
315 |
-
artist_input = gr.components.Textbox(label='Artists')
|
316 |
-
|
317 |
-
output_video = gr.components.Video(label="Output")
|
318 |
-
srt_output = gr.components.File(label="SRT Output", visible=False)
|
319 |
-
|
320 |
-
inputs.load(fn=gradio_interface,
|
321 |
-
inputs=[audio_file, lyrics_file, output_name, fps_slider, vidwidth_slider, vidheight_slider, oscres_slider, cover_img, title_input, artist_input],
|
322 |
-
outputs=[output_video, srt_output])
|
323 |
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
331 |
|
332 |
# Launch Gradio interface
|
333 |
-
|
|
|
291 |
def update_srt_output_visibility(haslyrics):
|
292 |
return gr.update(visible=haslyrics)
|
293 |
|
294 |
+
with gr.Blocks() as demo:
|
295 |
gr.Markdown('Upload an MP3 file and configure parameters to create a visualization video.\nOptionally upload a word or line synced lyric file\nEnsure a blank line at the end to avoid conversion errors')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
296 |
|
297 |
+
with gr.Row():
|
298 |
+
with gr.Column():
|
299 |
+
gr.Markdown('# Audio Settings')
|
300 |
+
audio_file = gr.File(label="Upload your MP3 file", file_count='single', file_types=['mp3'])
|
301 |
+
lyrics_file = gr.File(label="(Optional) Upload Lyrics as LRC or SRT", file_count='single', file_types=['lrc', 'srt'])
|
302 |
+
|
303 |
+
with gr.Column():
|
304 |
+
gr.Markdown('# Video Output Settings')
|
305 |
+
output_name = gr.Textbox(label="Output Video Name", value='video')
|
306 |
+
fps_slider = gr.Slider(label="Frames per Second", minimum=20, maximum=60, step=1, value=30)
|
307 |
+
vidwidth_slider = gr.Slider(label="Output Video Width", minimum=100, maximum=2000, value=1280, step=2)
|
308 |
+
vidheight_slider = gr.Slider(label="Output Video Height", minimum=100, maximum=2000, value=720, step=2)
|
309 |
+
|
310 |
+
with gr.Row():
|
311 |
+
with gr.Column():
|
312 |
+
gr.Markdown('# Advanced Options')
|
313 |
+
oscres_slider = gr.Slider(label="Number of Visualization Segments", minimum=256, maximum=2048, step=2, value=512)
|
314 |
+
|
315 |
+
with gr.Column():
|
316 |
+
gr.Markdown('# Mp3 Metadata')
|
317 |
+
cover_img = gr.Image(label='Cover Art')
|
318 |
+
title_input = gr.Textbox(label='Title')
|
319 |
+
artist_input = gr.Textbox(label='Artists')
|
320 |
+
|
321 |
+
with gr.Row():
|
322 |
+
output_video = gr.Video(label="Output")
|
323 |
+
srt_output = gr.File(label="SRT Output", visible=False)
|
324 |
+
|
325 |
+
# Connect the inputs to the function
|
326 |
+
demo.load(
|
327 |
+
fn=gradio_interface,
|
328 |
+
inputs=[audio_file, lyrics_file, output_name, fps_slider, vidwidth_slider, vidheight_slider, oscres_slider, cover_img, title_input, artist_input],
|
329 |
+
outputs=[output_video, srt_output]
|
330 |
+
)
|
331 |
+
|
332 |
+
# Update visibility of SRT output
|
333 |
+
demo.load(
|
334 |
+
fn=update_srt_output_visibility,
|
335 |
+
inputs=lyrics_file,
|
336 |
+
outputs=srt_output
|
337 |
+
)
|
338 |
|
339 |
# Launch Gradio interface
|
340 |
+
demo.launch()
|