0xrushi commited on
Commit
76430ee
2 Parent(s): c852ee2 e7ddf04

Merge branch 'main' of https://huggingface.co/spaces/rushic24/Priyanka-Chopra-TTS

Browse files
Files changed (2) hide show
  1. app.py +4 -5
  2. synthesize.py +1 -31
app.py CHANGED
@@ -12,10 +12,9 @@ description = "Generate english speech from text using a Tacotron2 model" \
12
  article = """<p style='text-align: center'>
13
  <a href='https://rushichaudhari.github.io/posts/2022-01-12-lets-clone-the-voice-of-priyanka-chopra-jonas/'
14
  target='blank'
15
- class='footer'>Blog</a> |
16
- <a href='https://github.com/eugenesiow/practical-ml' target='_blank'
17
- class='footer'>Github Repo</a></p>"""
18
- examples = ["Generate english speech from text using a Tacotron2 model."]
19
 
20
  def inference(text: str):
21
  synthesize(
@@ -32,7 +31,7 @@ gr.Interface(
32
  inputs=[
33
  gr.inputs.Textbox(
34
  label="Input",
35
- default="你好吗?我很好。",
36
  ),
37
  ],
38
  outputs=gr.outputs.Audio(label="Output"),
 
12
  article = """<p style='text-align: center'>
13
  <a href='https://rushichaudhari.github.io/posts/2022-01-12-lets-clone-the-voice-of-priyanka-chopra-jonas/'
14
  target='blank'
15
+ class='footer'>Blog</a></p>"""
16
+ examples = ["Generate english speech from text using a Tacotron2 model.",
17
+ "Two roads diverged in a wood, I took the one less traveled by, And that has made all the difference."]
 
18
 
19
  def inference(text: str):
20
  synthesize(
 
31
  inputs=[
32
  gr.inputs.Textbox(
33
  label="Input",
34
+ default=examples[0],
35
  ),
36
  ],
37
  outputs=gr.outputs.Audio(label="Output"),
synthesize.py CHANGED
@@ -200,34 +200,4 @@ def synthesize(
200
 
201
  if audio_path:
202
  audio = vocoder.generate_audio(mel_outputs_postnet)
203
- write(audio_path, sample_rate, audio)
204
-
205
-
206
- if __name__ == "__main__":
207
- """Synthesize audio using model and vocoder"""
208
- parser = argparse.ArgumentParser(description="Synthesize audio using model and vocoder")
209
- parser.add_argument("-m", "--model_path", type=str, help="tacotron2 model path", required=True)
210
- parser.add_argument("-vm", "--vocoder_model_path", type=str, help="vocoder model path", required=True)
211
- parser.add_argument("-hc", "--hifigan_config_path", type=str, help="hifigan_config path", required=True)
212
- parser.add_argument("-t", "--text", type=str, help="text to synthesize", required=True)
213
- parser.add_argument("-g", "--graph_output_path", type=str, help="path to save alignment graph to", required=False)
214
- parser.add_argument("-a", "--audio_output_path", type=str, help="path to save output audio to", required=False)
215
- parser.add_argument("--silence_padding", type=float, help="Padding between sentences in seconds", default=0.15)
216
- parser.add_argument("--sample_rate", type=int, help="Audio sample rate", default=22050)
217
- args = parser.parse_args()
218
-
219
- assert os.path.isfile(args.model_path), "Model not found"
220
- assert os.path.isfile(args.vocoder_model_path), "vocoder model not found"
221
-
222
- model = load_model(args.model_path)
223
- vocoder = Hifigan(args.vocoder_model_path, args.hifigan_config_path)
224
-
225
- synthesize(
226
- model=model,
227
- text=args.text,
228
- graph_path=args.graph_output_path,
229
- audio_path=args.audio_output_path,
230
- vocoder=vocoder,
231
- silence_padding=args.silence_padding,
232
- sample_rate=args.sample_rate,
233
- )
 
200
 
201
  if audio_path:
202
  audio = vocoder.generate_audio(mel_outputs_postnet)
203
+ write(audio_path, sample_rate, audio)