From 8e87d9d52fdae29a780cf330815273460641d43d Mon Sep 17 00:00:00 2001 From: Daniel Galvez Date: Fri, 17 May 2024 13:19:27 -0700 Subject: [PATCH] Fix transcribe_time not defined error when using partial audio. --- examples/asr/transcribe_speech.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/asr/transcribe_speech.py b/examples/asr/transcribe_speech.py index 644ac60b31306..9a02b36ae3035 100644 --- a/examples/asr/transcribe_speech.py +++ b/examples/asr/transcribe_speech.py @@ -415,6 +415,8 @@ def autocast(dtype=None, enabled=True): with autocast(dtype=amp_dtype, enabled=cfg.amp): with torch.no_grad(): + if cfg.calculate_rtfx: + start_time = time.time() if partial_audio: transcriptions = transcribe_partial_audio( asr_model=asr_model, @@ -436,14 +438,12 @@ def autocast(dtype=None, enabled=True): override_cfg.text_field = cfg.gt_text_attr_name override_cfg.lang_field = cfg.gt_lang_attr_name - if cfg.calculate_rtfx: - start_time = time.time() transcriptions = asr_model.transcribe( audio=filepaths, override_config=override_cfg, ) - if cfg.calculate_rtfx: - transcribe_time = time.time() - start_time + if cfg.calculate_rtfx: + transcribe_time = time.time() - start_time if cfg.dataset_manifest is not None: logging.info(f"Finished transcribing from manifest file: {cfg.dataset_manifest}")