Spaces:
Running
Running
import streamlit as st | |
import torch | |
import outetts | |
from scipy.io.wavfile import write | |
# Initialize model configuration | |
model_config = outetts.HFModelConfig_v1( | |
model_path="OuteAI/OuteTTS-0.2-500M", | |
language="en" | |
) | |
# Load the model | |
model = outetts.load_model(model_config) | |
def generate_speech(text): | |
with torch.no_grad(): | |
audio, sample_rate = model.infer(text) | |
return audio, sample_rate | |
# Streamlit UI | |
st.title("OuteTTS Speech Synthesis") | |
st.write("Enter text below to generate speech.") | |
text_input = st.text_area("Text to convert to speech:", "Hello, this is an AI-generated voice.") | |
if st.button("Generate Speech"): | |
with st.spinner("Generating audio..."): | |
audio, sample_rate = generate_speech(text_input) | |
output_path = "output.wav" | |
write(output_path, sample_rate, audio) | |
st.audio(output_path, format="audio/wav") | |
st.success("Speech generated successfully!") | |