Skip to content

Commit 44b6875

Browse files
committed
✍️ update env util
1 parent f79b3f6 commit 44b6875

34 files changed

+136
-118
lines changed

examples/conformer/test.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import argparse
1818
from tensorflow_asr.utils import env_util, file_util
1919

20-
env_util.setup_environment()
20+
logger = env_util.setup_environment()
2121
import tensorflow as tf
2222

2323
DEFAULT_YAML = os.path.join(os.path.abspath(os.path.dirname(__file__)), "config.yml")
@@ -63,13 +63,13 @@
6363
speech_featurizer = TFSpeechFeaturizer(config.speech_config)
6464

6565
if args.sentence_piece:
66-
print("Use SentencePiece ...")
66+
logger.info("Use SentencePiece ...")
6767
text_featurizer = SentencePieceFeaturizer(config.decoder_config)
6868
elif args.subwords:
69-
print("Use subwords ...")
69+
logger.info("Use subwords ...")
7070
text_featurizer = SubwordFeaturizer(config.decoder_config)
7171
else:
72-
print("Use characters ...")
72+
logger.info("Use characters ...")
7373
text_featurizer = CharFeaturizer(config.decoder_config)
7474

7575
tf.random.set_seed(0)
@@ -96,7 +96,7 @@
9696
overwrite = input(f"Overwrite existing result file {filepath} ? (y/n): ").lower() == "y"
9797
if overwrite:
9898
results = conformer.predict(test_data_loader, verbose=1)
99-
print(f"Saving result to {args.output} ...")
99+
logger.info(f"Saving result to {args.output} ...")
100100
with open(filepath, "w") as openfile:
101101
openfile.write("PATH\tDURATION\tGROUNDTRUTH\tGREEDY\tBEAMSEARCH\n")
102102
progbar = tqdm(total=test_dataset.total_steps, unit="batch")

examples/conformer/tflite.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import argparse
1717
from tensorflow_asr.utils import env_util, file_util
1818

19-
env_util.setup_environment()
19+
logger = env_util.setup_environment()
2020
import tensorflow as tf
2121

2222
from tensorflow_asr.configs.config import Config

examples/conformer/train.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import argparse
1818
from tensorflow_asr.utils import env_util
1919

20-
env_util.setup_environment()
20+
logger = env_util.setup_environment()
2121
import tensorflow as tf
2222

2323
DEFAULT_YAML = os.path.join(os.path.abspath(os.path.dirname(__file__)), "config.yml")
@@ -64,13 +64,13 @@
6464
speech_featurizer = speech_featurizers.TFSpeechFeaturizer(config.speech_config)
6565

6666
if args.sentence_piece:
67-
print("Loading SentencePiece model ...")
67+
logger.info("Loading SentencePiece model ...")
6868
text_featurizer = text_featurizers.SentencePieceFeaturizer(config.decoder_config)
6969
elif args.subwords:
70-
print("Loading subwords ...")
70+
logger.info("Loading subwords ...")
7171
text_featurizer = text_featurizers.SubwordFeaturizer(config.decoder_config)
7272
else:
73-
print("Use characters ...")
73+
logger.info("Use characters ...")
7474
text_featurizer = text_featurizers.CharFeaturizer(config.decoder_config)
7575

7676
if args.tfrecords:

examples/contextnet/test.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import argparse
1818
from tensorflow_asr.utils import env_util, file_util
1919

20-
env_util.setup_environment()
20+
logger = env_util.setup_environment()
2121
import tensorflow as tf
2222

2323
DEFAULT_YAML = os.path.join(os.path.abspath(os.path.dirname(__file__)), "config.yml")
@@ -63,13 +63,13 @@
6363
speech_featurizer = TFSpeechFeaturizer(config.speech_config)
6464

6565
if args.sentence_piece:
66-
print("Use SentencePiece ...")
66+
logger.info("Use SentencePiece ...")
6767
text_featurizer = SentencePieceFeaturizer(config.decoder_config)
6868
elif args.subwords:
69-
print("Use subwords ...")
69+
logger.info("Use subwords ...")
7070
text_featurizer = SubwordFeaturizer(config.decoder_config)
7171
else:
72-
print("Use characters ...")
72+
logger.info("Use characters ...")
7373
text_featurizer = CharFeaturizer(config.decoder_config)
7474

7575
tf.random.set_seed(0)
@@ -96,7 +96,7 @@
9696
overwrite = input(f"Overwrite existing result file {filepath} ? (y/n): ").lower() == "y"
9797
if overwrite:
9898
results = contextnet.predict(test_data_loader, verbose=1)
99-
print(f"Saving result to {args.output} ...")
99+
logger.info(f"Saving result to {args.output} ...")
100100
with open(filepath, "w") as openfile:
101101
openfile.write("PATH\tDURATION\tGROUNDTRUTH\tGREEDY\tBEAMSEARCH\n")
102102
progbar = tqdm(total=test_dataset.total_steps, unit="batch")

examples/contextnet/tflite.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import argparse
1717
from tensorflow_asr.utils import env_util, file_util
1818

19-
env_util.setup_environment()
19+
logger = env_util.setup_environment()
2020
import tensorflow as tf
2121

2222
from tensorflow_asr.configs.config import Config

examples/contextnet/train.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import argparse
1818
from tensorflow_asr.utils import env_util
1919

20-
env_util.setup_environment()
20+
logger = env_util.setup_environment()
2121
import tensorflow as tf
2222

2323
DEFAULT_YAML = os.path.join(os.path.abspath(os.path.dirname(__file__)), "config.yml")
@@ -64,13 +64,13 @@
6464
speech_featurizer = speech_featurizers.TFSpeechFeaturizer(config.speech_config)
6565

6666
if args.sentence_piece:
67-
print("Loading SentencePiece model ...")
67+
logger.info("Loading SentencePiece model ...")
6868
text_featurizer = text_featurizers.SentencePieceFeaturizer(config.decoder_config)
6969
elif args.subwords:
70-
print("Loading subwords ...")
70+
logger.info("Loading subwords ...")
7171
text_featurizer = text_featurizers.SubwordFeaturizer(config.decoder_config)
7272
else:
73-
print("Use characters ...")
73+
logger.info("Use characters ...")
7474
text_featurizer = text_featurizers.CharFeaturizer(config.decoder_config)
7575

7676
if args.tfrecords:

examples/deepspeech2/test.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import argparse
1818
from tensorflow_asr.utils import env_util, file_util
1919

20-
env_util.setup_environment()
20+
logger = env_util.setup_environment()
2121
import tensorflow as tf
2222

2323
DEFAULT_YAML = os.path.join(os.path.abspath(os.path.dirname(__file__)), "config.yml")
@@ -63,13 +63,13 @@
6363
speech_featurizer = TFSpeechFeaturizer(config.speech_config)
6464

6565
if args.sentence_piece:
66-
print("Use SentencePiece ...")
66+
logger.info("Use SentencePiece ...")
6767
text_featurizer = SentencePieceFeaturizer(config.decoder_config)
6868
elif args.subwords:
69-
print("Use subwords ...")
69+
logger.info("Use subwords ...")
7070
text_featurizer = SubwordFeaturizer(config.decoder_config)
7171
else:
72-
print("Use characters ...")
72+
logger.info("Use characters ...")
7373
text_featurizer = CharFeaturizer(config.decoder_config)
7474

7575
tf.random.set_seed(0)
@@ -96,7 +96,7 @@
9696
overwrite = input(f"Overwrite existing result file {filepath} ? (y/n): ").lower() == "y"
9797
if overwrite:
9898
results = deepspeech2.predict(test_data_loader, verbose=1)
99-
print(f"Saving result to {args.output} ...")
99+
logger.info(f"Saving result to {args.output} ...")
100100
with open(filepath, "w") as openfile:
101101
openfile.write("PATH\tDURATION\tGROUNDTRUTH\tGREEDY\tBEAMSEARCH\n")
102102
progbar = tqdm(total=test_dataset.total_steps, unit="batch")

examples/deepspeech2/tflite.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import argparse
1717
from tensorflow_asr.utils import env_util, file_util
1818

19-
env_util.setup_environment()
19+
logger = env_util.setup_environment()
2020
import tensorflow as tf
2121

2222
from tensorflow_asr.configs.config import Config

examples/deepspeech2/train.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import argparse
1717
from tensorflow_asr.utils import env_util
1818

19-
env_util.setup_environment()
19+
logger = env_util.setup_environment()
2020
import tensorflow as tf
2121

2222
DEFAULT_YAML = os.path.join(os.path.abspath(os.path.dirname(__file__)), "config.yml")
@@ -62,13 +62,13 @@
6262
speech_featurizer = speech_featurizers.TFSpeechFeaturizer(config.speech_config)
6363

6464
if args.sentence_piece:
65-
print("Loading SentencePiece model ...")
65+
logger.info("Loading SentencePiece model ...")
6666
text_featurizer = text_featurizers.SentencePieceFeaturizer(config.decoder_config)
6767
elif args.subwords:
68-
print("Loading subwords ...")
68+
logger.info("Loading subwords ...")
6969
text_featurizer = text_featurizers.SubwordFeaturizer(config.decoder_config)
7070
else:
71-
print("Use characters ...")
71+
logger.info("Use characters ...")
7272
text_featurizer = text_featurizers.CharFeaturizer(config.decoder_config)
7373

7474
if args.tfrecords:

examples/demonstration/conformer.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import argparse
1717
from tensorflow_asr.utils import env_util, math_util
1818

19-
env_util.setup_environment()
19+
logger = env_util.setup_environment()
2020
import tensorflow as tf
2121

2222
parser = argparse.ArgumentParser(prog="Conformer non streaming")
@@ -52,10 +52,10 @@
5252
config = Config(args.config)
5353
speech_featurizer = TFSpeechFeaturizer(config.speech_config)
5454
if args.sentence_piece:
55-
print("Loading SentencePiece model ...")
55+
logger.info("Loading SentencePiece model ...")
5656
text_featurizer = SentencePieceFeaturizer.load_from_file(config.decoder_config, args.subwords)
5757
elif args.subwords and os.path.exists(args.subwords):
58-
print("Loading subwords ...")
58+
logger.info("Loading subwords ...")
5959
text_featurizer = SubwordFeaturizer.load_from_file(config.decoder_config, args.subwords)
6060
else:
6161
text_featurizer = CharFeaturizer(config.decoder_config)
@@ -74,14 +74,14 @@
7474

7575
if args.beam_width:
7676
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"))
7878
elif args.timestamp:
7979
transcript, stime, etime, _, _ = conformer.recognize_tflite_with_timestamp(
8080
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)
8484
else:
8585
transcript, _, _ = conformer.recognize_tflite(
8686
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

Comments
 (0)