diff options
author | Pete Warden <petewarden@google.com> | 2018-04-12 11:45:02 -0700 |
---|---|---|
committer | TensorFlower Gardener <gardener@tensorflow.org> | 2018-04-12 11:49:27 -0700 |
commit | 024b037e9ad430c4023e3c9d250f3934f38de5cf (patch) | |
tree | fa6a2b9b97457f48bc505a85f6cdd38f4b13a45f /tensorflow/examples | |
parent | 3ebe39c6152e587137ab580b7e1ec6861f1f22cc (diff) |
Fixed error where no background audio samples were being used when testing no-speech clips
PiperOrigin-RevId: 192644704
Diffstat (limited to 'tensorflow/examples')
-rw-r--r-- | tensorflow/examples/speech_commands/input_data.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/tensorflow/examples/speech_commands/input_data.py b/tensorflow/examples/speech_commands/input_data.py index e7db9cddf0..63dd18457f 100644 --- a/tensorflow/examples/speech_commands/input_data.py +++ b/tensorflow/examples/speech_commands/input_data.py @@ -457,7 +457,7 @@ class AudioProcessor(object): self.time_shift_offset_placeholder_: time_shift_offset, } # Choose a section of background noise to mix in. - if use_background: + if use_background or sample['label'] == SILENCE_LABEL: background_index = np.random.randint(len(self.background_data)) background_samples = self.background_data[background_index] background_offset = np.random.randint( @@ -465,7 +465,9 @@ class AudioProcessor(object): background_clipped = background_samples[background_offset:( background_offset + desired_samples)] background_reshaped = background_clipped.reshape([desired_samples, 1]) - if np.random.uniform(0, 1) < background_frequency: + if sample['label'] == SILENCE_LABEL: + background_volume = np.random.uniform(0, 1) + elif np.random.uniform(0, 1) < background_frequency: background_volume = np.random.uniform(0, background_volume_range) else: background_volume = 0 |