Spaces:
No application file
No application file
| import streamlit as st | |
| import requests | |
| import base64 | |
| API_URL = "https://api-inference.huggingface.co/models/espnet/kan-bayashi_ljspeech_vits" | |
| HF_TOKEN = "TU_TOKEN_DE_HUGGINGFACE" # pon tu token aquí | |
| headers = {"Authorization": f"Bearer {HF_TOKEN}"} | |
| def text_to_speech(text): | |
| payload = {"inputs": text} | |
| response = requests.post(API_URL, headers=headers, json=payload) | |
| return response.content | |
| st.title("Texto a Voz Accesible") | |
| st.write("Aplicación para personas con discapacidades visuales o cognitivas.") | |
| texto = st.text_area("Escribe el texto que quieres convertir a audio") | |
| if st.button("Generar Audio"): | |
| if texto.strip() == "": | |
| st.warning("Introduce texto para convertir.") | |
| else: | |
| audio_bytes = text_to_speech(texto) | |
| # Mostrar audio en la web | |
| st.audio(audio_bytes, format="audio/wav") | |
| # Botón de descarga | |
| st.download_button( | |
| label="Descargar audio", | |
| data=audio_bytes, | |
| file_name="voz_generada.wav", | |
| mime="audio/wav", | |
| ) | |