PyAudio Memory Error

亡梦爱人 提交于 2019-12-04 15:03:02

What's the exception you're getting? If it's an input overflow from PortAudio, you can try increasing the chunk size. Also, when the buffer is overflowing on white noise, it can be handled by catching the exception and returning a blank stream:

try:
    data = stream.read(chunk)
except IOError as ex:
    if ex[1] != pyaudio.paInputOverflowed:
        raise
    data = '\x00' * chunk  # or however you choose to handle it, e.g. return None

Try to increasing the chunk size. For the overflow issue, the only think you need to do is replace the code from

data = stream.read(chunk)  

to

data = stream.read(chunk, exception_on_overflow = False)  
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!