I am trying to execute a PyAudio python capturing program on Rasbian in my RaspberryPi model B board, but getting error:
Traceback (most recent call last):
File "/home/pi/pythonsound/record.py", line 35, in <module>
data = stream.read(CHUNK)
File "/usr/local/lib/python2.7/dist-packages/pyaudio.py", line 605, in read
return pa.read_stream(self._stream, num_frames)
IOError: [Errno Input overflowed] -9981
There are some other suggestions available but not effective Here is what I've tried, This is the code
import pyaudio
import wave
import sys
CHUNK = 1024
FORMAT = pyaudio.paInt16
CHANNELS = 1
RATE = 44100
RECORD_SECONDS = 5
WAVE_OUTPUT_FILENAME = "output.wav"
p = pyaudio.PyAudio()
stream = p.open(format=FORMAT,
channels=CHANNELS,
rate=RATE,
input=True,
frames_per_buffer=CHUNK)
print("* recording")
frames = []
for i in range(0, int(RATE / CHUNK * RECORD_SECONDS)):
data = stream.read(CHUNK)
frames.append(data)
print("* done recording")
stream.stop_stream()
stream.close()
p.terminate()
wf = wave.open(WAVE_OUTPUT_FILENAME, 'wb')
wf.setnchannels(CHANNELS)
wf.setsampwidth(p.get_sample_size(FORMAT))
wf.setframerate(RATE)
wf.writeframes(b''.join(frames))
wf.close()
This is my USB Audio Card device info,
{'defaultSampleRate': 44100.0,
'defaultLowOutputLatency': 0.011609977324263039,
'defaultLowInputLatency': 0.011609977324263039,
'maxInputChannels': 1L,
'structVersion': 2L,
'hostApi': 0L,
'index': 0,
'defaultHighOutputLatency': 0.046439909297052155,
'maxOutputChannels': 2L,
'name': u
'USB PnP Sound Device: USB Audio (hw:0,0)',
'defaultHighInputLatency': 0.046439909297052155}
can you please guide me resolve this problem?