Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -8,9 +8,12 @@ import scipy
|
|
8 |
def TTS(text):
|
9 |
model = VitsModel.from_pretrained("SeyedAli/Persian-Speech-synthesis")
|
10 |
tokenizer = AutoTokenizer.from_pretrained("SeyedAli/Persian-Speech-synthesis")
|
11 |
-
|
|
|
|
|
|
|
12 |
with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as fp:
|
13 |
-
scipy.io.wavfile.write(fp, rate=model.config.sampling_rate, data=
|
14 |
return fp.name
|
15 |
iface = gr.Interface(fn=TTS, inputs="text", outputs="audio")
|
16 |
iface.launch(share=False)
|
|
|
8 |
def TTS(text):
|
9 |
model = VitsModel.from_pretrained("SeyedAli/Persian-Speech-synthesis")
|
10 |
tokenizer = AutoTokenizer.from_pretrained("SeyedAli/Persian-Speech-synthesis")
|
11 |
+
inputs = tokenizer(text, return_tensors="pt")
|
12 |
+
|
13 |
+
with torch.no_grad():
|
14 |
+
output = model(**inputs).waveform
|
15 |
with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as fp:
|
16 |
+
scipy.io.wavfile.write(fp, rate=model.config.sampling_rate, data=output)
|
17 |
return fp.name
|
18 |
iface = gr.Interface(fn=TTS, inputs="text", outputs="audio")
|
19 |
iface.launch(share=False)
|