Using any other values in pyaudio for rate / format / chunk give me the error: [Errno Input overflowed] -9981

11,255

If you want to check whether the desired settings of format, channels, rate, etc. are supported by your OS and hardware, do the following:

import pyaudio
soundObj = pyaudio.PyAudio()

# Learn what your OS+Hardware can do
defaultCapability = soundObj.get_default_host_api_info()
print defaultCapability

# See if you can make it do what you want
isSupported = soundObj.is_format_supported(input_format=pyaudio.paInt8, input_channels=1, rate=22050, input_device=0)
print isSupported

isSupported will be True incase your system can deal with your settings. The memory overflow errors might be due to some OS+Hardware issues. You must check what your default host API can actually do. You don't need to "open" and "close" the soundObj via the "stream class" for querying it.

Have a look at this SO question: PyAudio Input overflowed

For additional pyaudio documentation and help visit:

http://people.csail.mit.edu/hubert/pyaudio/docs/

Edit:

It turns out that "Errno Input overflowed - 9981" is not a trivial issue: http://trac.macports.org/ticket/39150

I see that you have the latest portaudio version (19.20111121) but 19.20111121_4 claims to have fixed the bug. See if upgrading portaudio works.

Share:
11,255
the_real_one
Author by

the_real_one

Updated on June 04, 2022

Comments

  • the_real_one
    the_real_one almost 2 years

    OS: Mac OSX 10.7.5 Python: Python 2.7.3 (homebrew) pyaudio: 0.2.7 portaudio: 19.20111121 (homebrew - portaudio)

    The following script outputs the following and displays the issues I am having:

    #!/usr/bin/env python
    import pyaudio
    from pprint import pprint
    
    p = pyaudio.PyAudio()
    
    
    # SUCCEEDS
    pprint(p.is_format_supported(input_format=pyaudio.paInt8,input_channels=1,rate=44100,input_device=0)) # => True
    try:
        stream = p.open(format=pyaudio.paInt8,channels=1,rate=44100,input=True,frames_per_buffer=1024)
        data = stream.read(1024)
    except IOError as e:
        print 'This never happens: '+str(e)
    
    # FAILS
    pprint(p.is_format_supported(input_format=pyaudio.paInt8,input_channels=1,rate=22050,input_device=0)) # => True
    try:
        stream = p.open(format=pyaudio.paInt8,channels=1,rate=22050,input=True,frames_per_buffer=1024)
        data = stream.read(1024)
    except IOError as e:
        print 'This fails: '+str(e)
    
    # FAILS
    pprint(p.is_format_supported(input_format=pyaudio.paInt8,input_channels=1,rate=22050,input_device=0)) # => True
    try:
        stream = p.open(format=pyaudio.paInt8,channels=1,rate=22050,input=True,frames_per_buffer=512)
        data = stream.read(1024)
    except IOError as e:
        print 'This also fails: '+str(e)
    
    # FAILS
    pprint(p.is_format_supported(input_format=pyaudio.paInt8,input_channels=1,rate=11025,input_device=0)) # => True
    try:
        stream = p.open(format=pyaudio.paInt8,channels=1,rate=11025,input=True,frames_per_buffer=512)
        data = stream.read(1024)
    except IOError as e:
        print 'This also fails as well: '+str(e)
    
    stream.stop_stream()
    stream.close()
    p.terminate()
    

    The above outputs the following:

    True
    True
    This fails: [Errno Input overflowed] -9981
    True
    This also fails: [Errno Input overflowed] -9981
    True
    This also fails as well: [Errno Input overflowed] -9981
    
  • the_real_one
    the_real_one about 11 years
    I had to modify your script (you use input_device=2 and I use 1) and also you do not have a "input_device_index=X" on the second p.open(...22050...) block and I then get: Traceback (most recent call last): File "test.py", line 12, in <module>` input_device=1)) File "/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/‌​Versions/2.7/lib/pyt‌​hon2.7/site-packages‌​/PyAudio-0.2.7-py2.7‌​-macosx-10.7-x86_64.‌​egg/pyaudio.py", line 934, in is_format_supported return pa.is_format_supported(rate, **kwargs) ValueError: ('Invalid number of channels', -9998)
  • Radio-
    Radio- about 11 years
    Yeah, I changed the device, since input device 0 is not a audio recording device on my computer, but I can change it back.
  • Radio-
    Radio- about 11 years
    ValueError is the expected results according to the docs if it isn't supported: "Returns True if the configuration is supported; throws a ValueError exception otherwise."