Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -59,6 +59,15 @@ LANGUANGE_MAP = {
|
|
| 59 |
}
|
| 60 |
|
| 61 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
|
| 63 |
|
| 64 |
|
|
@@ -83,16 +92,7 @@ def process_audio_file(file):
|
|
| 83 |
return audio
|
| 84 |
|
| 85 |
def transcribe(Microphone, File_Upload):
|
| 86 |
-
processor = WhisperProcessor.from_pretrained(model_id)
|
| 87 |
-
model = WhisperForConditionalGeneration.from_pretrained(model_id)
|
| 88 |
-
model.eval()
|
| 89 |
-
model.to(device)
|
| 90 |
-
|
| 91 |
-
sampling_rate = processor.feature_extractor.sampling_rate
|
| 92 |
|
| 93 |
-
bos_token_id = processor.tokenizer.all_special_ids[-106]
|
| 94 |
-
decoder_input_ids = torch.tensor([bos_token_id]).to(device)
|
| 95 |
-
|
| 96 |
warn_output = ""
|
| 97 |
if (Microphone is not None) and (File_Upload is not None):
|
| 98 |
warn_output = "WARNING: You've uploaded an audio file and used the microphone. " \
|
|
|
|
| 59 |
}
|
| 60 |
|
| 61 |
|
| 62 |
+
processor = WhisperProcessor.from_pretrained(model_id)
|
| 63 |
+
model = WhisperForConditionalGeneration.from_pretrained(model_id)
|
| 64 |
+
model.eval()
|
| 65 |
+
model.to(device)
|
| 66 |
+
|
| 67 |
+
sampling_rate = processor.feature_extractor.sampling_rate
|
| 68 |
+
|
| 69 |
+
bos_token_id = processor.tokenizer.all_special_ids[-106]
|
| 70 |
+
decoder_input_ids = torch.tensor([bos_token_id]).to(device)
|
| 71 |
|
| 72 |
|
| 73 |
|
|
|
|
| 92 |
return audio
|
| 93 |
|
| 94 |
def transcribe(Microphone, File_Upload):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 95 |
|
|
|
|
|
|
|
|
|
|
| 96 |
warn_output = ""
|
| 97 |
if (Microphone is not None) and (File_Upload is not None):
|
| 98 |
warn_output = "WARNING: You've uploaded an audio file and used the microphone. " \
|