Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -7,13 +7,14 @@ import json
|
|
7 |
with open('ISO_codes.json', 'r') as file:
|
8 |
iso_codes = json.load(file)
|
9 |
|
10 |
-
languages = list(iso_codes.keys())
|
11 |
|
12 |
-
model_id = "
|
|
|
13 |
processor = AutoProcessor.from_pretrained(model_id)
|
14 |
model = Wav2Vec2ForCTC.from_pretrained(model_id)
|
15 |
|
16 |
-
|
|
|
17 |
if audio_file_mic:
|
18 |
audio_file = audio_file_mic
|
19 |
elif audio_file_upload:
|
@@ -26,10 +27,10 @@ def transcribe(audio_file_mic=None, audio_file_upload=None, language="English (e
|
|
26 |
if sample_rate != 16000:
|
27 |
speech = librosa.resample(speech, orig_sr=sample_rate, target_sr=16000)
|
28 |
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
|
34 |
inputs = processor(speech, sampling_rate=16_000, return_tensors="pt")
|
35 |
|
|
|
7 |
with open('ISO_codes.json', 'r') as file:
|
8 |
iso_codes = json.load(file)
|
9 |
|
|
|
10 |
|
11 |
+
model_id = "TifinLab/mms-1b-berber"
|
12 |
+
|
13 |
processor = AutoProcessor.from_pretrained(model_id)
|
14 |
model = Wav2Vec2ForCTC.from_pretrained(model_id)
|
15 |
|
16 |
+
|
17 |
+
def transcribe(audio_file_mic=None, audio_file_upload=None):
|
18 |
if audio_file_mic:
|
19 |
audio_file = audio_file_mic
|
20 |
elif audio_file_upload:
|
|
|
27 |
if sample_rate != 16000:
|
28 |
speech = librosa.resample(speech, orig_sr=sample_rate, target_sr=16000)
|
29 |
|
30 |
+
|
31 |
+
processor.tokenizer.set_target_lang("ber")
|
32 |
+
model.load_adapter("ber")
|
33 |
+
|
34 |
|
35 |
inputs = processor(speech, sampling_rate=16_000, return_tensors="pt")
|
36 |
|