From 24e9e6777c112373792bd137e591d1bd1d8626bf Mon Sep 17 00:00:00 2001 From: CatalinVoss Date: Tue, 17 Nov 2020 14:44:26 -0800 Subject: [PATCH] Make sure we properly unpack samples when changing audio types --- training/deepspeech_training/util/audio.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/training/deepspeech_training/util/audio.py b/training/deepspeech_training/util/audio.py index 05ceba38..04e99fbd 100644 --- a/training/deepspeech_training/util/audio.py +++ b/training/deepspeech_training/util/audio.py @@ -118,15 +118,16 @@ class Sample: self.audio_type = new_audio_type -def _change_audio_type(sample_and_audio_type): - sample, audio_type, bitrate = sample_and_audio_type +def _unpack_and_change_audio_type(sample_and_audio_type): + packed_sample, audio_type, bitrate = sample_and_audio_type + sample = packed_sample.unpack() sample.change_audio_type(audio_type, bitrate=bitrate) return sample -def change_audio_types(samples, audio_type=AUDIO_TYPE_PCM, bitrate=None, processes=None, process_ahead=None): +def change_audio_types(packed_samples, audio_type=AUDIO_TYPE_PCM, bitrate=None, processes=None, process_ahead=None): with LimitingPool(processes=processes, process_ahead=process_ahead) as pool: - yield from pool.imap(_change_audio_type, map(lambda s: (s, audio_type, bitrate), samples)) + yield from pool.imap(_unpack_and_change_audio_type, map(lambda s: (s, audio_type, bitrate), packed_samples)) def get_audio_type_from_extension(ext):