简体   繁体   English

PyAudio:如何捕获内部音频(不是从麦克风)?

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

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 但它抛出paCanNotReadFromAnOutputOnlyStream
Using input=True it reads audio from mic, but that is not what I need. 使用input = True可以从麦克风读取音频,但这不是我所需要的。
Any help, please 任何帮助,请
Edit: I am using linux 编辑:我正在使用linux
I can also use other library, not only PyAudio. 我还可以使用其他库,不仅是PyAudio。 I just need to get this work 我只需要得到这份工作

Try this: https://github.com/intxcc/pyaudio_portaudio 试试这个: https : //github.com/intxcc/pyaudio_portaudio

PyAudio isn't made to record outputs, only inputs. PyAudio并非仅记录输入,而是记录输出。 This fork however introduces an api that gives you the ability to do so through loopback mode. 但是,此fork引入了一个api,使您能够通过环回模式执行此操作。 To use this, set the flag as AUDCLNT_STREAMFLAGS_LOOPBACK. 要使用它,请将标志设置为AUDCLNT_STREAMFLAGS_LOOPBACK。 Hopefully this works and good luck! 希望这能奏效,祝你好运!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM