Azure多语言神经语音疑似弃用,如何获取可用语音名称?
问题解决:Azure Speech SDK多语言神经语音合成错误
问题分析
从日志信息Unsupported voice en-US-RyanMultilingualNeural可以明确,你提及的en-US-RyanMultilingualNeural和en-US-JennyMultilingualV2Neural语音模型已不再被官方支持,确实存在文档更新滞后的情况。
解决方法
1. 获取当前可用的多语言神经语音列表
你可以通过两种方式获取最新的、支持欧洲葡萄牙语(pt-PT)的多语言语音:
- Azure CLI命令查询:
执行后会返回所有当前可用的多语言神经语音,可从中筛选支持az cognitiveservices speech voice list --multilingualpt-PT的选项。 - Speech Service REST API查询:
发送GET请求至https://<你的服务区域>.tts.speech.microsoft.com/cognitiveservices/voices/list,请求头需添加Ocp-Apim-Subscription-Key: <你的订阅密钥>,返回的JSON数据会包含所有可用语音及其支持的语言列表。
2. 修正后的示例代码
以当前支持pt-PT的跨语言语音(如en-US-AriaMultilingualNeural,具体以查询结果为准)为例,修正后的代码及SSML如下:
import azure.cognitiveservices.speech as speechsdk speech_config = speechsdk.SpeechConfig(subscription="<your-key>", region="<your-region>") speech_config.set_property(speechsdk.PropertyId.Speech_LogFilename, "/path/to/log/file") synthesizer = speechsdk.SpeechSynthesizer(speech_config=speech_config) ssml_string = """<speak version="1.0" xmlns="http://www.w3.org/2001/10/synthesis" xmlns:mstts="https://www.w3.org/2001/mstts" xml:lang="en-US"> <voice name="en-US-AriaMultilingualNeural"> <lang xml:lang="pt-PT"> Bom dia! Eu sou um assistente que fala em português europeu. </lang> </voice> </speak> """ result = synthesizer.speak_ssml_async(ssml_string).get() if result.reason != speechsdk.ResultReason.SynthesizingAudioCompleted: print(f"合成失败: {result.reason} - {result.error_details}") else: print("语音合成成功")
注意事项
- 确认你的Azure Speech服务区域支持所选语音模型,部分语音仅在特定区域开放使用。
- 定期查询更新语音列表,避免因模型下线再次出现类似错误。
内容的提问来源于stack exchange,提问作者ginjaemocoes
相关产品推荐
相关产品推荐

