Skip to content

Instantly share code, notes, and snippets.

@Uberi
Created November 5, 2015 22:12
Show Gist options
  • Save Uberi/4bb42f0b9fd6251984e4 to your computer and use it in GitHub Desktop.
Save Uberi/4bb42f0b9fd6251984e4 to your computer and use it in GitHub Desktop.
import pyaudio, audioop
CHANNELS = 2
RATE = 44100
CHUNK = 4096
FORMAT = pyaudio.paInt16
p = pyaudio.PyAudio()
stream = p.open(format=FORMAT, channels=CHANNELS, rate=RATE, input=True, frames_per_buffer=CHUNK)
sample_size = pyaudio.get_sample_size(FORMAT)
try:
while True:
buffer = stream.read(CHUNK)
left_frames, right_frames = audioop.tomono(buffer, sample_size, 1, 0), audioop.tomono(buffer, sample_size, 0, 1)
except KeyboardInterrupt: pass
stream.stop_stream()
stream.close()
p.terminate()
@theja0473
Copy link

This is giving nothing result with this script if interrupt occurred with specified speech word like "xioan" then can i call my other script.
the out put shows bellow.
screenshot from 2016-06-08 12 51 08

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment