diff --git a/nemo/collections/asr/parts/utils/streaming_utils.py b/nemo/collections/asr/parts/utils/streaming_utils.py index d657c56a67b6..b07053f9f3ec 100644 --- a/nemo/collections/asr/parts/utils/streaming_utils.py +++ b/nemo/collections/asr/parts/utils/streaming_utils.py @@ -13,7 +13,7 @@ # limitations under the License. import copy -import logging +from nemo.utils import logging import math import os from dataclasses import dataclass @@ -55,11 +55,8 @@ def print_alignment(alignment): if m > 0: n = len(alignment[0]) for i in range(m): - for j in range(n): - if j == 0: - print(f"{i:4d} |", end=" ") - print(f"{alignment[i][j]}", end=" ") - print() + row = f"{i:4d} | " + " ".join(str(alignment[i][j]) for j in range(n)) + logging.debug(row) def write_lcs_alignment_to_pickle(alignment, filepath, extras=None): @@ -292,7 +289,7 @@ def longest_common_subsequence_merge(X, Y, filepath=None): "slice_idx": result_idx, } write_lcs_alignment_to_pickle(LCSuff, filepath=filepath, extras=extras) - print("Wrote alignemnt to :", filepath) + logging.debug("Wrote alignemnt to : " + filepath) return result_idx, LCSuff @@ -1066,7 +1063,7 @@ def __init__( except Exception: self.eos_id = -1 - print("Performing Stateful decoding :", self.stateful_decoding) + logging.info(f"Performing Stateful decoding : {self.stateful_decoding}") if self.target_lang_id is not None: logging.info("Using target language ID") @@ -1962,7 +1959,7 @@ def transcribe( if not keep_logits: return hypothesis - print("keep_logits=True is not supported for MultiTaskAEDFrameBatchInfer. Returning empty logits.") + logging.warning("keep_logits=True is not supported for MultiTaskAEDFrameBatchInfer. Returning empty logits.") return hypothesis, [] def _join_hypotheses(self, hypotheses, timestamps=False): @@ -2102,7 +2099,7 @@ def transcribe( if not keep_logits: return hypothesis - print("keep_logits=True is not supported for FrameBatchChunkedRNNT. Returning empty logits.") + logging.warning("keep_logits=True is not supported for FrameBatchChunkedRNNT. Returning empty logits.") return hypothesis, [] @@ -2159,7 +2156,7 @@ def transcribe( if not keep_logits: return hypothesis - print("keep_logits=True is not supported for FrameBatchChunkedCTC. Returning empty logits.") + logging.warning("keep_logits=True is not supported for FrameBatchChunkedCTC. Returning empty logits.") return hypothesis, [] diff --git a/nemo/collections/asr/parts/utils/transcribe_utils.py b/nemo/collections/asr/parts/utils/transcribe_utils.py index 9c576ce3c093..c40f0b507baf 100644 --- a/nemo/collections/asr/parts/utils/transcribe_utils.py +++ b/nemo/collections/asr/parts/utils/transcribe_utils.py @@ -127,7 +127,7 @@ def get_buffered_pred_feat_rnnt( if manifest: filepaths = [] with open(manifest, "r", encoding='utf_8') as mfst_f: - print("Parsing manifest files...") + logging.info("Parsing manifest files...") for L in mfst_f: L = L.strip() if not L: @@ -202,13 +202,13 @@ def get_buffered_pred_feat_rnnt( if os.environ.get('DEBUG', '0') in ('1', 'y', 't'): if len(refs) == 0: - print("ground-truth text does not present!") + logging.warning("ground-truth text does not present!") for hyp in hyps: - print("hyp:", hyp) + logging.debug("hyp: " + str(hyp)) else: for hyp, ref in zip(hyps, refs): - print("hyp:", hyp) - print("ref:", ref) + logging.debug("hyp: " + str(hyp)) + logging.debug("ref: " + str(ref)) wrapped_hyps = wrap_transcription(hyps) return wrapped_hyps diff --git a/nemo/collections/asr/parts/utils/vad_utils.py b/nemo/collections/asr/parts/utils/vad_utils.py index 0848a4f9c3f1..25e9f6fe2ad5 100644 --- a/nemo/collections/asr/parts/utils/vad_utils.py +++ b/nemo/collections/asr/parts/utils/vad_utils.py @@ -954,12 +954,12 @@ def vad_tune_threshold_on_dev( best_threshold = param optimal_scores = all_perf[str(param)] min_score = score - print("Current best", best_threshold, optimal_scores) + logging.info(f"Current best {best_threshold} {optimal_scores}") except RuntimeError as e: - print(f"Pass {param}, with error {e}") + logging.warning(f"Pass {param}, with error {e}") except pd.errors.EmptyDataError as e1: - print(f"Pass {param}, with error {e1}") + logging.warning(f"Pass {param}, with error {e1}") return best_threshold, optimal_scores