Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -15,7 +15,9 @@ processor = AutoProcessor.from_pretrained(model_id)
|
|
15 |
model = Wav2Vec2ForCTC.from_pretrained(model_id)
|
16 |
model = BetterTransformer.transform(model)
|
17 |
|
18 |
-
|
|
|
|
|
19 |
if audio_file_mic:
|
20 |
audio_file = audio_file_mic
|
21 |
elif audio_file_upload:
|
@@ -28,11 +30,6 @@ def transcribe(audio_file_mic=None, audio_file_upload=None, language="English (e
|
|
28 |
if sample_rate != 16000:
|
29 |
speech = librosa.resample(speech, orig_sr=sample_rate, target_sr=16000)
|
30 |
|
31 |
-
# Keep the same model in memory and simply switch out the language adapters by calling load_adapter() for the model and set_target_lang() for the tokenizer
|
32 |
-
language_code = iso_codes[language]
|
33 |
-
processor.tokenizer.set_target_lang(language_code)
|
34 |
-
pipe = pipeline("automatic-speech-recognition", model=model)
|
35 |
-
|
36 |
return pipe(audio_file)["text"]
|
37 |
|
38 |
|
|
|
15 |
model = Wav2Vec2ForCTC.from_pretrained(model_id)
|
16 |
model = BetterTransformer.transform(model)
|
17 |
|
18 |
+
pipe = pipeline("automatic-speech-recognition", model=model)
|
19 |
+
|
20 |
+
def transcribe(audio_file_mic=None, audio_file_upload=None):
|
21 |
if audio_file_mic:
|
22 |
audio_file = audio_file_mic
|
23 |
elif audio_file_upload:
|
|
|
30 |
if sample_rate != 16000:
|
31 |
speech = librosa.resample(speech, orig_sr=sample_rate, target_sr=16000)
|
32 |
|
|
|
|
|
|
|
|
|
|
|
33 |
return pipe(audio_file)["text"]
|
34 |
|
35 |
|