legusxyz commited on
Commit
045b9e5
·
verified ·
1 Parent(s): d520218

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -14,7 +14,7 @@ app = FastAPI()
14
  device = 0 if torch.cuda.is_available() else -1
15
 
16
  # Load Whisper model and processor
17
- model_name = "openai/whisper-large-v2" # You can change to other variants like "openai/whisper-small"
18
  model = WhisperForConditionalGeneration.from_pretrained(model_name)
19
  processor = WhisperProcessor.from_pretrained(model_name)
20
 
@@ -27,8 +27,9 @@ asr_pipeline = pipeline(
27
  "automatic-speech-recognition",
28
  model=model,
29
  tokenizer=processor.tokenizer, # Explicitly set the tokenizer from the processor
30
- feature_extractor=processor.feature_extractor, # Also set the feature extractor
31
- device=device
 
32
  )
33
 
34
 
 
14
  device = 0 if torch.cuda.is_available() else -1
15
 
16
  # Load Whisper model and processor
17
+ model_name = "openai/whisper-large-v2" # Use the model of your choice, e.g., whisper-small or whisper-large
18
  model = WhisperForConditionalGeneration.from_pretrained(model_name)
19
  processor = WhisperProcessor.from_pretrained(model_name)
20
 
 
27
  "automatic-speech-recognition",
28
  model=model,
29
  tokenizer=processor.tokenizer, # Explicitly set the tokenizer from the processor
30
+ feature_extractor=processor.feature_extractor, # Set the feature extractor for audio input
31
+ device=device,
32
+ language="portuguese" # Add language explicitly in the pipeline to force Portuguese
33
  )
34
 
35