From eab6d3f5d9b2a7de09b761947f45fd8c76014cc9 Mon Sep 17 00:00:00 2001 From: Reuben Morais Date: Wed, 19 May 2021 13:28:43 +0200 Subject: [PATCH] Break dependency cycle between augmentation and config --- bin/data_set_tool.py | 1 + bin/play.py | 1 + training/coqui_stt_training/util/augmentations.py | 10 ++-------- training/coqui_stt_training/util/config.py | 4 ++-- 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/bin/data_set_tool.py b/bin/data_set_tool.py index bdff618d..078d0c35 100755 --- a/bin/data_set_tool.py +++ b/bin/data_set_tool.py @@ -33,6 +33,7 @@ AUDIO_TYPE_LOOKUP = {"wav": AUDIO_TYPE_WAV, "opus": AUDIO_TYPE_OPUS} def build_data_set(): audio_type = AUDIO_TYPE_LOOKUP[CLI_ARGS.audio_type] augmentations = parse_augmentations(CLI_ARGS.augment) + print(f"Parsed augmentations from flags: {augmentations}") if any(not isinstance(a, SampleAugmentation) for a in augmentations): print( "Warning: Some of the specified augmentations will not get applied, as this tool only supports " diff --git a/bin/play.py b/bin/play.py index c80e2a02..d0cb8873 100755 --- a/bin/play.py +++ b/bin/play.py @@ -52,6 +52,7 @@ def get_samples_in_play_order(): def play_collection(): augmentations = parse_augmentations(CLI_ARGS.augment) + print(f"Parsed augmentations from flags: {augmentations}") if any(not isinstance(a, SampleAugmentation) for a in augmentations): print("Warning: Some of the augmentations cannot be simulated by this command.") samples = get_samples_in_play_order() diff --git a/training/coqui_stt_training/util/augmentations.py b/training/coqui_stt_training/util/augmentations.py index 0206b1aa..e6ded9ae 100644 --- a/training/coqui_stt_training/util/augmentations.py +++ b/training/coqui_stt_training/util/augmentations.py @@ -15,7 +15,6 @@ from .audio import ( max_dbfs, normalize_audio, ) -from .config import log_info from .helpers import ( MEGABYTE, LimitingPool, @@ -76,10 +75,10 @@ class GraphAugmentation(Augmentation): return tensor def units_per_ms(self): - from .flags import FLAGS # pylint: disable=import-outside-toplevel + from .config import Config # pylint: disable=import-outside-toplevel return ( - FLAGS.audio_sample_rate / 1000.0 + Config.audio_sample_rate / 1000.0 if self.domain == "signal" else 1.0 / Config.feature_win_step ) @@ -123,11 +122,6 @@ def parse_augmentation(augmentation_spec): kwargs[pair[0]] = pair[1] else: raise ValueError("Unable to parse augmentation value assignment") - log_info( - "Processed augmentation type: [{}] with parameter settings: {}".format( - augmentation_cls.__name__, kwargs - ) - ) return augmentation_cls(*args, **kwargs) diff --git a/training/coqui_stt_training/util/config.py b/training/coqui_stt_training/util/config.py index a873f26f..683ba113 100755 --- a/training/coqui_stt_training/util/config.py +++ b/training/coqui_stt_training/util/config.py @@ -555,7 +555,7 @@ def initialize_globals(): c.augmentations = parse_augmentations(c.augment) print(f"Parsed augmentations from flags: {c.augmentations}") if c.augmentations and c.feature_cache and c.cache_for_epochs == 0: - log_warn( + print( "Due to current feature-cache settings the exact same sample augmentations of the first " "epoch will be repeated on all following epochs. This could lead to unintended over-fitting. " "You could use --cache_for_epochs to invalidate the cache after a given number of epochs." @@ -568,7 +568,7 @@ def initialize_globals(): # Caching if c.cache_for_epochs == 1: - log_warn( + print( "--cache_for_epochs == 1 is (re-)creating the feature cache on every epoch but will never use it." )