Sking / src /streamlit_app.py
Foxosy's picture
Update src/streamlit_app.py
ffa782c verified
import streamlit as st
import requests
st.title("🎀 Text-to-Speech (Hugging Face API)")
message = st.text_area("Enter Message", "Happy Birthday! Wishing you a joyful day filled with love and laughter.")
emotion = st.text_input("Emotion", "happy")
voice = st.text_input("Voice", "coral")
if st.button("Generate Audio"):
with st.spinner("Generating audio from Hugging Face..."):
# Replace with the actual API endpoint
API_URL = "https://nihalgazi-text-to-speech-unlimited.hf.space/run/predict"
# Gradio-style input
payload = {
"data": [message, emotion, voice]
}
try:
response = requests.post(API_URL, json=payload).json()
audio_url = response["data"][0] # assuming this contains a URL or base64 audio
if audio_url.startswith("http"):
st.audio(audio_url)
st.success("βœ… Audio generated!")
st.markdown(f"[πŸ”— Download Audio]({audio_url})", unsafe_allow_html=True)
else:
st.error("Unexpected audio format returned.")
except Exception as e:
st.error(f"Error: {e}")