3
Record a few seconds of audio and save to a WAVE file.
11
FORMAT = pyaudio.paInt16
15
WAVE_OUTPUT_FILENAME = "output.wav"
17
if sys.platform == 'darwin':
22
stream = p.open(format = FORMAT,
26
frames_per_buffer = chunk)
31
for i in range(0, RATE / chunk * RECORD_SECONDS):
32
data = stream.read(chunk)
35
print "* done recording"
41
# write data to WAVE file
43
wf = wave.open(WAVE_OUTPUT_FILENAME, 'wb')
44
wf.setnchannels(CHANNELS)
45
wf.setsampwidth(p.get_sample_size(FORMAT))