Spaces:
Runtime error
Runtime error
File size: 707 Bytes
e7db7ab 03fc43e 8d12a0e 03fc43e e7db7ab 73316e5 03fc43e b32b19f 675c596 e7db7ab 675c596 e7db7ab ef3739a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
import tempfile ,os
import gradio as gr
from transformers import VitsModel, AutoTokenizer,pipeline
import torch
import scipy
def TTS(text):
model = VitsModel.from_pretrained("SeyedAli/Persian-Speech-synthesis")
tokenizer = AutoTokenizer.from_pretrained("SeyedAli/Persian-Speech-synthesis")
#inputs = tokenizer(text, return_tensors="pt")
inputs = tokenizer(text)
with torch.no_grad():
output = model(**inputs).waveform
with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as fp:
scipy.io.wavfile.write(fp, rate=model.config.sampling_rate, data=output)
return fp.name
iface = gr.Interface(fn=TTS, inputs="text", outputs="audio")
iface.launch(share=False) |