Ubuntu commited on
Commit
75f8860
β€’
1 Parent(s): e7a545f

support timestamp toggle

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -69,7 +69,7 @@ def download_youtube_audio(youtube_url: str, output_dir: Optional[str] = None) -
69
  print("Error:", response.status_code, response.text)
70
  return None # Return None on failure
71
 
72
- def run_asr(audio_file, youtube_url):
73
  temp_file = None
74
  try:
75
  if youtube_url:
@@ -80,7 +80,7 @@ def run_asr(audio_file, youtube_url):
80
  return "Please provide either an audio file or a YouTube URL."
81
 
82
  files = {'file': open(audio_file, 'rb')}
83
- data = {'language': 'en', 'model_name': 'whisper-large-v2-imda'}
84
  response = requests.post(f"{API_URL}/asr", data=data, files=files)
85
 
86
  if response.status_code == 200:
@@ -119,6 +119,7 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
119
  audio_input = gr.Audio(sources=['microphone', 'upload'], type="filepath", label="Audio Input")
120
  youtube_input = gr.Textbox(label="YouTube URL", placeholder="Or paste a YouTube URL here...")
121
  video_player = gr.HTML(visible=False)
 
122
  with gr.Column(scale=3):
123
  result = gr.Textbox(
124
  label="Transcription Result",
@@ -127,7 +128,7 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
127
  )
128
 
129
  run_button = gr.Button("πŸš€ Transcribe Audio", variant="primary")
130
- run_button.click(run_asr, inputs=[audio_input, youtube_input], outputs=[result])
131
 
132
  # Update video player and clear transcription and audio input when YouTube URL is entered
133
  youtube_input.change(
@@ -151,4 +152,4 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
151
  gr.Markdown("5. Wait for a few seconds, and your transcription will appear in the result box.")
152
 
153
  # Launch the Gradio interface
154
- demo.launch()
 
69
  print("Error:", response.status_code, response.text)
70
  return None # Return None on failure
71
 
72
+ def run_asr(audio_file, youtube_url, with_timestamp):
73
  temp_file = None
74
  try:
75
  if youtube_url:
 
80
  return "Please provide either an audio file or a YouTube URL."
81
 
82
  files = {'file': open(audio_file, 'rb')}
83
+ data = {'language': 'en', 'model_name': 'whisper-large-v2-imda', 'with_timestamp': with_timestamp}
84
  response = requests.post(f"{API_URL}/asr", data=data, files=files)
85
 
86
  if response.status_code == 200:
 
119
  audio_input = gr.Audio(sources=['microphone', 'upload'], type="filepath", label="Audio Input")
120
  youtube_input = gr.Textbox(label="YouTube URL", placeholder="Or paste a YouTube URL here...")
121
  video_player = gr.HTML(visible=False)
122
+ timestamp_toggle = gr.Checkbox(label="Include Timestamps", value=False)
123
  with gr.Column(scale=3):
124
  result = gr.Textbox(
125
  label="Transcription Result",
 
128
  )
129
 
130
  run_button = gr.Button("πŸš€ Transcribe Audio", variant="primary")
131
+ run_button.click(run_asr, inputs=[audio_input, youtube_input, timestamp_toggle], outputs=[result])
132
 
133
  # Update video player and clear transcription and audio input when YouTube URL is entered
134
  youtube_input.change(
 
152
  gr.Markdown("5. Wait for a few seconds, and your transcription will appear in the result box.")
153
 
154
  # Launch the Gradio interface
155
+ demo.launch(server_name='0.0.0.0')