yellowcandle commited on
Commit
130fe19
1 Parent(s): dc1c6ab

feat: Add support for multiple Whisper models

Browse files

This commit adds a dropdown to select between different Whisper models for transcription. It includes the following changes:

- Add a dropdown input to the Gradio interface to select the model
- Pass the selected model ID to the transcribe_audio function
- Load the selected model and processor in the transcribe_audio function
- Update the pipeline to use the loaded model and processor

This allows users to easily switch between different Whisper models (e.g. large-v2, small-cantonese) for transcription based on their needs.

Files changed (1) hide show
  1. app.py +2 -2
app.py CHANGED
@@ -1,11 +1,11 @@
1
- # import spaces
2
  import gradio as gr
3
  # Use a pipeline as a high-level helper
4
  import torch
5
  from transformers import AutoModelForSpeechSeq2Seq, AutoProcessor, pipeline
6
  # from datasets import load_dataset
7
 
8
- # @spaces.GPU(duration=120)
9
  def transcribe_audio(audio, model_id):
10
  if audio is None:
11
  return "Please upload an audio file."
 
1
+ import spaces
2
  import gradio as gr
3
  # Use a pipeline as a high-level helper
4
  import torch
5
  from transformers import AutoModelForSpeechSeq2Seq, AutoProcessor, pipeline
6
  # from datasets import load_dataset
7
 
8
+ @spaces.GPU(duration=120)
9
  def transcribe_audio(audio, model_id):
10
  if audio is None:
11
  return "Please upload an audio file."