Spaces:
Running
Running
File size: 934 Bytes
84b3aae dbe86d4 84b3aae dbe86d4 84b3aae dbe86d4 84b3aae |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
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!")
|