From cb53661070cab184ff2182e6498e715709e1a61e Mon Sep 17 00:00:00 2001 From: aramlang <100400031+aramlang@users.noreply.github.com> Date: Wed, 3 May 2023 11:26:12 -0500 Subject: [PATCH] Enable Hebrew support --- whisperx/alignment.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/whisperx/alignment.py b/whisperx/alignment.py index 38c2f007..2ae77f36 100644 --- a/whisperx/alignment.py +++ b/whisperx/alignment.py @@ -38,6 +38,7 @@ "fa": "jonatasgrosman/wav2vec2-large-xlsr-53-persian", "el": "jonatasgrosman/wav2vec2-large-xlsr-53-greek", "tr": "mpoyraz/wav2vec2-xls-r-300m-cv7-turkish", + "he": "imvladikon/wav2vec2-xls-r-300m-hebrew", } @@ -231,8 +232,13 @@ def align( emission = emissions[0].cpu().detach() - trellis = get_trellis(emission, tokens) - path = backtrack(trellis, emission, tokens) + blank_id = 0 + for char, code in model_dictionary.items(): + if char == '[pad]' or char == '': + blank_id = code + + trellis = get_trellis(emission, tokens, blank_id) + path = backtrack(trellis, emission, tokens, blank_id) if path is None: print(f'Failed to align segment ("{segment["text"]}"): backtrack failed, resorting to original...') break