Spaces:
Build error
Build error
Commit
·
e1e8cf6
1
Parent(s):
fade36a
Update app.py
Browse files
app.py
CHANGED
|
@@ -16,16 +16,51 @@ def process_audio_file(file):
|
|
| 16 |
|
| 17 |
def transcribe(target_language, file):
|
| 18 |
|
| 19 |
-
|
|
|
|
| 20 |
|
| 21 |
input_values = process_audio_file(file)
|
| 22 |
|
| 23 |
-
sequences = model.generate(input_values)
|
| 24 |
|
| 25 |
transcription = tokenizer.batch_decode(sequences, skip_special_tokens=True)
|
| 26 |
return transcription[0]
|
| 27 |
|
| 28 |
-
target_languages = [
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
|
| 30 |
iface = gr.Interface(
|
| 31 |
fn=transcribe,
|
|
|
|
| 16 |
|
| 17 |
def transcribe(target_language, file):
|
| 18 |
|
| 19 |
+
target_code = target_language.split("(")[-1].split(")")[0]
|
| 20 |
+
forced_bos_token_id = MAPPING[target_code]
|
| 21 |
|
| 22 |
input_values = process_audio_file(file)
|
| 23 |
|
| 24 |
+
sequences = model.generate(input_values, forced_bos_token_id=forced_bos_token_id)
|
| 25 |
|
| 26 |
transcription = tokenizer.batch_decode(sequences, skip_special_tokens=True)
|
| 27 |
return transcription[0]
|
| 28 |
|
| 29 |
+
target_languages = [
|
| 30 |
+
"German (de)",
|
| 31 |
+
"Turkish (tr)",
|
| 32 |
+
"Persian (fa)",
|
| 33 |
+
"Swedish (sv)",
|
| 34 |
+
"Mongolian (mn)",
|
| 35 |
+
"Chinese (zh)",
|
| 36 |
+
"Welsh (cy)",
|
| 37 |
+
"Catalan (ca)",
|
| 38 |
+
"Slovenian (sl)",
|
| 39 |
+
"Estonian (et)",
|
| 40 |
+
"Indonesian (id)",
|
| 41 |
+
"Arabic (ar)",
|
| 42 |
+
"Tamil (ta)",
|
| 43 |
+
"Latvian (lv)",
|
| 44 |
+
"Japanese (ja)",
|
| 45 |
+
]
|
| 46 |
+
|
| 47 |
+
MAPPING = {
|
| 48 |
+
"de": 250003,
|
| 49 |
+
"tr": 250023,
|
| 50 |
+
"fa": 250029,
|
| 51 |
+
"sv": 250042,
|
| 52 |
+
"mn": 250037,
|
| 53 |
+
"zh": 250025,
|
| 54 |
+
"cy": 250007,
|
| 55 |
+
"ca": 250005,
|
| 56 |
+
"sl": 250052,
|
| 57 |
+
"et": 250006,
|
| 58 |
+
"id": 250032,
|
| 59 |
+
"ar": 250001,
|
| 60 |
+
"ta": 250044,
|
| 61 |
+
"lv": 250017,
|
| 62 |
+
"ja": 250012,
|
| 63 |
+
}
|
| 64 |
|
| 65 |
iface = gr.Interface(
|
| 66 |
fn=transcribe,
|