我已成功使用 pyaudio 读取和记录麦克风数据。我想对声卡输出做同样的事情。(即播放 wavfile 并使用 pyaudio 打开流并逐帧读取声卡输出)。
为了阅读麦克风,我打开了一个 pyaudio 流,如下所示
stream = pyaud.open(
format = pyaudio.paInt16,
channels = 1,
rate = 22050,
input_device_index = 0,
input = True)
当我将 input_device_index 更改为 1 时,出现以下错误
IOError: [Errno 无效的通道数] -9998
下面是 macbook 声卡的 system_info
Default Devices:
================
Default Input Device : 0
defaultSampleRate: 44100.0
defaultLowOutputLatency: 0.01
defaultLowInputLatency: 0.00199546485261
maxInputChannels: 2
structVersion: 2
hostApi: 0 (Core Audio)
index: 0
defaultHighOutputLatency: 0.1
maxOutputChannels: 0
name: Built-in Microph
defaultHighInputLatency: 0.0121541950113
--------------------------------
Default Output Device: 1
defaultSampleRate: 44100.0
defaultLowOutputLatency: 0.00655328798186
defaultLowInputLatency: 0.01
maxInputChannels: 0
structVersion: 2
hostApi: 0 (Core Audio)
index: 1
defaultHighOutputLatency: 0.0167120181406
maxOutputChannels: 2
name: Built-in Output
defaultHighInputLatency: 0.1
--------------------------------