Spaces:
Running
Running
import gradio as gr | |
from outetts.v0_1.interface import InterfaceHF | |
# Initialize the TTS model interface | |
interface = InterfaceHF("OuteAI/OuteTTS-0.1-350M") | |
# Define a function to generate and save TTS output from input text | |
def generate_tts(text, temperature=0.1, repetition_penalty=1.1, max_length=4096): | |
output = interface.generate( | |
text=text, | |
temperature=temperature, | |
repetition_penalty=repetition_penalty, | |
max_lenght=max_length | |
) | |
# Save the output audio to a file | |
output.save("output.wav") | |
return "output.wav" | |
# Gradio interface for TTS | |
demo = gr.Interface( | |
fn=generate_tts, | |
inputs=[ | |
gr.Textbox(lines=2, placeholder="Enter text to convert to speech", label="Text"), | |
gr.Slider(0.1, 1.0, value=0.1, label="Temperature"), | |
gr.Slider(1.0, 2.0, value=1.1, label="Repetition Penalty"), | |
gr.Slider(512, 4096, value=4096, step=256, label="Max Length") | |
], | |
outputs=gr.Audio(type="file", label="Generated Speech"), | |
title="OuteTTS Text-to-Speech Demo", | |
description="Convert text to speech using the OuteTTS model." | |
) | |
# Launch the Gradio app | |
demo.launch() | |