sreelekhaputta2 commited on
Commit
302c577
·
verified ·
1 Parent(s): df6393c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -9
app.py CHANGED
@@ -70,7 +70,7 @@ def versewise_bot(question, play_music):
70
  "🌼 Stay strong — Krishna walks with you."
71
  )
72
 
73
- # Background music handling
74
  music_path = None
75
  if play_music and os.path.exists(bg_music_path):
76
  unique_bgm_path = os.path.join(TEMP_DIR, f"bgm_{uuid.uuid4()}.mp3")
@@ -78,11 +78,11 @@ def versewise_bot(question, play_music):
78
  shutil.copy(bg_music_path, unique_bgm_path)
79
  music_path = unique_bgm_path
80
  except Exception as e:
81
- print(f"BGM Error: {e}")
82
 
83
- # Create downloadable text file
84
  download_file = create_downloadable_text(question, verse_number, sanskrit, translation, explanation)
85
 
 
86
  return reply, None, music_path, download_file
87
 
88
  def get_quote_of_the_day():
@@ -90,10 +90,10 @@ def get_quote_of_the_day():
90
  sanskrit = verse['verse_in_sanskrit']
91
  translation = verse['translation_in_english']
92
  verse_number = verse['verse_number']
93
- return (f'''<div style="font-size:1.1em;padding:10px 0;">
94
- <b>Quote of the Day (Gita {verse_number}):</b><br>
95
- <i>[translate:{sanskrit[:60]}...]</i><br>
96
- <span style="color:#2d2d2d;">"{translation}"</span></div>''')
97
 
98
  custom_css = """
99
  body, .gradio-container, .gradio-interface, html {
@@ -130,7 +130,7 @@ interface = gr.Interface(
130
  ],
131
  outputs=[
132
  gr.Textbox(label="🧘‍♂ Krishna's Answer"),
133
- gr.Audio(label="🔊 Krishna’s Voice", type="filepath"), # Always None since TTS removed
134
  gr.Audio(label="🎶 Background Music", autoplay=True, type="filepath"),
135
  gr.DownloadButton(label="Download Response with Assurance")
136
  ],
@@ -143,5 +143,5 @@ interface = gr.Interface(
143
  )
144
 
145
  if __name__ == "__main__":
146
- print(f"Temp directory for audio files: {TEMP_DIR}")
147
  interface.launch()
 
70
  "🌼 Stay strong — Krishna walks with you."
71
  )
72
 
73
+ # Play background music only if toggled and file exists
74
  music_path = None
75
  if play_music and os.path.exists(bg_music_path):
76
  unique_bgm_path = os.path.join(TEMP_DIR, f"bgm_{uuid.uuid4()}.mp3")
 
78
  shutil.copy(bg_music_path, unique_bgm_path)
79
  music_path = unique_bgm_path
80
  except Exception as e:
81
+ print(f"BGM copy error: {e}")
82
 
 
83
  download_file = create_downloadable_text(question, verse_number, sanskrit, translation, explanation)
84
 
85
+ # No Krishna voice, so audio output set to None
86
  return reply, None, music_path, download_file
87
 
88
  def get_quote_of_the_day():
 
90
  sanskrit = verse['verse_in_sanskrit']
91
  translation = verse['translation_in_english']
92
  verse_number = verse['verse_number']
93
+ return f"""<div style="font-size:1.1em;padding:10px 0;">
94
+ <b>Quote of the Day (Gita {verse_number}):</b><br>
95
+ <i>[translate:{sanskrit[:60]}...]</i><br>
96
+ <span style="color:#2d2d2d;">"{translation}"</span></div>"""
97
 
98
  custom_css = """
99
  body, .gradio-container, .gradio-interface, html {
 
130
  ],
131
  outputs=[
132
  gr.Textbox(label="🧘‍♂ Krishna's Answer"),
133
+ gr.Audio(label="🔊 Krishna’s Voice", visible=False, type="filepath"),
134
  gr.Audio(label="🎶 Background Music", autoplay=True, type="filepath"),
135
  gr.DownloadButton(label="Download Response with Assurance")
136
  ],
 
143
  )
144
 
145
  if __name__ == "__main__":
146
+ print(f"Temp directory for audio and downloads: {TEMP_DIR}")
147
  interface.launch()