YinuoGuo27 commited on
Commit
2a2d679
·
verified ·
1 Parent(s): 4a6a470

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -4
app.py CHANGED
@@ -19,6 +19,12 @@ for root, dirs, files in os.walk(local_dir):
19
  print(file_path)
20
 
21
  result_dir = "results"
 
 
 
 
 
 
22
 
23
  @spaces.GPU
24
  def predict(prompt, upload_reference_audio, microphone_reference_audio, reference_audio_type):
@@ -69,14 +75,14 @@ def main():
69
  with gr.Tabs(elem_id="kdtalker_driven_audio"):
70
  with gr.TabItem("Upload"):
71
  upload_driven_audio = gr.Audio(label="Upload audio", sources="upload", type="filepath")
72
- upload_driven_audio.change(lambda: "upload", outputs=driven_audio_type)
73
  reference_audio_type = gr.State(value="upload")
74
 
75
  with gr.TabItem("TTS"):
76
  upload_reference_audio = gr.Audio(label="Upload Reference Audio", sources="upload", type="filepath")
77
- upload_reference_audio.change(lambda: "upload", outputs=reference_audio_type)
78
  microphone_reference_audio = gr.Audio(label="Recorded Reference Audio", sources="microphone", type="filepath")
79
- microphone_reference_audio.change(lambda: "microphone", outputs=reference_audio_type)
80
  input_text = gr.Textbox(
81
  label="Generating audio from text",
82
  lines=5,
@@ -85,7 +91,7 @@ def main():
85
  tts_button = gr.Button("Generate audio", elem_id="kdtalker_audio_generate", variant="primary")
86
  tts_driven_audio = gr.Audio(label="Synthesised Audio", type="filepath")
87
  tts_button.click(fn=predict, inputs=[input_text, upload_reference_audio, microphone_reference_audio, reference_audio_type], outputs=[tts_driven_audio])
88
- tts_button.click(lambda: "tts", outputs=driven_audio_type)
89
 
90
  with gr.Column(variant="panel"):
91
  gen_video = gr.Video(label="Generated video", format="mp4", width=256)
 
19
  print(file_path)
20
 
21
  result_dir = "results"
22
+ def set_upload():
23
+ return "upload"
24
+ def set_microphone():
25
+ return "microphone"
26
+ def set_tts():
27
+ return "tts"
28
 
29
  @spaces.GPU
30
  def predict(prompt, upload_reference_audio, microphone_reference_audio, reference_audio_type):
 
75
  with gr.Tabs(elem_id="kdtalker_driven_audio"):
76
  with gr.TabItem("Upload"):
77
  upload_driven_audio = gr.Audio(label="Upload audio", sources="upload", type="filepath")
78
+ upload_driven_audio.change(set_upload, outputs=driven_audio_type)
79
  reference_audio_type = gr.State(value="upload")
80
 
81
  with gr.TabItem("TTS"):
82
  upload_reference_audio = gr.Audio(label="Upload Reference Audio", sources="upload", type="filepath")
83
+ upload_reference_audio.change(set_upload, outputs=reference_audio_type)
84
  microphone_reference_audio = gr.Audio(label="Recorded Reference Audio", sources="microphone", type="filepath")
85
+ microphone_reference_audio.change(set_microphone, outputs=reference_audio_type)
86
  input_text = gr.Textbox(
87
  label="Generating audio from text",
88
  lines=5,
 
91
  tts_button = gr.Button("Generate audio", elem_id="kdtalker_audio_generate", variant="primary")
92
  tts_driven_audio = gr.Audio(label="Synthesised Audio", type="filepath")
93
  tts_button.click(fn=predict, inputs=[input_text, upload_reference_audio, microphone_reference_audio, reference_audio_type], outputs=[tts_driven_audio])
94
+ tts_button.click(set_tts, outputs=driven_audio_type)
95
 
96
  with gr.Column(variant="panel"):
97
  gen_video = gr.Video(label="Generated video", format="mp4", width=256)