Spaces:
Sleeping
Sleeping
ogeti siva satyanarayana
commited on
Commit
·
473ecbf
1
Parent(s):
59e5f86
Update streamlit_ui.py
Browse filesobserved ❌ Failed: Not Found when clicking “Generate Audio” in Streamlit app
it is due to a mismatch between what the frontend expects and what your backend returns.
so fixed this
- streamlit_ui.py +8 -1
streamlit_ui.py
CHANGED
|
@@ -40,10 +40,17 @@ if tab == "Text to Audio":
|
|
| 40 |
with st.spinner("Generating audio..."):
|
| 41 |
r = requests.post(f"{API_BASE}/audio/generate", json={"text": text, "voice": voice}, headers=HEADERS)
|
| 42 |
if r.status_code == 200:
|
| 43 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
else:
|
| 45 |
st.error(f"❌ Failed: {r.json().get('detail')}")
|
| 46 |
|
|
|
|
| 47 |
elif tab == "Text to Image":
|
| 48 |
st.subheader("🖼️ Text to Image")
|
| 49 |
prompt = st.text_area("Enter image prompt")
|
|
|
|
| 40 |
with st.spinner("Generating audio..."):
|
| 41 |
r = requests.post(f"{API_BASE}/audio/generate", json={"text": text, "voice": voice}, headers=HEADERS)
|
| 42 |
if r.status_code == 200:
|
| 43 |
+
data = r.json()
|
| 44 |
+
download_url = f"{API_BASE}{data['download_url']}"
|
| 45 |
+
audio_resp = requests.get(download_url, headers=HEADERS)
|
| 46 |
+
if audio_resp.status_code == 200:
|
| 47 |
+
render_media(audio_resp.content, "audio", "Generated Audio")
|
| 48 |
+
else:
|
| 49 |
+
st.error("❌ Failed to download audio file.")
|
| 50 |
else:
|
| 51 |
st.error(f"❌ Failed: {r.json().get('detail')}")
|
| 52 |
|
| 53 |
+
|
| 54 |
elif tab == "Text to Image":
|
| 55 |
st.subheader("🖼️ Text to Image")
|
| 56 |
prompt = st.text_area("Enter image prompt")
|