gpt4 book ai didi

python - PyAudio 复制设备

转载 作者:太空宇宙 更新时间:2023-11-03 11:53:05 25 4
gpt4 key购买 nike

我正在尝试列出我的音频设备,但我认为 PyAudio 正在显示一些重复的设备。

这是结果(2 和 6、4 和 5):

1. {'type': 'input', 'name': 'Microsoft Sound Mapper - Input'}
2. {'type': 'input', 'name': 'Microphone (Realtek High Defini'}
3. {'type': 'output', 'name': 'Microsoft Sound Mapper - Output'}
4. {'type': 'output', 'name': 'Speakers (Realtek High Definiti'}
5. {'type': 'output', 'name': 'Speakers (Realtek High Definition Audio)'}
6. {'type': 'input', 'name': 'Microphone (Realtek High Definition Audio)'}

这是我的代码:

def get_devices(self):

self.p = pyaudio.PyAudio()

devices = {}

for x in range(self.p.get_device_count()):
d = self.get_device_info(x)
devices[x] = { 'name' : d['name'] , 'type' : 'output' if d['maxInputChannels'] == 0 else 'input' }

return devices

复制设备的名称已被删除。我的代码有什么问题。或者这是一个错误?

我使用的是 MS Windows 8。

最佳答案

它们不是重复的。其中一些可能来自MME hostApi,一些可能来自DirectSound hostApi,还有一些可能来自Windows-KS,或者WASAPI,甚至ASIO。

我有同样的情况,我选择从这个设备列表中只保留来自 DirectSound 和 ASIO(在 Windows 上)的设备。您可以使用字典的键“hostApi”过滤列表(0=mme、1=directsound 等。请查看 pyaudio 文档)。

关于python - PyAudio 复制设备,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20943803/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com