riteshkr commited on
Commit
09b9573
1 Parent(s): 912008d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -2
app.py CHANGED
@@ -5,7 +5,7 @@ from transformers import pipeline, WhisperForConditionalGeneration, WhisperProce
5
  # Check if a GPU is available and set the device
6
  device = 0 if torch.cuda.is_available() else -1
7
 
8
- # Load the ASR model using the Hugging Face pipeline
9
  model_id = "riteshkr/quantized-whisper-large-v3"
10
  model = WhisperForConditionalGeneration.from_pretrained(model_id)
11
  processor = WhisperProcessor.from_pretrained(model_id)
@@ -13,7 +13,14 @@ processor = WhisperProcessor.from_pretrained(model_id)
13
  # Set the language to English using forced_decoder_ids
14
  forced_decoder_ids = processor.get_decoder_prompt_ids(language="english", task="transcribe")
15
 
16
- pipe = pipeline("automatic-speech-recognition", model=model, processor=processor, device=device)
 
 
 
 
 
 
 
17
 
18
  # Define the transcription function
19
  def transcribe_speech(filepath):
 
5
  # Check if a GPU is available and set the device
6
  device = 0 if torch.cuda.is_available() else -1
7
 
8
+ # Load the ASR model and processor
9
  model_id = "riteshkr/quantized-whisper-large-v3"
10
  model = WhisperForConditionalGeneration.from_pretrained(model_id)
11
  processor = WhisperProcessor.from_pretrained(model_id)
 
13
  # Set the language to English using forced_decoder_ids
14
  forced_decoder_ids = processor.get_decoder_prompt_ids(language="english", task="transcribe")
15
 
16
+ # Create the pipeline, explicitly setting the tokenizer and feature extractor
17
+ pipe = pipeline(
18
+ "automatic-speech-recognition",
19
+ model=model,
20
+ tokenizer=processor.tokenizer, # Use the processor's tokenizer
21
+ feature_extractor=processor.feature_extractor, # Use the processor's feature extractor
22
+ device=device
23
+ )
24
 
25
  # Define the transcription function
26
  def transcribe_speech(filepath):