PyAudio: how to capture internal audio (not from microphone)?

╄→гoц情女王★ 提交于 2020-03-03 09:13:00

问题


Tried like this:

p = pyaudio.PyAudio()

stream = p.open(format=FORMAT,
            channels=CHANNELS,
            rate=RATE,
            output=True,
            frames_per_buffer=chunk)

all = []
for i in range(0, int(RATE / chunk * RECORD_SECONDS)):
    data = stream.read(chunk)

but it throws paCanNotReadFromAnOutputOnlyStream
Using input=True it reads audio from mic, but that is not what I need.
Any help, please
Edit: I am using linux
I can also use other library, not only PyAudio. I just need to get this work


回答1:


Try this: https://github.com/intxcc/pyaudio_portaudio

PyAudio isn't made to record outputs, only inputs. This fork however introduces an api that gives you the ability to do so through loopback mode. To use this, set the flag as AUDCLNT_STREAMFLAGS_LOOPBACK. Hopefully this works and good luck!



来源:https://stackoverflow.com/questions/45824412/pyaudio-how-to-capture-internal-audio-not-from-microphone

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