File size: 1,176 Bytes
2210519 ffa782c |
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 |
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}") |