说话人识别错误 API:"Resource or path can't be found."
Error with Speaker Recognition API: "Resource or path can't be found."
我正在尝试 运行 使用 Jupyter API 注册说话人识别的配置文件代码 Python。
不幸的是,我遇到了一个错误:
{ "error": { "code": "NotFound", "message": "Resource or path can't be found." } }
代码如下:
#Loading .wav file
w = wave.open("Harshil_recording_final.wav", "rb")
binary_data = w.readframes(w.getnframes())
#User Enrollment
headers = {
# Request headers
'Content-Type': 'application/octet-stream',
'Ocp-Apim-Subscription-Key': '*subscription-key*',
}
params = urllib.urlencode({
# Request parameters
'identificationProfileId':user1,
'shortAudio': 'true',
})
body = w
try:
conn = httplib.HTTPSConnection('api.projectoxford.ai')
conn.request("POST", "/spid/v1.0/identificationProfiles/{identificationProfileId}/enroll?%s" % params, str(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))
identificationProfileId 是 URL 路径的一部分,而不是查询参数。您应该改为执行以下操作:
params = urllib.urlencode({
# Request parameters
'shortAudio': 'true',
})
...
conn.request("POST", "/spid/v1.0/identificationProfiles/{0}/enroll?{1}".format(user1, params), body, headers)
我正在尝试 运行 使用 Jupyter API 注册说话人识别的配置文件代码 Python。
不幸的是,我遇到了一个错误:
{ "error": { "code": "NotFound", "message": "Resource or path can't be found." } }
代码如下:
#Loading .wav file
w = wave.open("Harshil_recording_final.wav", "rb")
binary_data = w.readframes(w.getnframes())
#User Enrollment
headers = {
# Request headers
'Content-Type': 'application/octet-stream',
'Ocp-Apim-Subscription-Key': '*subscription-key*',
}
params = urllib.urlencode({
# Request parameters
'identificationProfileId':user1,
'shortAudio': 'true',
})
body = w
try:
conn = httplib.HTTPSConnection('api.projectoxford.ai')
conn.request("POST", "/spid/v1.0/identificationProfiles/{identificationProfileId}/enroll?%s" % params, str(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))
identificationProfileId 是 URL 路径的一部分,而不是查询参数。您应该改为执行以下操作:
params = urllib.urlencode({
# Request parameters
'shortAudio': 'true',
})
...
conn.request("POST", "/spid/v1.0/identificationProfiles/{0}/enroll?{1}".format(user1, params), body, headers)