PyAudio:如何捕获内部音频(不是来自麦克风)? [英] PyAudio: how to capture internal audio (not from microphone)?

查看:82
本文介绍了PyAudio:如何捕获内部音频(不是来自麦克风)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这样试过:

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)

但它抛出 paCanNotReadFromAnOutputOnlyStream
使用 input=True 它从麦克风读取音频,但这不是我需要的.
任何帮助,请
我使用的是 linux
我还可以使用其他库,而不仅仅是 PyAudio.我只需要完成这项工作

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

推荐答案

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

PyAudio 不是用来记录输出的,而是用来记录输入的.然而,这个 fork 引入了一个 api,使您能够通过环回模式执行此操作.要使用它,请将标志设置为 AUDCLNT_STREAMFLAGS_LOOPBACK.希望这有效,祝你好运!

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!

这篇关于PyAudio:如何捕获内部音频(不是来自麦克风)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆