Microsoft认知服务-说话者识别API-验证-error-SpeakerInvalid

问题描述 投票:0回答:1

我仍然在验证过程中遇到错误

{“错误”:{“代码”:“ BadRequest”,“消息”:“ SpeakerInvalid”}}''

我的音频很容易注册,因此是正确的

##code for API CALL speaker verification 

import http.client, urllib.request, urllib.parse, urllib.error, base64
subscription_key = 'XXXXXXXXXXXXXXXXXXXXXXX'

headers = {
# Request headers
"Content-Type": 'multipart/form-data',
"Ocp-Apim-Subscription-Key": subscription_key,
}

params = urllib.parse.urlencode({
    'verificationProfileId':'445b849b-6418-4443-961b-77bd88196223',

})

#body = {
#}
try:
    conn = http.client.HTTPSConnection('speaker-recognition-api.cognitiveservices.azure.com')
    body = open('pp.wav','rb') //pp.wav is my audio file
    conn.request("POST", "/spid/v1.0/verify?verificationProfileId=445b849b-6418-4443-961b-77bd88196223?%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))
python-3.x microsoft-cognitive voice-recognition azure-cognitive-services
1个回答
0
投票

我可以重现您的问题。您收到此错误的原因是,URL末尾有一个?,但是在verify后面已经有一个?。因此,如果您想在请求网址中添加参数,则应使用&,就像此API文档中的示例代码:Speaker Recognition - Verification一样。

enter image description here

下面是我的工作代码。

try:
    conn = http.client.HTTPSConnection('geospeaker.cognitiveservices.azure.com')


    body=open("output4.wav","rb")
    conn.request("POST", "/spid/v1.0/verify?verificationProfileId=1ae143b0-c301-4345-9295-3e34ad367092?%s" % params, body, headers)
    response = conn.getresponse()
    data = response.read()
    print(data)
    conn.close()
except OSError as e:
    print("[Errno {0}] {1}".format(e.errno, e.strerror))

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.