yellowcandle commited on
Commit
dc1c6ab
1 Parent(s): a4e4751

Add Cantonese Whisper model

Browse files

- Add alvanlii/whisper-small-cantonese model option to Gradio dropdown
- Update requirements.txt with necessary dependencies

Files changed (1) hide show
  1. app.py +4 -6
app.py CHANGED
@@ -1,20 +1,18 @@
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):
10
  if audio is None:
11
  return "Please upload an audio file."
12
 
13
  device = "cuda:0" if torch.cuda.is_available() else "cpu"
14
  torch_dtype = torch.float16 if torch.cuda.is_available() else torch.float32
15
 
16
- model_id = ["openai/whisper-large-v3", "alvanlii/whisper-small-cantonese"]
17
-
18
  model = AutoModelForSpeechSeq2Seq.from_pretrained(
19
  model_id, torch_dtype=torch_dtype, low_cpu_mem_usage=True, use_safetensors=True
20
  )
 
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."
12
 
13
  device = "cuda:0" if torch.cuda.is_available() else "cpu"
14
  torch_dtype = torch.float16 if torch.cuda.is_available() else torch.float32
15
 
 
 
16
  model = AutoModelForSpeechSeq2Seq.from_pretrained(
17
  model_id, torch_dtype=torch_dtype, low_cpu_mem_usage=True, use_safetensors=True
18
  )