From 8ab46ffcb0fc8b892d2e35b166772076fb630e8f Mon Sep 17 00:00:00 2001 From: Nithin Rao Date: Thu, 21 Nov 2024 16:03:50 -0500 Subject: [PATCH] update hypothesis when passed through cfg (#11366) Signed-off-by: Nithin Rao Koluguri Co-authored-by: Nithin Rao Koluguri --- examples/asr/transcribe_speech.py | 2 ++ nemo/collections/asr/models/ctc_models.py | 1 + nemo/collections/asr/models/rnnt_models.py | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/examples/asr/transcribe_speech.py b/examples/asr/transcribe_speech.py index f1d61edc990e..b3264e7e6d90 100644 --- a/examples/asr/transcribe_speech.py +++ b/examples/asr/transcribe_speech.py @@ -275,6 +275,8 @@ def main(cfg: TranscriptionConfig) -> Union[TranscriptionConfig, List[Hypothesis # we will adjust this flag if the model does not support it compute_langs = cfg.compute_langs + if cfg.timestamps: + cfg.return_hypotheses = True # Check whether model and decoder type match if isinstance(asr_model, EncDecCTCModel): diff --git a/nemo/collections/asr/models/ctc_models.py b/nemo/collections/asr/models/ctc_models.py index 3df6a7352c4d..962c7f2902eb 100644 --- a/nemo/collections/asr/models/ctc_models.py +++ b/nemo/collections/asr/models/ctc_models.py @@ -160,6 +160,7 @@ def transcribe( A list of transcriptions (or raw log probabilities if logprobs is True) in the same order as paths2audio_files """ + timestamps = timestamps or override_config.timestamps if override_config is not None else None if timestamps is not None: # else retain the decoder state (users can set it using change_decoding_strategy) if timestamps or (override_config is not None and override_config.timestamps): diff --git a/nemo/collections/asr/models/rnnt_models.py b/nemo/collections/asr/models/rnnt_models.py index a6408b5e935e..4facd59a8c14 100644 --- a/nemo/collections/asr/models/rnnt_models.py +++ b/nemo/collections/asr/models/rnnt_models.py @@ -285,7 +285,7 @@ def transcribe( * A list of greedy transcript texts / Hypothesis * An optional list of beam search transcript texts / Hypothesis / NBestHypothesis. """ - + timestamps = timestamps or override_config.timestamps if override_config is not None else None if timestamps is not None: if timestamps or (override_config is not None and override_config.timestamps): logging.info(