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