Spaces:
Running
Running
File size: 1,853 Bytes
52937bd |
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 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# app.py
import streamlit as st
import tempfile
from utils import VoiceCloner
def main():
st.title("Clonaci贸n de Voz en Espa帽ol")
st.write("""
Esta aplicaci贸n de ejemplo utiliza **Coqui TTS** (YourTTS) para
realizar clonaci贸n de voz en espa帽ol mediante zero-shot.
""")
# Creamos una instancia del clonador de voz
voice_cloner = VoiceCloner()
# Entrada de texto
text_input = st.text_area("Ingresa el texto a reproducir:", "")
# Carga de archivo de audio (WAV o MP3)
uploaded_audio = st.file_uploader("Sube una nota de voz o audio de referencia", type=["wav", "mp3"])
# Bot贸n para generar la voz clonada
if st.button("Generar voz clonada"):
# Validaciones b谩sicas
if not text_input:
st.warning("Por favor, ingresa un texto.")
elif not uploaded_audio:
st.warning("Por favor, sube un archivo de audio de referencia.")
else:
# Guardamos temporalmente el audio subido
with tempfile.NamedTemporaryFile(delete=False, suffix=".wav") as tmp:
tmp.write(uploaded_audio.read())
reference_audio_path = tmp.name
# Definimos un archivo de salida
output_path = "cloned_voice.wav"
# Llamamos a la funci贸n que clona la voz
result_audio_path = voice_cloner.clone_voice(
text=text_input,
reference_audio_path=reference_audio_path,
output_path=output_path
)
st.success("隆Voz clonada generada con 茅xito!")
# Leemos el audio generado y lo reproducimos
with open(result_audio_path, "rb") as audio_file:
audio_bytes = audio_file.read()
st.audio(audio_bytes, format="audio/wav")
if __name__ == "__main__":
main()
|