Nick088 commited on
Commit
6cbeb97
1 Parent(s): c77d490

censor org name + added distil whisper v3

Browse files
Files changed (1) hide show
  1. app.py +12 -1
app.py CHANGED
@@ -33,6 +33,7 @@ def handle_groq_error(e, model_name):
33
  elif isinstance(e, groq.RateLimitError):
34
  if isinstance(error_data, dict) and 'error' in error_data and 'message' in error_data['error']:
35
  error_message = error_data['error']['message']
 
36
  raise gr.Error(error_message)
37
  else:
38
  raise gr.Error(f"Error during Groq API call: {e}")
@@ -513,7 +514,7 @@ with gr.Blocks(theme=theme, css=css) as interface:
513
  link_input = gr.Textbox(label="Enter Video/Audio Link", visible=False)
514
 
515
  # Model and options
516
- model_choice_subtitles = gr.Dropdown(choices=["whisper-large-v3"], value="whisper-large-v3", label="Audio Speech Recogition (ASR) Model")
517
  transcribe_prompt_subtitles = gr.Textbox(label="Prompt (Optional)", info="Specify any context or spelling corrections.")
518
  with gr.Row():
519
  language_subtitles = gr.Dropdown(choices=[(lang, code) for lang, code in LANGUAGE_CODES.items()], value="en", label="Language")
@@ -561,6 +562,16 @@ with gr.Blocks(theme=theme, css=css) as interface:
561
  show_subtitle_settings.change(lambda show, include_video: gr.update(visible=show and include_video), inputs=[show_subtitle_settings, include_video_option], outputs=[show_subtitle_settings])
562
  # show custom font file selection
563
  font_selection.change(lambda font_selection: gr.update(visible=font_selection == "Custom Font File"), inputs=[font_selection], outputs=[font_file])
 
 
 
 
 
 
 
 
 
 
564
  # Modified generate subtitles event
565
  transcribe_button_subtitles.click(
566
  fn=generate_subtitles,
 
33
  elif isinstance(e, groq.RateLimitError):
34
  if isinstance(error_data, dict) and 'error' in error_data and 'message' in error_data['error']:
35
  error_message = error_data['error']['message']
36
+ error_message = re.sub(r'org_[a-zA-Z0-9]+', 'org_(censored)', error_message) # censor org
37
  raise gr.Error(error_message)
38
  else:
39
  raise gr.Error(f"Error during Groq API call: {e}")
 
514
  link_input = gr.Textbox(label="Enter Video/Audio Link", visible=False)
515
 
516
  # Model and options
517
+ model_choice_subtitles = gr.Dropdown(choices=["whisper-large-v3", "distil-whisper-large-v3-en"], value="whisper-large-v3", label="Audio Speech Recogition (ASR) Model")
518
  transcribe_prompt_subtitles = gr.Textbox(label="Prompt (Optional)", info="Specify any context or spelling corrections.")
519
  with gr.Row():
520
  language_subtitles = gr.Dropdown(choices=[(lang, code) for lang, code in LANGUAGE_CODES.items()], value="en", label="Language")
 
562
  show_subtitle_settings.change(lambda show, include_video: gr.update(visible=show and include_video), inputs=[show_subtitle_settings, include_video_option], outputs=[show_subtitle_settings])
563
  # show custom font file selection
564
  font_selection.change(lambda font_selection: gr.update(visible=font_selection == "Custom Font File"), inputs=[font_selection], outputs=[font_file])
565
+
566
+ # Update language dropdown based on model selection
567
+ def update_language_options(model):
568
+ if model == "distil-whisper-large-v3-en":
569
+ return gr.update(choices=[("English", "en")], value="en", interactive=False)
570
+ else:
571
+ return gr.update(choices=[(lang, code) for lang, code in LANGUAGE_CODES.items()], value="en", interactive=True)
572
+
573
+ model_choice_subtitles.change(fn=update_language_options, inputs=[model_choice_subtitles], outputs=[language_subtitles])
574
+
575
  # Modified generate subtitles event
576
  transcribe_button_subtitles.click(
577
  fn=generate_subtitles,