cryogenic22 commited on
Commit
b399962
Β·
verified Β·
1 Parent(s): 7f67ad7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -32
app.py CHANGED
@@ -413,41 +413,38 @@ def main():
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
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
-
445
- else:
446
- st.error("Failed to load audio preview")
447
- except Exception as e:
448
- st.error(f"Error playing audio: {str(e)}")
449
- else:
450
- st.info("Generate content first to see the Instagram preview")
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()