i want to make a push to talk a chat, but i dont know how.
import pyaudio import sys chunk = 1024 FORMAT = pyaudio.paInt16 CHANNELS = 1 RATE = 44100 RECORD_SECONDS = 5 p = pyaudio.PyAudio() stream = p.open(format = FORMAT, channels = CHANNELS, rate = RATE, input = True, output = True, frames_per_buffer = chunk) print "* recording" for i in range(0, 44100 / chunk * RECORD_SECONDS): data = stream.read(chunk) stream.write(data, chunk) print "* done" stream.stop_stream() stream.close() p.terminate()
This is my code and i want to change it, that only when i press "a" sound is recorded and played. I tryed it with pyhook, that always i press a- something is read out and written in the stream, but i got an input overflow error. Can someone help me?
PS: sorry for my bad english