PyAudi未找到ALSA设备

2024-09-30 03:26:21 发布

您现在位置:Python中文网/ 问答频道 /正文

在我的Raspberry Pi上,我通过将以下内容添加到~/.asoundrc中,向ALSA添加了一个音频设备:

pcm_slave.usb16 {
    pcm "hw:1,0"
    format S16_LE
    channels 1
}

pcm.rate_convert {
    type plug
    slave usb16
}

当调用arecord -L时,会列出设备rate_convert,但在PyAudio中列出所有设备时,不会列出该设备。为什么会这样?如何在python中使用这个设备?在


Tags: leformatconvertratepiraspberryslavealsa
1条回答
网友
1楼 · 发布于 2024-09-30 03:26:21

请尝试下面的代码来查找设备及其索引

import pyaudio

po = pyaudio.PyAudio()
for index in range(po.get_device_count()): 
    desc = po.get_device_info_by_index(index)
    print ("DEVICE: {0} \t INDEX: {1} \t RATE: {2}".format(desc["name"],index,int(desc["defaultSampleRate"])))

相关问题 更多 >

    热门问题