【发布时间】:2020-03-17 14:46:54
【问题描述】:
我想为说话人验证项目实施 Microsoft 认知服务中的说话人识别 API。我已经有一个说话人识别 API 密钥。我直接从文档中获得了示例 Python 代码(在文档的底部):
########### Python 3.2 #############
import http.client, urllib.request, urllib.parse, urllib.error, base64
headers = {
# Request headers
'Content-Type': 'application/json',
'Ocp-Apim-Subscription-Key': '{subscription key}',
}
params = urllib.parse.urlencode({
})
try:
conn = http.client.HTTPSConnection('westus.api.cognitive.microsoft.com')
conn.request("POST", "/spid/v1.0/verificationProfiles?%s" % params, "{body}", headers)
response = conn.getresponse()
data = response.read()
print(data)
conn.close()
except Exception as e:
print("[Errno {0}] {1}".format(e.errno, e.strerror))
####################################
这是第一步的代码示例,创建并保存语音配置文件。
要进行说话人验证,我们需要执行 3 个步骤: 1) 创建个人资料 2) 创建注册 3) 验证
我现在已经卡在第一步了。这是我第一次使用 API,所以我不太确定我必须更改 Python 代码的哪些部分。我知道我需要在 'Ocp-Apim-Subscription-Key' 中插入我的 API 密钥,但除此之外,还有什么?例如,如果我在该特定字段中添加我的 API 密钥并让代码运行,我会收到此错误消息。
b'{"error":{"code":"BadRequest","message":"locale is not specified"}}'
例如,我需要在哪里插入语言环境(“en-us”)?从文档中我并不清楚我需要编辑什么。如果您能指导我在 API 调用中插入/添加什么内容,我将不胜感激。
提前非常感谢!
【问题讨论】:
标签: azure speech-recognition microsoft-cognitive voice-recognition azure-cognitive-services