Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,13 +3,18 @@ import torch
|
|
| 3 |
import outetts
|
| 4 |
from scipy.io.wavfile import write
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
with torch.no_grad():
|
| 11 |
audio, sample_rate = model.infer(text)
|
| 12 |
-
|
| 13 |
return audio, sample_rate
|
| 14 |
|
| 15 |
# Streamlit UI
|
|
@@ -20,13 +25,9 @@ text_input = st.text_area("Text to convert to speech:", "Hello, this is an AI-ge
|
|
| 20 |
|
| 21 |
if st.button("Generate Speech"):
|
| 22 |
with st.spinner("Generating audio..."):
|
| 23 |
-
|
| 24 |
-
model_path="OuteAI/OuteTTS-0.2-500M",
|
| 25 |
-
language="en"
|
| 26 |
-
)
|
| 27 |
-
audio, sample_rate = generate_speech(text_input, model_config)
|
| 28 |
output_path = "output.wav"
|
| 29 |
write(output_path, sample_rate, audio)
|
| 30 |
-
|
| 31 |
st.audio(output_path, format="audio/wav")
|
| 32 |
st.success("Speech generated successfully!")
|
|
|
|
| 3 |
import outetts
|
| 4 |
from scipy.io.wavfile import write
|
| 5 |
|
| 6 |
+
# Initialize model configuration
|
| 7 |
+
model_config = outetts.HFModelConfig_v1(
|
| 8 |
+
model_path="OuteAI/OuteTTS-0.2-500M",
|
| 9 |
+
language="en"
|
| 10 |
+
)
|
| 11 |
+
|
| 12 |
+
# Load the model
|
| 13 |
+
model = outetts.load_model(model_config)
|
| 14 |
+
|
| 15 |
+
def generate_speech(text):
|
| 16 |
with torch.no_grad():
|
| 17 |
audio, sample_rate = model.infer(text)
|
|
|
|
| 18 |
return audio, sample_rate
|
| 19 |
|
| 20 |
# Streamlit UI
|
|
|
|
| 25 |
|
| 26 |
if st.button("Generate Speech"):
|
| 27 |
with st.spinner("Generating audio..."):
|
| 28 |
+
audio, sample_rate = generate_speech(text_input)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
output_path = "output.wav"
|
| 30 |
write(output_path, sample_rate, audio)
|
| 31 |
+
|
| 32 |
st.audio(output_path, format="audio/wav")
|
| 33 |
st.success("Speech generated successfully!")
|