解决Azure Speech SDK错误0xe(SPXERR_MIC_NOT_AVAILABLE):VSCode终端麦克风问题
解决VSCode PowerShell终端中Azure Speech SDK麦克风不可用问题
检查VSCode麦克风权限
打开Windows设置→隐私和安全性→麦克风,确保“允许应用访问麦克风”已开启,同时在应用列表里找到Visual Studio Code,确认其麦克风访问开关处于打开状态。终端作为VSCode的子进程运行,需保证VSCode本身拥有麦克风权限。确认PowerShell麦克风权限(若上述步骤无效)
同样在麦克风权限列表中,找到Windows PowerShell或PowerShell,开启它的麦克风访问权限。重启VSCode和PowerShell
修改权限后,完全关闭VSCode(包括后台进程)再重新打开,确保权限设置生效。指定具体麦克风设备(规避默认设备识别问题)
可以通过代码列出所有可用麦克风,手动指定目标设备ID来解决默认设备识别错误:import azure.cognitiveservices.speech as speechsdk # 列出所有音频输入设备 speech_config = speechsdk.SpeechConfig(subscription="你的订阅密钥", region="你的区域") devices = speechsdk.audio.AudioDeviceManager.list_audio_input_devices() for i, device in enumerate(devices): print(f"设备 {i}: {device.name}, ID: {device.id}") # 使用指定设备初始化识别器 target_device_id = "上述输出的目标设备ID" audio_config = speechsdk.audio.AudioConfig(device_id=target_device_id) speech_recognizer = speechsdk.SpeechRecognizer(speech_config=speech_config, audio_config=audio_config)检查VSCode终端环境一致性
确认VSCode使用的Python解释器和Jupyter一致(点击VSCode左下角切换环境,选择Python 3.11.10),并重新安装SDK到当前环境:pip install azure-cognitiveservices-speech --upgrade
内容的提问来源于stack exchange,提问作者Saeshav Subash
相关产品推荐
相关产品推荐

