gpt4 book ai didi

audio - 如何使用 PyAudio 或 PortAudio 获取设备的音频采样率列表?

转载 作者:行者123 更新时间:2023-12-04 14:19:05 32 4
gpt4 key购买 nike

我想查询我的音频设备并获取其所有可用的采样率。我正在使用 PyAudio 0.2,它运行在 PortAudio v19 之上,在带有 Python 2.6 的 Ubuntu 机器上。

最佳答案

在 pyaudio 发行版中,test/system_info.py展示了如何确定设备支持的采样率。见 section that starts at line 49 .

简而言之,您使用 PyAudio.is_format_supported方法,例如


devinfo = p.get_device_info_by_index(1) # Or whatever device you care about.
if p.is_format_supported(44100.0, # Sample rate
input_device=devinfo['index'],
input_channels=devinfo['maxInputChannels'],
input_format=pyaudio.paInt16):
print 'Yay!'

关于audio - 如何使用 PyAudio 或 PortAudio 获取设备的音频采样率列表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4623572/

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