Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -32,6 +32,18 @@ def set_tts():
|
|
| 32 |
def create_kd_talker():
|
| 33 |
return Inferencer()
|
| 34 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
@spaces.GPU
|
| 36 |
def predict(prompt, upload_reference_audio, microphone_reference_audio, reference_audio_type):
|
| 37 |
global result_dir
|
|
@@ -80,7 +92,6 @@ def main():
|
|
| 80 |
with gr.Tabs(elem_id="kdtalker_source_image"):
|
| 81 |
with gr.TabItem("Upload image"):
|
| 82 |
source_image = gr.Image(label="Source image", sources="upload", type="filepath", scale=256)
|
| 83 |
-
|
| 84 |
with gr.Tabs(elem_id="kdtalker_driven_audio"):
|
| 85 |
with gr.TabItem("Upload"):
|
| 86 |
upload_driven_audio = gr.Audio(label="Upload audio", sources="upload", type="filepath")
|
|
@@ -116,6 +127,18 @@ def main():
|
|
| 116 |
],
|
| 117 |
outputs=[gen_video]
|
| 118 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 119 |
return interface
|
| 120 |
|
| 121 |
|
|
|
|
| 32 |
def create_kd_talker():
|
| 33 |
return Inferencer()
|
| 34 |
|
| 35 |
+
example_folder = "example"
|
| 36 |
+
example_choices = ["Example 1", "Example 2", "Example 3"]
|
| 37 |
+
example_mapping = {
|
| 38 |
+
"Example 1": {"audio": os.path.join(example_folder, "example1.wav"), "image": os.path.join(example_folder, "example1.png")},
|
| 39 |
+
"Example 2": {"audio": os.path.join(example_folder, "example2.wav"), "image": os.path.join(example_folder, "example2.png")},
|
| 40 |
+
"Example 3": {"audio": os.path.join(example_folder, "example3.wav"), "image": os.path.join(example_folder, "example3.png")},
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
def load_example(choice):
|
| 44 |
+
example = example_mapping.get(choice, {})
|
| 45 |
+
return example.get("audio", ""), example.get("image", "")
|
| 46 |
+
|
| 47 |
@spaces.GPU
|
| 48 |
def predict(prompt, upload_reference_audio, microphone_reference_audio, reference_audio_type):
|
| 49 |
global result_dir
|
|
|
|
| 92 |
with gr.Tabs(elem_id="kdtalker_source_image"):
|
| 93 |
with gr.TabItem("Upload image"):
|
| 94 |
source_image = gr.Image(label="Source image", sources="upload", type="filepath", scale=256)
|
|
|
|
| 95 |
with gr.Tabs(elem_id="kdtalker_driven_audio"):
|
| 96 |
with gr.TabItem("Upload"):
|
| 97 |
upload_driven_audio = gr.Audio(label="Upload audio", sources="upload", type="filepath")
|
|
|
|
| 127 |
],
|
| 128 |
outputs=[gen_video]
|
| 129 |
)
|
| 130 |
+
with gr.TabItem("Example"):
|
| 131 |
+
example_choice = gr.Dropdown(choices=example_choices, label="Choose an example")
|
| 132 |
+
example_audio = gr.Audio(label="Example Audio", type="filepath")
|
| 133 |
+
example_image = gr.Image(label="Example Image", type="filepath")
|
| 134 |
+
|
| 135 |
+
example_choice.change(
|
| 136 |
+
fn=load_example,
|
| 137 |
+
inputs=[example_choice],
|
| 138 |
+
outputs=[upload_driven_audio, source_image]
|
| 139 |
+
)
|
| 140 |
+
example_choice.change(set_upload, outputs=driven_audio_type)
|
| 141 |
+
|
| 142 |
return interface
|
| 143 |
|
| 144 |
|