File size: 979 Bytes
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
import streamlit as st
import torch
import outetts
from scipy.io.wavfile import write

def generate_speech(text, model_config):
    model = outetts.TTSModel(model_config)
    model.eval()
    
    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..."):
        model_config = outetts.HFModelConfig_v1(
            model_path="OuteAI/OuteTTS-0.2-500M",
            language="en"
        )
        audio, sample_rate = generate_speech(text_input, model_config)
        output_path = "output.wav"
        write(output_path, sample_rate, audio)
        
        st.audio(output_path, format="audio/wav")
        st.success("Speech generated successfully!")