Skip to content

Commit

Permalink
Fix transcribe_time not defined error when using partial audio.
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Galvez <dgalvez@nvidia.com>
  • Loading branch information
galv committed May 17, 2024
1 parent 82c607c commit bf017ac
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions examples/asr/transcribe_speech.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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

Check failure

Code scanning / CodeQL

Potentially uninitialized local variable Error

Local variable 'start_time' may be used before it is initialized.

if cfg.dataset_manifest is not None:
logging.info(f"Finished transcribing from manifest file: {cfg.dataset_manifest}")
Expand Down

0 comments on commit bf017ac

Please sign in to comment.