File size: 559 Bytes
ed4d752 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
import gradio as gr
from transformers import Tacotron2Processor, Tacotron2ForConditionalGeneration
# تحميل النموذج والمعالج
processor = Tacotron2Processor.from_pretrained("facebook/tacotron2")
model = Tacotron2ForConditionalGeneration.from_pretrained("facebook/tacotron2")
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="Najdi TTS Model")
iface.launch()
|