Pyaudio Recorder Script Ioerror: [errno Input Overflowed] -9981
The code below is what I use to record audio until the 'Enter' key is pressed it returns an exception, import pyaudio import wave import curses from time import gmtime, strftime im
Solution 1:
I had a similar problem; there are 3 ways to solve it (that I could find)
- set rate=24000
- add option "exception_on_overflow=False" to the "read()" call, that is, make it "stream.read(chunk, exception_on_overflow=False)"
- use callbacks
Here is, for your convenience, an example o "using callbacks"
#!/usr/bin/pythonimport sys, os, math, time, pyaudio
try:
import numpy
except:
numpy = None
rate=48000
chan=2
sofar=0
p = pyaudio.PyAudio()
defcallback(in_data, frame_count, time_info, status):
global sofar
sofar += len(in_data)
if numpy:
f = numpy.fromstring(in_data, dtype=numpy.int16)
sys.stderr.write('length %6d sofar %6d std %4.1f \r' % \
(len(in_data), sofar, numpy.std(f)))
else:
sys.stderr.write('length %6d sofar %6d \r' % \
(len(in_data), sofar))
data = Nonereturn (data, pyaudio.paContinue)
stream = p.open(format=pyaudio.paInt16, channels=chan, rate=rate,
input=True, stream_callback=callback)
whileTrue:
time.sleep(1)
Post a Comment for "Pyaudio Recorder Script Ioerror: [errno Input Overflowed] -9981"