TTS / app.py
ygutierrez's picture
Update app.py
ffc1b0d verified
raw
history blame contribute delete
839 Bytes
import os
# Instalar dependencias
os.system("pip install TTS torchaudio")
import streamlit as st
import torchaudio
from TTS.api import TTS
# Cargar el modelo Coqui XTTS v2.0.3
tts = TTS("tts_models/multilingual/multi-dataset/xtts_v2", gpu=False)
def text_to_speech(text):
output_path = "output.wav"
tts.tts_to_file(text=text, file_path=output_path)
return output_path
# Interfaz con Streamlit
st.title("Conversión de Texto a Voz con Coqui XTTS v2.0.3")
st.write("Ingrese un texto y escuche el audio generado utilizando el modelo XTTS v2.0.3 de Coqui.")
text = st.text_area("Ingrese el texto")
if st.button("Generar Audio"):
if text:
output_audio = text_to_speech(text)
st.audio(output_audio, format="audio/wav")
else:
st.warning("Por favor, ingrese un texto antes de generar el audio.")