|
16 | 16 | import argparse |
17 | 17 | from tensorflow_asr.utils import env_util, math_util |
18 | 18 |
|
19 | | -env_util.setup_environment() |
| 19 | +logger = env_util.setup_environment() |
20 | 20 | import tensorflow as tf |
21 | 21 |
|
22 | 22 | parser = argparse.ArgumentParser(prog="Conformer non streaming") |
|
52 | 52 | config = Config(args.config) |
53 | 53 | speech_featurizer = TFSpeechFeaturizer(config.speech_config) |
54 | 54 | if args.sentence_piece: |
55 | | - print("Loading SentencePiece model ...") |
| 55 | + logger.info("Loading SentencePiece model ...") |
56 | 56 | text_featurizer = SentencePieceFeaturizer.load_from_file(config.decoder_config, args.subwords) |
57 | 57 | elif args.subwords and os.path.exists(args.subwords): |
58 | | - print("Loading subwords ...") |
| 58 | + logger.info("Loading subwords ...") |
59 | 59 | text_featurizer = SubwordFeaturizer.load_from_file(config.decoder_config, args.subwords) |
60 | 60 | else: |
61 | 61 | text_featurizer = CharFeaturizer(config.decoder_config) |
|
74 | 74 |
|
75 | 75 | if args.beam_width: |
76 | 76 | transcript = conformer.recognize_beam(features[None, ...], input_length[None, ...]) |
77 | | - print("Transcript:", transcript[0].numpy().decode("UTF-8")) |
| 77 | + logger.info("Transcript:", transcript[0].numpy().decode("UTF-8")) |
78 | 78 | elif args.timestamp: |
79 | 79 | transcript, stime, etime, _, _ = conformer.recognize_tflite_with_timestamp( |
80 | 80 | signal, tf.constant(text_featurizer.blank, dtype=tf.int32), conformer.predict_net.get_initial_state()) |
81 | | - print("Transcript:", transcript) |
82 | | - print("Start time:", stime) |
83 | | - print("End time:", etime) |
| 81 | + logger.info("Transcript:", transcript) |
| 82 | + logger.info("Start time:", stime) |
| 83 | + logger.info("End time:", etime) |
84 | 84 | else: |
85 | 85 | transcript, _, _ = conformer.recognize_tflite( |
86 | 86 | signal, tf.constant(text_featurizer.blank, dtype=tf.int32), conformer.predict_net.get_initial_state()) |
87 | | - print("Transcript:", tf.strings.unicode_encode(transcript, "UTF-8").numpy().decode("UTF-8")) |
| 87 | + logger.info("Transcript:", tf.strings.unicode_encode(transcript, "UTF-8").numpy().decode("UTF-8")) |
0 commit comments