rutsam commited on
Commit
2dadc0d
·
1 Parent(s): 84f4ed8

deploy new app

Browse files
Files changed (1) hide show
  1. app.py +9 -9
app.py CHANGED
@@ -3,7 +3,7 @@ from typing import Optional
3
  import gradio as gr
4
  import subprocess
5
  import numpy as np
6
- from TTS.api import TTS
7
 
8
 
9
  MAX_TXT_LEN = 100
@@ -29,16 +29,16 @@ def generate_audio(text):
29
  # text1 = subprocess.check_output("pwd", shell=True)+ subprocess.check_output("ls Kinyarwanda_YourTTS", shell=True)
30
  # text2 = text1.decode("utf-8")
31
  # return text2
32
- tts = TTS(model_path="Kinyarwanda_YourTTS/model.pth",
33
- config_path="Kinyarwanda_YourTTS/config.json",
34
  tts_speakers_file="Kinyarwanda_YourTTS/speakers.pth",
35
  encoder_checkpoint="Kinyarwanda_YourTTS/SE_checkpoint.pth.tar",
36
  encoder_config="Kinyarwanda_YourTTS/config_se.json",)
37
- wav = tts.tts(text, speaker_wav="Kinyarwanda_YourTTS/conditioning_audio.wav")
38
- # with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as fp:
39
- # synthesizer.save_wav(wav, fp)
40
- # return fp.name
41
- return wav
42
 
43
  iface = gr.Interface(
44
  fn=generate_audio,
@@ -48,7 +48,7 @@ iface = gr.Interface(
48
  default="This sentence has been generated by a speech synthesis system.",
49
  ),
50
  ],
51
- outputs=gr.outputs.Audio(type="numpy",label="Output"),
52
  #outputs=gr.outputs.Textbox(label="Recognized speech from speechbrain model"),
53
  title="Kinyarwanda tts Demo",
54
  description="Kinyarwanda tts build with ",
 
3
  import gradio as gr
4
  import subprocess
5
  import numpy as np
6
+ from TTS.utils.synthesizer import Synthesizer
7
 
8
 
9
  MAX_TXT_LEN = 100
 
29
  # text1 = subprocess.check_output("pwd", shell=True)+ subprocess.check_output("ls Kinyarwanda_YourTTS", shell=True)
30
  # text2 = text1.decode("utf-8")
31
  # return text2
32
+ synthesizer = Synthesizer("./Kinyarwanda_YourTTS/model.pth",
33
+ "Kinyarwanda_YourTTS/config.json",
34
  tts_speakers_file="Kinyarwanda_YourTTS/speakers.pth",
35
  encoder_checkpoint="Kinyarwanda_YourTTS/SE_checkpoint.pth.tar",
36
  encoder_config="Kinyarwanda_YourTTS/config_se.json",)
37
+ wav = synthesizer.tts(text, speaker_wav="Kinyarwanda_YourTTS/conditioning_audio.wav")
38
+ with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as fp:
39
+ synthesizer.save_wav(wav, fp)
40
+ return fp.name
41
+
42
 
43
  iface = gr.Interface(
44
  fn=generate_audio,
 
48
  default="This sentence has been generated by a speech synthesis system.",
49
  ),
50
  ],
51
+ outputs=gr.outputs.Audio(type="file",label="Output"),
52
  #outputs=gr.outputs.Textbox(label="Recognized speech from speechbrain model"),
53
  title="Kinyarwanda tts Demo",
54
  description="Kinyarwanda tts build with ",