Skip to content

Commit

Permalink
no text skip
Browse files Browse the repository at this point in the history
Signed-off-by: fayejf <fayejf07@gmail.com>
  • Loading branch information
fayejf committed May 9, 2023
1 parent 69ac874 commit ef5d91a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,9 @@ def autocast():
use_cer=cfg.use_cer,
output_filename=None,
)
logging.info(f"Writing prediction and error rate of each sample to {output_manifest_w_wer}!")
logging.info(f"{total_res}")
if output_manifest_w_wer:
logging.info(f"Writing prediction and error rate of each sample to {output_manifest_w_wer}!")
logging.info(f"{total_res}")

return cfg

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,9 @@ def main(cfg: TranscriptionConfig) -> TranscriptionConfig:
use_cer=cfg.use_cer,
output_filename=None,
)
logging.info(f"Writing prediction and error rate of each sample to {output_manifest_w_wer}!")
logging.info(f"{total_res}")
if output_manifest_w_wer:
logging.info(f"Writing prediction and error rate of each sample to {output_manifest_w_wer}!")
logging.info(f"{total_res}")

return cfg

Expand Down
5 changes: 3 additions & 2 deletions examples/asr/transcribe_speech.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,8 +355,9 @@ def autocast():
use_cer=cfg.use_cer,
output_filename=None,
)
logging.info(f"Writing prediction and error rate of each sample to {output_manifest_w_wer}!")
logging.info(f"{total_res}")
if output_manifest_w_wer:
logging.info(f"Writing prediction and error rate of each sample to {output_manifest_w_wer}!")
logging.info(f"{total_res}")

return cfg

Expand Down
7 changes: 4 additions & 3 deletions nemo/collections/asr/parts/utils/eval_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def cal_write_wer(
langid: str = 'en',
use_cer: bool = False,
output_filename: str = None,
) -> Tuple[str, dict]:
) -> Tuple[str, dict, str]:
"""
Calculate wer, inserion, deletion and substitution rate based on groundtruth text and pred_text_attr_name (pred_text)
We use WER in function name as a convention, but Error Rate (ER) currently support Word Error Rate (WER) and Character Error Rate (CER)
Expand All @@ -103,9 +103,10 @@ def cal_write_wer(
sample = json.loads(line)

if 'text' not in sample:
raise ValueError(
"ground-truth text is not present in manifest! Cannot calculate Word Error Rate. Exiting!"
logging.info(
"ground-truth text is not present in manifest! Cannot calculate Word Error Rate. Returning!"
)
return None, None, eval_metric

hyp = sample[pred_text_attr_name]
ref = sample['text']
Expand Down

0 comments on commit ef5d91a

Please sign in to comment.