Spaces:
Running on Zero
Running on Zero
Commit ·
e0917de
1
Parent(s): 6d105d2
Sync video upload across all three model tabs
Browse files
app.py
CHANGED
|
@@ -776,13 +776,6 @@ with gr.Blocks(title="Generate Audio for Video") as demo:
|
|
| 776 |
"| **HunyuanFoley** | Cinematic foley requiring high fidelity and explicit creative direction — dramatic SFX, layered environmental design, or any scene where you have a clear written description of the desired sound palette. | Quick one-shot clips where you don't want to write a prompt, or raw impact sounds where timing precision matters more than richness. |"
|
| 777 |
)
|
| 778 |
|
| 779 |
-
# Shared video upload — persists across all model tabs
|
| 780 |
-
shared_video = gr.Video(label="Input Video", interactive=True)
|
| 781 |
-
shared_video_state = gr.State(value=None)
|
| 782 |
-
|
| 783 |
-
# Keep state in sync whenever the shared upload changes
|
| 784 |
-
shared_video.change(fn=lambda v: v, inputs=[shared_video], outputs=[shared_video_state])
|
| 785 |
-
|
| 786 |
with gr.Tabs():
|
| 787 |
|
| 788 |
# ---------------------------------------------------------- #
|
|
@@ -791,6 +784,7 @@ with gr.Blocks(title="Generate Audio for Video") as demo:
|
|
| 791 |
with gr.Tab("TARO"):
|
| 792 |
with gr.Row():
|
| 793 |
with gr.Column():
|
|
|
|
| 794 |
taro_seed = gr.Number(label="Seed (-1 = random)", value=get_random_seed(), precision=0)
|
| 795 |
taro_cfg = gr.Slider(label="CFG Scale", minimum=1, maximum=15, value=7.5, step=0.5)
|
| 796 |
taro_steps = gr.Slider(label="Sampling Steps", minimum=10, maximum=50, value=25, step=1)
|
|
@@ -803,10 +797,10 @@ with gr.Blocks(title="Generate Audio for Video") as demo:
|
|
| 803 |
with gr.Column():
|
| 804 |
taro_slot_grps, taro_slot_vids, taro_slot_auds = _make_output_slots()
|
| 805 |
|
| 806 |
-
for trigger in [
|
| 807 |
trigger.change(
|
| 808 |
fn=_on_video_upload_taro,
|
| 809 |
-
inputs=[
|
| 810 |
outputs=[taro_samples],
|
| 811 |
)
|
| 812 |
taro_samples.change(
|
|
@@ -820,7 +814,7 @@ with gr.Blocks(title="Generate Audio for Video") as demo:
|
|
| 820 |
|
| 821 |
taro_btn.click(
|
| 822 |
fn=_run_taro,
|
| 823 |
-
inputs=[
|
| 824 |
taro_cf_dur, taro_cf_db, taro_samples],
|
| 825 |
outputs=taro_slot_grps + taro_slot_vids + taro_slot_auds,
|
| 826 |
)
|
|
@@ -831,6 +825,7 @@ with gr.Blocks(title="Generate Audio for Video") as demo:
|
|
| 831 |
with gr.Tab("MMAudio"):
|
| 832 |
with gr.Row():
|
| 833 |
with gr.Column():
|
|
|
|
| 834 |
mma_prompt = gr.Textbox(label="Prompt", placeholder="e.g. footsteps on gravel")
|
| 835 |
mma_neg = gr.Textbox(label="Negative Prompt", placeholder="music, speech")
|
| 836 |
mma_seed = gr.Number(label="Seed (-1 = random)", value=get_random_seed(), precision=0)
|
|
@@ -855,7 +850,7 @@ with gr.Blocks(title="Generate Audio for Video") as demo:
|
|
| 855 |
|
| 856 |
mma_btn.click(
|
| 857 |
fn=_run_mmaudio,
|
| 858 |
-
inputs=[
|
| 859 |
mma_cfg, mma_steps, mma_cf_dur, mma_cf_db, mma_samples],
|
| 860 |
outputs=mma_slot_grps + mma_slot_vids + mma_slot_auds,
|
| 861 |
)
|
|
@@ -866,6 +861,7 @@ with gr.Blocks(title="Generate Audio for Video") as demo:
|
|
| 866 |
with gr.Tab("HunyuanFoley"):
|
| 867 |
with gr.Row():
|
| 868 |
with gr.Column():
|
|
|
|
| 869 |
hf_prompt = gr.Textbox(label="Prompt", placeholder="e.g. rain hitting a metal roof")
|
| 870 |
hf_neg = gr.Textbox(label="Negative Prompt", value="noisy, harsh")
|
| 871 |
hf_seed = gr.Number(label="Seed (-1 = random)", value=get_random_seed(), precision=0)
|
|
@@ -891,9 +887,17 @@ with gr.Blocks(title="Generate Audio for Video") as demo:
|
|
| 891 |
|
| 892 |
hf_btn.click(
|
| 893 |
fn=_run_hunyuan,
|
| 894 |
-
inputs=[
|
| 895 |
hf_guidance, hf_steps, hf_size, hf_cf_dur, hf_cf_db, hf_samples],
|
| 896 |
outputs=hf_slot_grps + hf_slot_vids + hf_slot_auds,
|
| 897 |
)
|
| 898 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 899 |
demo.queue(max_size=10).launch()
|
|
|
|
| 776 |
"| **HunyuanFoley** | Cinematic foley requiring high fidelity and explicit creative direction — dramatic SFX, layered environmental design, or any scene where you have a clear written description of the desired sound palette. | Quick one-shot clips where you don't want to write a prompt, or raw impact sounds where timing precision matters more than richness. |"
|
| 777 |
)
|
| 778 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 779 |
with gr.Tabs():
|
| 780 |
|
| 781 |
# ---------------------------------------------------------- #
|
|
|
|
| 784 |
with gr.Tab("TARO"):
|
| 785 |
with gr.Row():
|
| 786 |
with gr.Column():
|
| 787 |
+
taro_video = gr.Video(label="Input Video")
|
| 788 |
taro_seed = gr.Number(label="Seed (-1 = random)", value=get_random_seed(), precision=0)
|
| 789 |
taro_cfg = gr.Slider(label="CFG Scale", minimum=1, maximum=15, value=7.5, step=0.5)
|
| 790 |
taro_steps = gr.Slider(label="Sampling Steps", minimum=10, maximum=50, value=25, step=1)
|
|
|
|
| 797 |
with gr.Column():
|
| 798 |
taro_slot_grps, taro_slot_vids, taro_slot_auds = _make_output_slots()
|
| 799 |
|
| 800 |
+
for trigger in [taro_video, taro_steps, taro_cf_dur]:
|
| 801 |
trigger.change(
|
| 802 |
fn=_on_video_upload_taro,
|
| 803 |
+
inputs=[taro_video, taro_steps, taro_cf_dur],
|
| 804 |
outputs=[taro_samples],
|
| 805 |
)
|
| 806 |
taro_samples.change(
|
|
|
|
| 814 |
|
| 815 |
taro_btn.click(
|
| 816 |
fn=_run_taro,
|
| 817 |
+
inputs=[taro_video, taro_seed, taro_cfg, taro_steps, taro_mode,
|
| 818 |
taro_cf_dur, taro_cf_db, taro_samples],
|
| 819 |
outputs=taro_slot_grps + taro_slot_vids + taro_slot_auds,
|
| 820 |
)
|
|
|
|
| 825 |
with gr.Tab("MMAudio"):
|
| 826 |
with gr.Row():
|
| 827 |
with gr.Column():
|
| 828 |
+
mma_video = gr.Video(label="Input Video")
|
| 829 |
mma_prompt = gr.Textbox(label="Prompt", placeholder="e.g. footsteps on gravel")
|
| 830 |
mma_neg = gr.Textbox(label="Negative Prompt", placeholder="music, speech")
|
| 831 |
mma_seed = gr.Number(label="Seed (-1 = random)", value=get_random_seed(), precision=0)
|
|
|
|
| 850 |
|
| 851 |
mma_btn.click(
|
| 852 |
fn=_run_mmaudio,
|
| 853 |
+
inputs=[mma_video, mma_prompt, mma_neg, mma_seed,
|
| 854 |
mma_cfg, mma_steps, mma_cf_dur, mma_cf_db, mma_samples],
|
| 855 |
outputs=mma_slot_grps + mma_slot_vids + mma_slot_auds,
|
| 856 |
)
|
|
|
|
| 861 |
with gr.Tab("HunyuanFoley"):
|
| 862 |
with gr.Row():
|
| 863 |
with gr.Column():
|
| 864 |
+
hf_video = gr.Video(label="Input Video")
|
| 865 |
hf_prompt = gr.Textbox(label="Prompt", placeholder="e.g. rain hitting a metal roof")
|
| 866 |
hf_neg = gr.Textbox(label="Negative Prompt", value="noisy, harsh")
|
| 867 |
hf_seed = gr.Number(label="Seed (-1 = random)", value=get_random_seed(), precision=0)
|
|
|
|
| 887 |
|
| 888 |
hf_btn.click(
|
| 889 |
fn=_run_hunyuan,
|
| 890 |
+
inputs=[hf_video, hf_prompt, hf_neg, hf_seed,
|
| 891 |
hf_guidance, hf_steps, hf_size, hf_cf_dur, hf_cf_db, hf_samples],
|
| 892 |
outputs=hf_slot_grps + hf_slot_vids + hf_slot_auds,
|
| 893 |
)
|
| 894 |
|
| 895 |
+
# ---- Cross-tab video sync ----
|
| 896 |
+
# When any tab's video changes, push the value to the other two tabs.
|
| 897 |
+
# Clearing (value=None) also propagates so the X button clears all.
|
| 898 |
+
_sync = lambda v: (gr.update(value=v), gr.update(value=v))
|
| 899 |
+
taro_video.change(fn=_sync, inputs=[taro_video], outputs=[mma_video, hf_video])
|
| 900 |
+
mma_video.change(fn=_sync, inputs=[mma_video], outputs=[taro_video, hf_video])
|
| 901 |
+
hf_video.change(fn=_sync, inputs=[hf_video], outputs=[taro_video, mma_video])
|
| 902 |
+
|
| 903 |
demo.queue(max_size=10).launch()
|