Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,21 +1,14 @@
|
|
1 |
import streamlit as st
|
2 |
-
import
|
3 |
-
from scipy.io.wavfile import write
|
4 |
import tempfile
|
5 |
import os
|
6 |
from pydub import AudioSegment
|
7 |
|
8 |
-
# Initialize model
|
9 |
-
|
10 |
-
model_path="OuteAI/OuteTTS-0.2-500M",
|
11 |
-
language="en" # Supported languages: en, zh, ja, ko
|
12 |
-
)
|
13 |
-
|
14 |
-
# Initialize the interface
|
15 |
-
interface = outetts.InterfaceHF(model_version="0.2", cfg=model_config)
|
16 |
|
17 |
# Streamlit UI
|
18 |
-
st.title("
|
19 |
st.write("Enter text below to generate speech.")
|
20 |
|
21 |
# Sidebar for reference voice
|
@@ -38,18 +31,17 @@ text_input = st.text_area("Text to convert to speech:", "Hello, this is an AI-ge
|
|
38 |
|
39 |
if st.button("Generate Speech"):
|
40 |
with st.spinner("Generating audio..."):
|
41 |
-
#
|
42 |
-
|
|
|
|
|
|
|
43 |
text=text_input,
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
)
|
48 |
|
49 |
-
# Save the synthesized speech to a file
|
50 |
-
output_path = "output.wav"
|
51 |
-
output.save(output_path)
|
52 |
-
|
53 |
# Play the audio in the Streamlit app
|
54 |
st.audio(output_path, format="audio/wav")
|
55 |
st.success("Speech generated successfully!")
|
|
|
1 |
import streamlit as st
|
2 |
+
from TTS.api import TTS
|
|
|
3 |
import tempfile
|
4 |
import os
|
5 |
from pydub import AudioSegment
|
6 |
|
7 |
+
# Initialize the TTS model
|
8 |
+
tts = TTS("tts_models/multilingual/multi-dataset/xtts_v2", gpu=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
|
10 |
# Streamlit UI
|
11 |
+
st.title("XTTS v2 Speech Synthesis")
|
12 |
st.write("Enter text below to generate speech.")
|
13 |
|
14 |
# Sidebar for reference voice
|
|
|
31 |
|
32 |
if st.button("Generate Speech"):
|
33 |
with st.spinner("Generating audio..."):
|
34 |
+
# Define output path
|
35 |
+
output_path = "output.wav"
|
36 |
+
|
37 |
+
# Generate speech using XTTS v2
|
38 |
+
tts.tts_to_file(
|
39 |
text=text_input,
|
40 |
+
file_path=output_path,
|
41 |
+
speaker_wav=ref_audio_path if ref_audio_path else None,
|
42 |
+
language="en"
|
43 |
)
|
44 |
|
|
|
|
|
|
|
|
|
45 |
# Play the audio in the Streamlit app
|
46 |
st.audio(output_path, format="audio/wav")
|
47 |
st.success("Speech generated successfully!")
|