|
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]) |
|
|
|
|
|
iface = gr.Interface(fn=tts, inputs="text", outputs="audio", title="FastSpeech2 Najdi TTS Model") |
|
iface.launch() |
|
|