SeyedAli commited on
Commit
56d59fe
1 Parent(s): 58be996

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -2
app.py CHANGED
@@ -7,7 +7,8 @@ import torchaudio
7
 
8
  model = VitsModel.from_pretrained("SeyedAli/Persian-Speech-synthesis")
9
  tokenizer = AutoTokenizer.from_pretrained("SeyedAli/Persian-Speech-synthesis")
10
-
 
11
  def TTS(text):
12
  inputs = tokenizer(text, return_tensors="pt")
13
  with torch.no_grad():
@@ -15,5 +16,5 @@ def TTS(text):
15
  with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as fp:
16
  torchaudio.save(fp, output, model.config.sampling_rate,format="wav")
17
  return fp.name
18
- iface = gr.Interface(fn=TTS, inputs="text", outputs="audio")
19
  iface.launch(share=False)
 
7
 
8
  model = VitsModel.from_pretrained("SeyedAli/Persian-Speech-synthesis")
9
  tokenizer = AutoTokenizer.from_pretrained("SeyedAli/Persian-Speech-synthesis")
10
+ text_input = gr.TextArea(label="متن فارسی", type="text")
11
+ audio_output = gr.Audio(label="صوت گفتار فارسی", type="filepath")
12
  def TTS(text):
13
  inputs = tokenizer(text, return_tensors="pt")
14
  with torch.no_grad():
 
16
  with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as fp:
17
  torchaudio.save(fp, output, model.config.sampling_rate,format="wav")
18
  return fp.name
19
+ iface = gr.Interface(fn=TTS, inputs=text_input, outputs=audio_output)
20
  iface.launch(share=False)