skytnt commited on
Commit
1276f85
β€’
1 Parent(s): 274ad02

add microphone input

Browse files
Files changed (1) hide show
  1. app.py +16 -4
app.py CHANGED
@@ -85,7 +85,10 @@ def create_vc_fn(model, hps, speaker_ids):
85
 
86
 
87
  def create_soft_vc_fn(model, hps, speaker_ids):
88
- def soft_vc_fn(target_speaker, input_audio):
 
 
 
89
  if input_audio is None:
90
  return "You need to upload an audio", None
91
  sampling_rate, audio = input_audio
@@ -257,15 +260,24 @@ if __name__ == '__main__':
257
  vc_submit.click(vc_fn, [vc_input1, vc_input2, vc_input3], [vc_output1, vc_output2])
258
  with gr.TabItem("Soft Voice Conversion"):
259
  with gr.Tabs():
260
- for i, (name, cover_path, speakers,soft_vc_fn) in enumerate(models_soft_vc):
261
  with gr.TabItem(f"model{i}"):
262
  gr.Markdown(f"## {name}\n\n"
263
  f"![cover](file/{cover_path})")
264
  vc_input1 = gr.Dropdown(label="Target Speaker", choices=speakers, type="index",
265
  value=speakers[0])
266
- vc_input2 = gr.Audio(label="Input Audio (15s limitation)")
 
 
 
 
 
267
  vc_submit = gr.Button("Convert", variant="primary")
268
  vc_output1 = gr.Textbox(label="Output Message")
269
  vc_output2 = gr.Audio(label="Output Audio")
270
- vc_submit.click(soft_vc_fn, [vc_input1, vc_input2], [vc_output1, vc_output2])
 
 
 
 
271
  app.launch()
 
85
 
86
 
87
  def create_soft_vc_fn(model, hps, speaker_ids):
88
+ def soft_vc_fn(target_speaker, input_audio1, input_audio2):
89
+ input_audio = input_audio1
90
+ if input_audio is None:
91
+ input_audio = input_audio2
92
  if input_audio is None:
93
  return "You need to upload an audio", None
94
  sampling_rate, audio = input_audio
 
260
  vc_submit.click(vc_fn, [vc_input1, vc_input2, vc_input3], [vc_output1, vc_output2])
261
  with gr.TabItem("Soft Voice Conversion"):
262
  with gr.Tabs():
263
+ for i, (name, cover_path, speakers, soft_vc_fn) in enumerate(models_soft_vc):
264
  with gr.TabItem(f"model{i}"):
265
  gr.Markdown(f"## {name}\n\n"
266
  f"![cover](file/{cover_path})")
267
  vc_input1 = gr.Dropdown(label="Target Speaker", choices=speakers, type="index",
268
  value=speakers[0])
269
+ source_tabs = gr.Tabs()
270
+ with source_tabs:
271
+ with gr.TabItem("microphone"):
272
+ vc_input2 = gr.Audio(label="Input Audio (15s limitation)", source="microphone")
273
+ with gr.TabItem("upload"):
274
+ vc_input3 = gr.Audio(label="Input Audio (15s limitation)", source="upload")
275
  vc_submit = gr.Button("Convert", variant="primary")
276
  vc_output1 = gr.Textbox(label="Output Message")
277
  vc_output2 = gr.Audio(label="Output Audio")
278
+ # clear inputs
279
+ source_tabs.set_event_trigger("change", None, [], [vc_input2, vc_input3],
280
+ js="()=>[null,null]")
281
+ vc_submit.click(soft_vc_fn, [vc_input1, vc_input2, vc_input3],
282
+ [vc_output1, vc_output2])
283
  app.launch()