Spaces:
Running
Running
ziqiangao
commited on
Commit
·
797a642
1
Parent(s):
fde84dd
refactor ui
Browse files
app.py
CHANGED
@@ -267,7 +267,6 @@ def main(file, name, fps=30, res: tuple=(1280,720), oscres=512, sr=11025, lyrics
|
|
267 |
print('Frame Count: ' + str(num_frames))
|
268 |
print('Segments per frame: ' + str(oscres))
|
269 |
print('---------------------------------------------------------')
|
270 |
-
start_progress("Rendering:")
|
271 |
try:
|
272 |
with Pool(cpu_count()) as pool:
|
273 |
num_frames = len(samples_array) // (sr // fps)
|
@@ -275,12 +274,9 @@ def main(file, name, fps=30, res: tuple=(1280,720), oscres=512, sr=11025, lyrics
|
|
275 |
for _ in pool.imap_unordered(render_frame, params):
|
276 |
iii += 1 # Increment frame count for progress
|
277 |
p((iii, num_frames), desc="Rendering Frames")
|
278 |
-
progress((iii/num_frames)*100)
|
279 |
|
280 |
except Exception as e:
|
281 |
raise gr.Error("Something went wrong whilst rendering")
|
282 |
-
finally:
|
283 |
-
end_progress()
|
284 |
|
285 |
p = gr.Progress()
|
286 |
p(0.5, desc="Compiling video")
|
@@ -347,6 +343,11 @@ with gr.Blocks() as demo:
|
|
347 |
gr.Markdown('## Load your mp3 file here')
|
348 |
audio_file = gr.File(label="Upload your MP3 file", file_count='single', file_types=['mp3'])
|
349 |
|
|
|
|
|
|
|
|
|
|
|
350 |
|
351 |
with gr.Accordion(label="Video Output Settings", open=False):
|
352 |
gr.Markdown('## Configure Video Output Here')
|
@@ -360,11 +361,7 @@ with gr.Blocks() as demo:
|
|
360 |
gr.Markdown('If uploading LRC, ensure a blank timed line at the end to avoid conversion errors')
|
361 |
lyrics_file = gr.File(label="(Optional) Upload Lyrics as LRC or SRT", file_count='single', file_types=['lrc', 'srt'])
|
362 |
|
363 |
-
|
364 |
-
gr.Markdown('## Add Metadata here if your mp3 does not have one')
|
365 |
-
cover_img = gr.Image(label='Cover Art', type="filepath")
|
366 |
-
title_input = gr.Textbox(label='Title')
|
367 |
-
artist_input = gr.Textbox(label='Artists')
|
368 |
|
369 |
# Add a submit button
|
370 |
submit_btn = gr.Button("Generate Video")
|
@@ -372,20 +369,14 @@ with gr.Blocks() as demo:
|
|
372 |
# Outputs on the right
|
373 |
with gr.Column():
|
374 |
output_video = gr.Video(label="Output")
|
375 |
-
|
|
|
376 |
|
377 |
# Bind the button to the function
|
378 |
submit_btn.click(
|
379 |
fn=gradio_interface,
|
380 |
inputs=[audio_file, lyrics_file, output_name, fps_slider, vidwidth_slider, vidheight_slider, oscres_slider, cover_img, title_input, artist_input],
|
381 |
-
outputs=[output_video, srt_output
|
382 |
-
)
|
383 |
-
|
384 |
-
# Update visibility of SRT output
|
385 |
-
demo.load(
|
386 |
-
fn=update_srt_output_visibility,
|
387 |
-
inputs=gr.State(),
|
388 |
-
outputs=srt_output
|
389 |
)
|
390 |
|
391 |
# Launch Gradio interface
|
|
|
267 |
print('Frame Count: ' + str(num_frames))
|
268 |
print('Segments per frame: ' + str(oscres))
|
269 |
print('---------------------------------------------------------')
|
|
|
270 |
try:
|
271 |
with Pool(cpu_count()) as pool:
|
272 |
num_frames = len(samples_array) // (sr // fps)
|
|
|
274 |
for _ in pool.imap_unordered(render_frame, params):
|
275 |
iii += 1 # Increment frame count for progress
|
276 |
p((iii, num_frames), desc="Rendering Frames")
|
|
|
277 |
|
278 |
except Exception as e:
|
279 |
raise gr.Error("Something went wrong whilst rendering")
|
|
|
|
|
280 |
|
281 |
p = gr.Progress()
|
282 |
p(0.5, desc="Compiling video")
|
|
|
343 |
gr.Markdown('## Load your mp3 file here')
|
344 |
audio_file = gr.File(label="Upload your MP3 file", file_count='single', file_types=['mp3'])
|
345 |
|
346 |
+
with gr.Accordion(label="Mp3 Metadata", open=False):
|
347 |
+
gr.Markdown('## Add Metadata here if your mp3 does not have one')
|
348 |
+
cover_img = gr.Image(label='Cover Art', type="filepath")
|
349 |
+
title_input = gr.Textbox(label='Title')
|
350 |
+
artist_input = gr.Textbox(label='Artists')
|
351 |
|
352 |
with gr.Accordion(label="Video Output Settings", open=False):
|
353 |
gr.Markdown('## Configure Video Output Here')
|
|
|
361 |
gr.Markdown('If uploading LRC, ensure a blank timed line at the end to avoid conversion errors')
|
362 |
lyrics_file = gr.File(label="(Optional) Upload Lyrics as LRC or SRT", file_count='single', file_types=['lrc', 'srt'])
|
363 |
|
364 |
+
|
|
|
|
|
|
|
|
|
365 |
|
366 |
# Add a submit button
|
367 |
submit_btn = gr.Button("Generate Video")
|
|
|
369 |
# Outputs on the right
|
370 |
with gr.Column():
|
371 |
output_video = gr.Video(label="Output")
|
372 |
+
with gr.Accordion(label="SRT File (Only used if lyrics is provided)", open=False):
|
373 |
+
srt_output = gr.File(label="SRT Output")
|
374 |
|
375 |
# Bind the button to the function
|
376 |
submit_btn.click(
|
377 |
fn=gradio_interface,
|
378 |
inputs=[audio_file, lyrics_file, output_name, fps_slider, vidwidth_slider, vidheight_slider, oscres_slider, cover_img, title_input, artist_input],
|
379 |
+
outputs=[output_video, srt_output]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
380 |
)
|
381 |
|
382 |
# Launch Gradio interface
|