megaaziib commited on
Commit
64674d6
1 Parent(s): b7d2d2a

rollback tts

Browse files
Files changed (1) hide show
  1. app.py +8 -18
app.py CHANGED
@@ -28,15 +28,15 @@ def create_vc_fn(tgt_sr, net_g, vc, if_f0, file_index, file_big_npy):
28
  index_rate,
29
  tts_mode,
30
  tts_text,
31
- tts_speaker
32
  ):
33
  try:
34
  if tts_mode:
35
  if len(tts_text) > 600 and limitation:
36
  return "Text is too long", None
37
- if tts_text is None or tts_speaker is None:
38
  return "You need to enter text and select a voice", None
39
- asyncio.run(edge_tts.Communicate(tts_text, tts_speaker).save("tts.mp3"))
40
  audio, sr = librosa.load("tts.mp3", sr=16000, mono=True)
41
  else:
42
  if args.files:
@@ -106,8 +106,8 @@ if __name__ == '__main__':
106
  args, unknown = parser.parse_known_args()
107
  load_hubert()
108
  models = []
109
- tts_speakers_list = asyncio.get_event_loop().run_until_complete(edge_tts.list_voices())
110
- speaker = tts_speakers_list[tts_speaker]['ShortName']
111
  with open("weights/model_info.json", "r", encoding="utf-8") as f:
112
  models_info = json.load(f)
113
  for name, info in models_info.items():
@@ -175,21 +175,11 @@ if __name__ == '__main__':
175
  )
176
  tts_mode = gr.Checkbox(label="tts (use edge-tts as input)", value=False)
177
  tts_text = gr.Textbox(visible=False,label="TTS text (600 words limitation)" if limitation else "TTS text")
178
- tts_speaker = gr.Dropdown(
179
- [
180
- '%s (%s)' % (
181
- s['FriendlyName'],
182
- s['Gender']
183
- )
184
- for s in tts_speakers_list
185
- ],
186
- label='TTS speaker',
187
- type='index'
188
- )
189
  vc_submit = gr.Button("Generate", variant="primary")
190
  with gr.Column():
191
  vc_output1 = gr.Textbox(label="Output Message")
192
  vc_output2 = gr.Audio(label="Output Audio")
193
- vc_submit.click(vc_fn, [vc_input, vc_transpose, vc_f0method, vc_index_ratio, tts_mode, tts_text, tts_speaker], [vc_output1, vc_output2])
194
- tts_mode.change(change_to_tts_mode, [tts_mode], [vc_input, tts_text, tts_speaker])
195
  app.queue(concurrency_count=1, max_size=20, api_open=args.api).launch(share=args.share)
 
28
  index_rate,
29
  tts_mode,
30
  tts_text,
31
+ tts_voice
32
  ):
33
  try:
34
  if tts_mode:
35
  if len(tts_text) > 600 and limitation:
36
  return "Text is too long", None
37
+ if tts_text is None or tts_voice is None:
38
  return "You need to enter text and select a voice", None
39
+ asyncio.run(edge_tts.Communicate(tts_text, "-".join(tts_voice.split('-')[:-1])).save("tts.mp3"))
40
  audio, sr = librosa.load("tts.mp3", sr=16000, mono=True)
41
  else:
42
  if args.files:
 
106
  args, unknown = parser.parse_known_args()
107
  load_hubert()
108
  models = []
109
+ tts_voice_list = asyncio.get_event_loop().run_until_complete(edge_tts.list_voices())
110
+ voices = [f"{v['ShortName']}-{v['Gender']}" for v in tts_voice_list]
111
  with open("weights/model_info.json", "r", encoding="utf-8") as f:
112
  models_info = json.load(f)
113
  for name, info in models_info.items():
 
175
  )
176
  tts_mode = gr.Checkbox(label="tts (use edge-tts as input)", value=False)
177
  tts_text = gr.Textbox(visible=False,label="TTS text (600 words limitation)" if limitation else "TTS text")
178
+ tts_voice = gr.Dropdown(label="Edge-tts speaker", choices=voices, visible=False, allow_custom_value=False, value="en-US-AnaNeural-Female")
 
 
 
 
 
 
 
 
 
 
179
  vc_submit = gr.Button("Generate", variant="primary")
180
  with gr.Column():
181
  vc_output1 = gr.Textbox(label="Output Message")
182
  vc_output2 = gr.Audio(label="Output Audio")
183
+ vc_submit.click(vc_fn, [vc_input, vc_transpose, vc_f0method, vc_index_ratio, tts_mode, tts_text, tts_voice], [vc_output1, vc_output2])
184
+ tts_mode.change(change_to_tts_mode, [tts_mode], [vc_input, tts_text, tts_voice])
185
  app.queue(concurrency_count=1, max_size=20, api_open=args.api).launch(share=args.share)