Chan-Y commited on
Commit
234c504
1 Parent(s): d5521a2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -11
app.py CHANGED
@@ -89,7 +89,7 @@ def process_audio(audio_path):
89
  def handle_audio_input(audio_path=None, youtube_url=None):
90
  if youtube_url:
91
  audio_path = download_youtube_to_mp3(youtube_url, output_dir="downloads", filename="youtube_audio")
92
-
93
  if audio_path:
94
  return process_audio(audio_path)
95
  else:
@@ -112,16 +112,20 @@ def create_gradio_interface():
112
  submit_btn.click(fn=on_text_submit, inputs=text_input, outputs=[lang_output, output_text, time_taken])
113
 
114
  with gr.Tab("Audio Input"):
115
- audio_input = gr.Audio(label="Upload Audio", type="filepath")
116
- youtube_input = gr.Textbox(label="YT URL (optional)")
117
- audio_output = gr.Textbox(label="Detected Topics from Audio")
118
- audio_submit_btn = gr.Button("Process Audio")
119
-
120
- def on_audio_submit(audio, youtube_url):
121
- return handle_audio_input(audio_path=audio, youtube_url=youtube_url)
122
-
123
- audio_submit_btn.click(fn=on_audio_submit, inputs=[audio_input, youtube_input], outputs=audio_output)
124
-
 
 
 
 
125
  iface.launch()
126
 
127
  if __name__ == "__main__":
 
89
  def handle_audio_input(audio_path=None, youtube_url=None):
90
  if youtube_url:
91
  audio_path = download_youtube_to_mp3(youtube_url, output_dir="downloads", filename="youtube_audio")
92
+ return process_audio(audio_path)
93
  if audio_path:
94
  return process_audio(audio_path)
95
  else:
 
112
  submit_btn.click(fn=on_text_submit, inputs=text_input, outputs=[lang_output, output_text, time_taken])
113
 
114
  with gr.Tab("Audio Input"):
115
+ audio_input = gr.Audio(label="Upload Audio", type="filepath")
116
+ youtube_input = gr.Textbox(label="YouTube URL")
117
+ audio_output = gr.Textbox(label="Detected Topics from Audio")
118
+ audio_submit_btn = gr.Button("Process Audio")
119
+
120
+ def on_audio_submit(audio, youtube_url):
121
+ if youtube_url:
122
+ return handle_audio_input(youtube_url=youtube_url)
123
+ elif audio:
124
+ return handle_audio_input(audio_path=audio)
125
+ else:
126
+ return "Please provide either an audio file or a YouTube URL."
127
+
128
+ audio_submit_btn.click(fn=on_audio_submit, inputs=[audio_input, youtube_input], outputs=audio_output)
129
  iface.launch()
130
 
131
  if __name__ == "__main__":