tts / app.py
m6011's picture
Update app.py
99c6dce verified
raw
history blame
599 Bytes
import gradio as gr
from transformers import FastSpeechForConditionalGeneration, Wav2Vec2Processor
# تحميل النموذج والمعالج
model = FastSpeechForConditionalGeneration.from_pretrained("facebook/fastspeech2-en-ljspeech")
processor = Wav2Vec2Processor.from_pretrained("facebook/fastspeech2-en-ljspeech")
def tts(text):
inputs = processor(text, return_tensors="pt")
speech = model.generate(**inputs)
return processor.decode(speech[0])
# واجهة Gradio
iface = gr.Interface(fn=tts, inputs="text", outputs="audio", title="FastSpeech2 Najdi TTS Model")
iface.launch()