File size: 662 Bytes
06aba51
 
280610d
 
 
 
 
 
 
 
 
 
 
06aba51
 
 
280610d
06aba51
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import gradio as gr

# Load model directly
from transformers import AutoProcessor, SpeechT5ForTextToSpeech

processor = AutoProcessor.from_pretrained("burraco135/speecht5_finetuned_voxpopuli_it")
model = SpeechT5ForTextToSpeech.from_pretrained("burraco135/speecht5_finetuned_voxpopuli_it")

def tts(text):
    inputs = processor(text=text, return_tensors="pt")
    vocoder = SpeechT5HifiGan.from_pretrained("microsoft/speecht5_hifigan")
    speech = model.generate_speech(inputs["input_ids"], speaker_embeddings, vocoder=vocoder)
    
def greet(name):
    return "Hello " + name + "!!"

iface = gr.Interface(fn=tts, inputs="text", outputs="audio")
iface.launch()