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-large-v2" #
|
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, #
|
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 |
|