Download src/streamlit_app.py from Foxosy/Sking: direct link, hf CLI and curl.
- Browser
- Download file 1.18 kB
-
https://huggingface.co/spaces/Foxosy/Sking/resolve/main/src/streamlit_app.py
- Command line
-
hf download hf://spaces/Foxosy/Sking/src/streamlit_app.py
-
curl -L -o streamlit_app.py https://huggingface.co/spaces/Foxosy/Sking/resolve/main/src/streamlit_app.py
1.18 kB
| 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}") |