From d51353a4b6461d5c440e86f394ee858a84c2d881 Mon Sep 17 00:00:00 2001 From: m-bain <36994049+m-bain@users.noreply.github.com> Date: Sun, 8 Jan 2023 18:02:36 +0000 Subject: [PATCH 1/4] uncomment .ass --- whisperx/transcribe.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/whisperx/transcribe.py b/whisperx/transcribe.py index 772143d..85bcda5 100644 --- a/whisperx/transcribe.py +++ b/whisperx/transcribe.py @@ -548,8 +548,8 @@ def cli(): write_srt(result_aligned["word_segments"], file=srt) # save ASS - # with open(os.path.join(output_dir, audio_basename + ".ass"), "w", encoding="utf-8") as ass: - # write_ass(result_aligned["segments"], file=ass) + with open(os.path.join(output_dir, audio_basename + ".ass"), "w", encoding="utf-8") as ass: + write_ass(result_aligned["segments"], file=ass) if __name__ == '__main__': From 7459bf8ad0c576d1637da7dd5fec3ca99635950f Mon Sep 17 00:00:00 2001 From: Felippe Chemello Date: Wed, 11 Jan 2023 12:11:41 -0300 Subject: [PATCH 2/4] Add PT (pt-br) align support --- README.md | 2 +- whisperx/transcribe.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 6af17b3..3afd7c7 100644 --- a/README.md +++ b/README.md @@ -93,7 +93,7 @@ https://user-images.githubusercontent.com/36994049/207743923-b4f0d537-29ae-4be2- The phoneme ASR alignment model is *language-specific*, for tested languages these models are [automatically picked from torchaudio pipelines or huggingface](https://github.com/m-bain/whisperX/blob/e909f2f766b23b2000f2d95df41f9b844ac53e49/whisperx/transcribe.py#L22). Just pass in the `--language` code, and use the whisper `--model large`. -Currently default models provided for `{en, fr, de, es, it, ja, zh, nl, uk}`. If the detected language is not in this list, you need to find a phoneme-based ASR model from [huggingface model hub](https://huggingface.co/models) and test it on your data. +Currently default models provided for `{en, fr, de, es, it, ja, zh, nl, uk, pt}`. If the detected language is not in this list, you need to find a phoneme-based ASR model from [huggingface model hub](https://huggingface.co/models) and test it on your data. #### E.g. German diff --git a/whisperx/transcribe.py b/whisperx/transcribe.py index 85bcda5..62e96f2 100644 --- a/whisperx/transcribe.py +++ b/whisperx/transcribe.py @@ -32,6 +32,7 @@ DEFAULT_ALIGN_MODELS_HF = { "zh": "jonatasgrosman/wav2vec2-large-xlsr-53-chinese-zh-cn", "nl": "jonatasgrosman/wav2vec2-large-xlsr-53-dutch", "uk": "Yehor/wav2vec2-xls-r-300m-uk-with-small-lm", + "pt": "joaoalvarenga/wav2vec2-large-100k-voxpopuli-pt" } From 7adead16e082c4a7d157dce8b1bc52cbafc8584a Mon Sep 17 00:00:00 2001 From: Rhenan Bartels Date: Wed, 11 Jan 2023 19:50:34 -0300 Subject: [PATCH 3/4] Update pt model to wav2vec2-large-xlsr-53-portuguese --- whisperx/transcribe.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/whisperx/transcribe.py b/whisperx/transcribe.py index 62e96f2..787b4e7 100644 --- a/whisperx/transcribe.py +++ b/whisperx/transcribe.py @@ -32,7 +32,7 @@ DEFAULT_ALIGN_MODELS_HF = { "zh": "jonatasgrosman/wav2vec2-large-xlsr-53-chinese-zh-cn", "nl": "jonatasgrosman/wav2vec2-large-xlsr-53-dutch", "uk": "Yehor/wav2vec2-xls-r-300m-uk-with-small-lm", - "pt": "joaoalvarenga/wav2vec2-large-100k-voxpopuli-pt" + "pt": "jonatasgrosman/wav2vec2-large-xlsr-53-portuguese", } From 4569cb982a160689e5b807f03192c01fa01fcc46 Mon Sep 17 00:00:00 2001 From: m-bain <36994049+m-bain@users.noreply.github.com> Date: Thu, 12 Jan 2023 12:57:12 +0000 Subject: [PATCH 4/4] fix file_ass display bug sentence start time on .ass files had a bug where if the first word did not have a timestamp, it would set sentence start_time to 0, but this needs to be the local 0 not actual file 0 (i.e. it should be segment['start']) --- whisperx/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/whisperx/utils.py b/whisperx/utils.py index e7c8c33..56e3483 100644 --- a/whisperx/utils.py +++ b/whisperx/utils.py @@ -193,7 +193,7 @@ def write_ass(transcript: Iterator[dict], file: TextIO, curr_words = [wrd['text'] for wrd in segment['word-level']] prev = segment['word-level'][0]['start'] if prev is None: - prev = 0 + prev = segment['start'] for wdx, word in enumerate(segment['word-level']): if word['start'] is not None: # fill gap between previous word