File size: 395 Bytes
011a4c2
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
import gradio as gr
from transformers import pipeline

# Load a reliable text-to-speech pipeline
text_to_speech = pipeline("text-to-speech", model="facebook/fastspeech2-en-ljspeech", framework="pt")

def generate_speech(text):
    output = text_to_speech(text)
    return output["audio"]

gr.Interface(fn=generate_speech, inputs="text", outputs="audio", title="Simple Voice Assistant").launch()