如何修复值错误:通道数无效?

y1aodyip  于 2021-07-14  发布在  Java
关注(0)|答案(0)|浏览(143)

关闭。这个问题需要细节或清晰。它目前不接受答案。
**想改进这个问题吗?**通过编辑这个帖子来添加细节并澄清问题。

两小时前关门了。
改进这个问题

import pyaudio
soundObj = pyaudio.PyAudio()

# Learn what your OS+Hardware can do

defaultCapability = soundObj.get_default_host_api_info()
print(defaultCapability)

# See if you can make it do what you want

isSupported = soundObj.is_format_supported(input_format=pyaudio.paInt8, input_channels=2, rate=22050, input_device=0)
print(isSupported)

我一直在犯以下错误,为什么?

{'index': 0, 
 'structVersion': 1, 
 'type': 2, 
 'name': 'MME', 
 'deviceCount': 2, 
 'defaultInputDevice': -1, 
 'defaultOutputDevice': 1}
Traceback (most recent call last):
  File "M:/Python Workspace/PycharmProjects/untitled/junk2.py", line 9, in <module>
    isSupported = soundObj.is_format_supported(input_format=pyaudio.paInt8, input_channels=2, rate=22050, input_device=0)
  File "C:\Users\clasq\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pyaudio.py", line 937, in is_format_supported
    return pa.is_format_supported(rate,**kwargs)

ValueError: ('Invalid number of channels', -9998)

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题