Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -5,14 +5,15 @@ import torch
|
|
5 |
import numpy as np
|
6 |
import torchaudio
|
7 |
|
|
|
|
|
8 |
|
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 |
with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as fp:
|
15 |
-
torchaudio.save(fp,
|
16 |
return fp.name
|
17 |
iface = gr.Interface(fn=TTS, inputs="text", outputs="audio")
|
18 |
iface.launch(share=False)
|
|
|
5 |
import numpy as np
|
6 |
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():
|
14 |
+
output = model(**inputs).waveform
|
15 |
with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as fp:
|
16 |
+
torchaudio.save(fp, output, model.config.sampling_rate)
|
17 |
return fp.name
|
18 |
iface = gr.Interface(fn=TTS, inputs="text", outputs="audio")
|
19 |
iface.launch(share=False)
|