coraKong commited on
Commit
6045b6b
·
1 Parent(s): 392fff0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -11
app.py CHANGED
@@ -4,9 +4,7 @@ from TTS.api import TTS
4
  # Init TTS
5
  tts = TTS(model_name="tts_models/multilingual/multi-dataset/your_tts", progress_bar = False, gpu=False)
6
  zh_tts = TTS(model_name="tts_models/zh-CN/baker/tacotron2-DDC-GST", progress_bar=False, gpu=False)
7
- # en_tts = TTS(model_name = "tts_models/en/ljspeech/vits", gpu=False)
8
- # fr_tts = TTS(model_name = "tts_models/fr/css10/vits", gpu=False)
9
- # de_tts = TTS(model_name = "tts_models/de/thorsten/vits", gpu=False)
10
 
11
  def text_to_speech(text: str, speaker_wav, speaker_wav_file, language: str):
12
  if speaker_wav_file and not speaker_wav:
@@ -17,16 +15,11 @@ def text_to_speech(text: str, speaker_wav, speaker_wav_file, language: str):
17
  # zh_tts.tts_to_file(text, speaker_wav=speaker_wav, file_path=file_path)
18
  # else:
19
  zh_tts.tts_to_file(text, file_path=file_path)
20
- # elif language == "de":
21
  # if speaker_wav is not None:
22
  # de_tts.tts_to_file(text, speaker_wav=speaker_wav, file_path=file_path)
23
  # else:
24
- # de_tts.tts_to_file(text, file_path=file_path)
25
- # elif language == "en":
26
- # if speaker_wav is not None:
27
- # en_tts.tts_to_file(text, speaker_wav=speaker_wav, file_path=file_path)
28
- # else:
29
- # en_tts.tts_to_file(text, file_path=file_path)
30
  else:
31
  if speaker_wav is not None:
32
  tts.tts_to_file(text, speaker_wav=speaker_wav, language=language, file_path=file_path)
@@ -37,7 +30,7 @@ def text_to_speech(text: str, speaker_wav, speaker_wav_file, language: str):
37
  inputs = [gr.Textbox(label="Input the text", value="", max_lines=3),
38
  gr.Audio(label="Voice to clone", source="microphone", type="filepath"),
39
  gr.Audio(label="Voice to clone", type="filepath"),
40
- gr.Radio(label="Language", choices=["en", "zh-CN", "fr-fr"], value="en")]
41
  outputs = gr.Audio(label="Output")
42
 
43
  demo = gr.Interface(fn=text_to_speech, inputs=inputs, outputs=outputs)
 
4
  # Init TTS
5
  tts = TTS(model_name="tts_models/multilingual/multi-dataset/your_tts", progress_bar = False, gpu=False)
6
  zh_tts = TTS(model_name="tts_models/zh-CN/baker/tacotron2-DDC-GST", progress_bar=False, gpu=False)
7
+ de_tts = TTS(model_name = "tts_models/de/thorsten/vits", gpu=False)
 
 
8
 
9
  def text_to_speech(text: str, speaker_wav, speaker_wav_file, language: str):
10
  if speaker_wav_file and not speaker_wav:
 
15
  # zh_tts.tts_to_file(text, speaker_wav=speaker_wav, file_path=file_path)
16
  # else:
17
  zh_tts.tts_to_file(text, file_path=file_path)
18
+ elif language == "de":
19
  # if speaker_wav is not None:
20
  # de_tts.tts_to_file(text, speaker_wav=speaker_wav, file_path=file_path)
21
  # else:
22
+ de_tts.tts_to_file(text, file_path=file_path)
 
 
 
 
 
23
  else:
24
  if speaker_wav is not None:
25
  tts.tts_to_file(text, speaker_wav=speaker_wav, language=language, file_path=file_path)
 
30
  inputs = [gr.Textbox(label="Input the text", value="", max_lines=3),
31
  gr.Audio(label="Voice to clone", source="microphone", type="filepath"),
32
  gr.Audio(label="Voice to clone", type="filepath"),
33
+ gr.Radio(label="Language", choices=["en", "zh-CN", "fr-fr", "de"], value="en")]
34
  outputs = gr.Audio(label="Output")
35
 
36
  demo = gr.Interface(fn=text_to_speech, inputs=inputs, outputs=outputs)