Update asr.py
Browse files
asr.py
CHANGED
@@ -3,7 +3,6 @@ from transformers import Wav2Vec2ForCTC, AutoProcessor
|
|
3 |
import torch
|
4 |
|
5 |
ASR_SAMPLING_RATE = 16_000
|
6 |
-
|
7 |
MODEL_ID = "facebook/mms-1b-all"
|
8 |
|
9 |
processor = AutoProcessor.from_pretrained(MODEL_ID)
|
@@ -23,6 +22,10 @@ def transcribe(audio):
|
|
23 |
with torch.no_grad():
|
24 |
outputs = model(**inputs).logits
|
25 |
|
|
|
|
|
|
|
|
|
26 |
ids = torch.argmax(outputs, dim=-1)[0]
|
27 |
transcription = processor.decode(ids)
|
28 |
|
|
|
3 |
import torch
|
4 |
|
5 |
ASR_SAMPLING_RATE = 16_000
|
|
|
6 |
MODEL_ID = "facebook/mms-1b-all"
|
7 |
|
8 |
processor = AutoProcessor.from_pretrained(MODEL_ID)
|
|
|
22 |
with torch.no_grad():
|
23 |
outputs = model(**inputs).logits
|
24 |
|
25 |
+
# Setting the target language to Faroese (ISO 639-3: fao)
|
26 |
+
processor.tokenizer.set_target_lang("fao")
|
27 |
+
model.load_adapter("fao")
|
28 |
+
|
29 |
ids = torch.argmax(outputs, dim=-1)[0]
|
30 |
transcription = processor.decode(ids)
|
31 |
|