From 77b2f8f3ecaa8178d1a1c6a18457f2d5351b8678 Mon Sep 17 00:00:00 2001 From: Jordan Olafsen Date: Mon, 4 Mar 2019 23:00:00 +1300 Subject: [PATCH] Address pull request feedback from @lissyx --- examples/mic_vad_streaming/mic_vad_streaming.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) mode change 100644 => 100755 examples/mic_vad_streaming/mic_vad_streaming.py diff --git a/examples/mic_vad_streaming/mic_vad_streaming.py b/examples/mic_vad_streaming/mic_vad_streaming.py old mode 100644 new mode 100755 index 5c385242..6e7f4993 --- a/examples/mic_vad_streaming/mic_vad_streaming.py +++ b/examples/mic_vad_streaming/mic_vad_streaming.py @@ -11,7 +11,6 @@ from scipy import signal logging.basicConfig(level=20) - class Audio(object): """Streams raw audio from microphone. Data is received in a separate thread, and stored in a buffer, to be read from.""" @@ -25,8 +24,7 @@ class Audio(object): def proxy_callback(in_data, frame_count, time_info, status): callback(in_data) return (None, pyaudio.paContinue) - if callback is None: - callback = lambda in_data: self.buffer_queue.put(in_data) + if callback is None: callback = lambda in_data: self.buffer_queue.put(in_data) self.buffer_queue = queue.Queue() self.device = device self.input_rate = input_rate @@ -117,8 +115,7 @@ class VADAudio(Audio): Example: (frame, ..., frame, None, frame, ..., frame, None, ...) |---utterence---| |---utterence---| """ - if frames is None: - frames = self.frame_generator() + if frames is None: frames = self.frame_generator() num_padding_frames = padding_ms // self.frame_duration_ms ring_buffer = collections.deque(maxlen=num_padding_frames) triggered = False @@ -190,7 +187,6 @@ def main(ARGS): print("Recognized: %s" % text) stream_context = model.setupStream() - if __name__ == '__main__': BEAM_WIDTH = 500 DEFAULT_SAMPLE_RATE = 16000 @@ -218,7 +214,7 @@ if __name__ == '__main__': parser.add_argument('-t', '--trie', default='trie', help="Path to the language model trie file created with native_client/generate_trie. Default: trie") parser.add_argument('-d', '--device', type=int, default=None, - help="Device input index (Int) as listed by pyaudio.PyAudio.get_device_info_by_index()") + help="Device input index (Int) as listed by pyaudio.PyAudio.get_device_info_by_index(). If not provided, falls back to PyAudio.get_default_device()") parser.add_argument('-r', '--rate', type=int, default=DEFAULT_SAMPLE_RATE, help=f"Input device sample rate. Default: {DEFAULT_SAMPLE_RATE}. Your device may require 44100.") parser.add_argument('-nf', '--n_features', type=int, default=N_FEATURES,