Update app.py
Browse files
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-
|
18 |
model = WhisperForConditionalGeneration.from_pretrained(model_name)
|
19 |
processor = WhisperProcessor.from_pretrained(model_name)
|
20 |
|
@@ -22,11 +22,12 @@ processor = WhisperProcessor.from_pretrained(model_name)
|
|
22 |
forced_decoder_ids = processor.get_decoder_prompt_ids(language="portuguese", task="transcribe")
|
23 |
model.config.forced_decoder_ids = forced_decoder_ids
|
24 |
|
25 |
-
# Initialize the ASR pipeline with the modified model
|
26 |
asr_pipeline = pipeline(
|
27 |
"automatic-speech-recognition",
|
28 |
model=model,
|
29 |
-
|
|
|
30 |
device=device
|
31 |
)
|
32 |
|
|
|
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 |
|
|
|
22 |
forced_decoder_ids = processor.get_decoder_prompt_ids(language="portuguese", task="transcribe")
|
23 |
model.config.forced_decoder_ids = forced_decoder_ids
|
24 |
|
25 |
+
# Initialize the ASR pipeline with the modified model and processor
|
26 |
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 |
|