aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/examples/speech_commands/generate_streaming_test_wav_test.py
diff options
context:
space:
mode:
authorGravatar Pete Warden <petewarden@google.com>2017-08-11 14:30:43 -0700
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2017-08-11 14:34:09 -0700
commit0c6fd1703eb8f990c8b071471b0105339ccf821d (patch)
tree39cd2d96aa06d2ff3bfcaebc0d78cc2aba7dd545 /tensorflow/examples/speech_commands/generate_streaming_test_wav_test.py
parente9a8d75bc470fb410fc54bf78fb4c9ff5d3bdff6 (diff)
Speech keyword detector tutorial
Adds a basic training script for a simple audio model to our examples. See third_party/docs_src/tutorials/audio_recognition.md for full documentation PiperOrigin-RevId: 165025732
Diffstat (limited to 'tensorflow/examples/speech_commands/generate_streaming_test_wav_test.py')
-rw-r--r--tensorflow/examples/speech_commands/generate_streaming_test_wav_test.py39
1 files changed, 39 insertions, 0 deletions
diff --git a/tensorflow/examples/speech_commands/generate_streaming_test_wav_test.py b/tensorflow/examples/speech_commands/generate_streaming_test_wav_test.py
new file mode 100644
index 0000000000..63d93f4534
--- /dev/null
+++ b/tensorflow/examples/speech_commands/generate_streaming_test_wav_test.py
@@ -0,0 +1,39 @@
+# Copyright 2017 The TensorFlow Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ==============================================================================
+"""Tests for test file generation for speech commands."""
+
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
+
+import numpy as np
+
+from tensorflow.examples.speech_commands import generate_streaming_test_wav
+from tensorflow.python.platform import test
+
+
+class GenerateStreamingTestWavTest(test.TestCase):
+
+ def testMixInAudioSample(self):
+ track_data = np.zeros([10000])
+ sample_data = np.ones([1000])
+ generate_streaming_test_wav.mix_in_audio_sample(
+ track_data, 2000, sample_data, 0, 1000, 1.0, 100, 100)
+ self.assertNear(1.0, track_data[2500], 0.0001)
+ self.assertNear(0.0, track_data[3500], 0.0001)
+
+
+if __name__ == "__main__":
+ test.main()