The following script output problems and show me the following content:
#! The/usr/bin/env python
The import pyaudio
The from pprint import pprint
P=pyaudio. Pyaudio ()
# SUCCEEDS
Pprint (p.i s_format_supported (input_format=pyaudio paInt8, input_channels=1, rate=44100, input_device=0)) #=& gt; True
Try:
Stream=p.o pen (format=pyaudio paInt8, channels=1, rate=44100, input=True, frames_per_buffer=1024)
Data=https://bbs.csdn.net/topics/stream.read (1024)
Except IOError as e:
Print 'This never happens: "+ STR (e)
# FAILS
Pprint (p.i s_format_supported (input_format=pyaudio paInt8, input_channels=1, rate=22050, input_device=0)) #=& gt; True
Try:
Stream=p.o pen (format=pyaudio paInt8, channels=1, rate=22050, input=True, frames_per_buffer=1024)
Data=https://bbs.csdn.net/topics/stream.read (1024)
Except IOError as e:
Print 'This fails: "+ STR (e)
# FAILS
Pprint (p.i s_format_supported (input_format=pyaudio paInt8, input_channels=1, rate=22050, input_device=0)) #=& gt; True
Try:
Stream=p.o pen (format=pyaudio paInt8, channels=1, rate=22050, input=True, frames_per_buffer=512)
Data=https://bbs.csdn.net/topics/stream.read (1024)
Except IOError as e:
Print 'This braking fails: "+ STR (e)
# FAILS
Pprint (p.i s_format_supported (input_format=pyaudio paInt8, input_channels=1, rate=11025, input_device=0)) #=& gt; True
Try:
Stream=p.o pen (format=pyaudio paInt8, channels=1, rate=11025, input=True, frames_per_buffer=512)
Data=https://bbs.csdn.net/topics/stream.read (1024)
Except IOError as e:
Print 'This braking fails as well: "+ STR (e)
Stream. Stop_stream ()
Stream. The close ()
P.t erminate ()
The above output is as follows:
True
True
This fails: [Errno Input overflowed] - 9981
True
This braking fails: [Errno Input overflowed] - 9981
True
This braking fails as well: [Errno Input overflowed] - 9981
CodePudding user response:
If you want to check whether the operating system and hardware to support the required format, channels, rate Settings, do the following:The 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 is True, because your system can handle your Settings. Out of memory error may be caused by certain operating system hardware problems. You must check your default host API can actually do. You don't need to "stream class" "open" and "closed" soundObj to query it.
Look at this question: PyAudio Input overflowed
About other pyaudio document and help, please visit:
http://people.csail.mit.edu/hubert/pyaudio/docs/
Editor:
Facts have proven that "Errno input overflow - 9981" is not a small problem: http://trac.macports.org/ticket/39150
I see you have the latest portaudio version (19.20111121), but 19.20111121 _4 claims to fix the bug. See if upgrade portaudio effectively.
CodePudding user response:
So how to solve this problem?