Aki004 commited on
Commit
5950a5c
1 Parent(s): 59f6c6f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -27
app.py CHANGED
@@ -33,22 +33,6 @@ def infer(txt, input_audio, voice, audio_mode):
33
  raw_path.seek(0)
34
  model = Svc(fr"Herta-Svc/G_10000.pth", f"Herta-Svc/config.json", device = 'cpu')
35
  out_audio, out_sr = model.infer('speaker0', 0, raw_path, auto_predict_f0 = True,)
36
-
37
- if audio_mode:
38
- sampling_rate, audio = input_audio
39
- audio = (audio / np.iinfo(audio.dtype).max).astype(np.float32)
40
-
41
- if len(audio.shape) > 1:
42
- audio = librosa.to_mono(audio.transpose(1, 0))
43
- if sampling_rate != 16000:
44
- audio = librosa.resample(audio, org_sr=sampling_rate, target_sr=16000)
45
-
46
- raw_path = io.BytesIO()
47
- soundfile.write(raw_path, audio, 16000, format="wav")
48
- raw_path.seek(0)
49
- model = Svc(fr"Herta-Svc/G_10000.pth", f"Herta-Svc/config.json", device = 'cpu')
50
- out_audio, out_sr = model.infer('speaker0', 0, raw_path, auto_predict_f0 = True,)
51
-
52
  return (44100, out_audio.cpu().numpy())
53
 
54
  if __name__ == '__main__':
@@ -68,19 +52,9 @@ if __name__ == '__main__':
68
  '</div>')
69
  tts_text = gr.Textbox(label="TTS text (100 words limitation)", visible = True)
70
  tts_voice = gr.Dropdown(choices= tts_get_voices_list(), visible = True)
71
- audio_mode = gr.Checkbox(label = 'Upload audio instead')
72
- audio_input = gr.Audio(label = 'Input Audio')
73
  audio_output = gr.Audio(label="Output Audio")
74
  btn_submit = gr.Button("Generate")
75
 
76
- if audio_mode.update == True:
77
- tts_text = gr.Textbox.update(label="TTS text (100 words limitation)", visible = False, show_label = False)
78
- tts_voice = gr.Dropdown.update(choices= tts_get_voices_list(), visible = False, show_label = False)
79
- audio_input = gr.Audio.update(label = 'Input Audio', visible = True, show_label = True)
80
- else:
81
- tts_text = gr.Textbox.update(label="TTS text (100 words limitation)", visible = True, show_label = True)
82
- tts_voice = gr.Dropdown.update(choices= tts_get_voices_list(), visible = True, show_label = True)
83
- audio_input = gr.Audio.update(label = 'Input Audio', visible = False, show_label = False)
84
 
85
- btn_submit.click(infer, [tts_text, audio_input, tts_voice, audio_mode], [audio_output])
86
  app.queue(concurrency_count=1, api_open=args.api).launch(share=args.share)
 
33
  raw_path.seek(0)
34
  model = Svc(fr"Herta-Svc/G_10000.pth", f"Herta-Svc/config.json", device = 'cpu')
35
  out_audio, out_sr = model.infer('speaker0', 0, raw_path, auto_predict_f0 = True,)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
  return (44100, out_audio.cpu().numpy())
37
 
38
  if __name__ == '__main__':
 
52
  '</div>')
53
  tts_text = gr.Textbox(label="TTS text (100 words limitation)", visible = True)
54
  tts_voice = gr.Dropdown(choices= tts_get_voices_list(), visible = True)
 
 
55
  audio_output = gr.Audio(label="Output Audio")
56
  btn_submit = gr.Button("Generate")
57
 
 
 
 
 
 
 
 
 
58
 
59
+ btn_submit.click(infer, [tts_text, tts_voice], [audio_output])
60
  app.queue(concurrency_count=1, api_open=args.api).launch(share=args.share)