File size: 639 Bytes
d745698
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import gradio as gr
from tortoise.api import TextToSpeech
from tortoise.utils.audio import load_voice, load_voices
import torchaudio

tts = TextToSpeech()

def generate_audio(text, voice="tom"):
    audio = tts.tts(text, voice=voice, preset="fast")
    output_file = "output.wav"
    torchaudio.save(output_file, audio.squeeze(0).cpu(), 24000)
    return output_file

iface = gr.Interface(
    fn=generate_audio,
    inputs=[
        gr.Textbox(label="Enter your text"),
        gr.Dropdown(["tom", "emma", "pat"], label="Voice", value="tom")
    ],
    outputs=gr.Audio(label="Generated Audio"),
    title="Tortoise TTS"
)

iface.launch()