Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -413,41 +413,38 @@ def main():
|
|
| 413 |
)
|
| 414 |
|
| 415 |
with col2:
|
| 416 |
-
|
| 417 |
-
|
| 418 |
-
|
| 419 |
-
|
| 420 |
-
|
| 421 |
-
|
| 422 |
-
|
| 423 |
-
|
| 424 |
-
|
| 425 |
-
|
| 426 |
-
|
| 427 |
-
|
| 428 |
-
|
| 429 |
-
|
| 430 |
-
# Add caption and hashtags
|
| 431 |
-
st.subheader("π Caption")
|
| 432 |
-
hashtags = generate_hashtags(
|
| 433 |
-
quote_data['tradition'],
|
| 434 |
-
quote_data.get('theme', 'Wisdom')
|
| 435 |
-
)
|
| 436 |
-
caption = f"""β¨ Wisdom from {quote_data['tradition']} β¨
|
| 437 |
|
| 438 |
-
|
| 439 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 440 |
|
| 441 |
-
|
| 442 |
-
|
| 443 |
|
| 444 |
-
|
| 445 |
-
|
| 446 |
-
|
| 447 |
-
|
| 448 |
-
|
| 449 |
-
|
| 450 |
-
|
| 451 |
|
| 452 |
with tab3:
|
| 453 |
display_debug_logs()
|
|
|
|
| 413 |
)
|
| 414 |
|
| 415 |
with col2:
|
| 416 |
+
# Audio preview
|
| 417 |
+
st.subheader("π΅ Background Music")
|
| 418 |
+
if st.session_state.generated_audio:
|
| 419 |
+
try:
|
| 420 |
+
audio_response = requests.get(st.session_state.generated_audio)
|
| 421 |
+
if audio_response.status_code == 200:
|
| 422 |
+
st.audio(audio_response.content, format='audio/mp3')
|
| 423 |
+
st.download_button(
|
| 424 |
+
"π₯ Download Audio",
|
| 425 |
+
data=audio_response.content,
|
| 426 |
+
file_name="background_music.mp3",
|
| 427 |
+
mime="audio/mp3"
|
| 428 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 429 |
|
| 430 |
+
# Add caption and hashtags (This block should be outside the 'if audio_response.status_code == 200:')
|
| 431 |
+
st.subheader("π Caption")
|
| 432 |
+
hashtags = generate_hashtags(
|
| 433 |
+
quote_data['tradition'],
|
| 434 |
+
quote_data.get('theme', 'Wisdom')
|
| 435 |
+
)
|
| 436 |
+
caption = f"""β¨ Wisdom from {quote_data['tradition']} β¨
|
| 437 |
|
| 438 |
+
"{quote_data['text']}"
|
| 439 |
+
- {quote_data['author']}
|
| 440 |
|
| 441 |
+
{' '.join(hashtags)}"""
|
| 442 |
+
st.text_area("Instagram Caption", caption, height=200)
|
| 443 |
+
|
| 444 |
+
except Exception as e: # 'except' block to handle exceptions
|
| 445 |
+
st.error(f"Error playing audio: {str(e)}")
|
| 446 |
+
else:
|
| 447 |
+
st.info("No audio generated yet.") # Informative message if no audio
|
| 448 |
|
| 449 |
with tab3:
|
| 450 |
display_debug_logs()
|