Microsoft认知服务-说话者识别API-识别-错误 [英] Microsoft Cognitive Services - Speaker Recognition API - Identification - error
问题描述
在此API中,我已经成功创建了标识配置文件,并成功创建了注册,并检查了操作状态并成功注册.
In this API I had successfully created Identification Profile, as well as created enrollment successfully and checked the operation status and received successfully enrolled.
现在,我正在尝试确定说话者,但我得到了 一个错误 : b'{错误":{代码":"BadRequest",消息":音频太长"}}' b'{错误":{代码":"BadRequest",消息":音频太短"}}'
Now I am trying to identify speaker but I am getting an error : b'{"error":{"code":"BadRequest","message":"Audio too long"}}' b'{"error":{"code":"BadRequest","message":"Audio too short"}}'
我尝试了各种不同大小的语音样本,例如5秒,10秒,15秒,30秒,40秒,80秒. 并且还提到了IdentificationProfileIds应该作为字符串(操作方法)
I tried various voice samples with different sizes like 5-Second, 10-Second, 15-Second, 30-Second, 40-Seconds, 80-Seconds. And also mentioned identificationProfileIds should be as strings (How to do that)
对于音频录制,我使用的是$ rec -c 1 -r 16000 -b 16 xa.wav
但是仍然遇到相同的错误,我希望代码中可能存在一些问题. 请帮我 如果您可以为我提供说话者识别码> ,它将非常有帮助
But still getting the same errors I hope there might be some problem in my code. Please Help me If you can provide me the code for Speaker - Identification it will be so much helpful
import http.client, urllib.request, urllib.parse, urllib.error, base64
subscription_key = 'XXXXXXXXXXXXXXXXXXXX'
headers = {
# Request headers
'Content-Type': 'multipart/form-data',
'Ocp-Apim-Subscription-Key': subscription_key,
}
params = urllib.parse.urlencode({
# Request parameters
# 'shortAudio': 'false',
"identificationProfileIds":"080d22d6-917e-487f-a553-fb13a0575067",
})
try:
conn = http.client.HTTPSConnection('speaker-recognition-api.cognitiveservices.azure.com')
body = open('xa.wav','rb')
#aud = base64.b64encode(body.read())
print(body)
conn.request("POST", "/spid/v1.0/identify?identificationProfileIds=080d22d6-917e-487f-a553-fb13a0575067&%s" % params, body, headers)
response = conn.getresponse()
print(response)
data = response.read()
print(data)
conn.close()
except Exception as e:
print("[Errno {0}] {1}".format(e.errno, e.strerror))
推荐答案
您可以从此处开始尝试使用说话者识别" Python示例应用程序,然后从那里开始工作,您可以在Microsoft的GitHub上找到该应用程序
You can try using the Speaker Recognition Python sample app as start and work from there, which you can find publicly available on GitHub by Microsoft here
You'll have to set your values in place in the respective files and particularly look for IdentifyFile.py
import IdentificationServiceHttpClientHelper
import sys
def identify_file(subscription_key, file_path, force_short_audio, profile_ids):
"""Identify an audio file on the server.
Arguments:
subscription_key -- the subscription key string
file_path -- the audio file path for identification
profile_ids -- an array of test profile IDs strings
force_short_audio -- waive the recommended minimum audio limit needed for enrollment
"""
helper = IdentificationServiceHttpClientHelper.IdentificationServiceHttpClientHelper(
subscription_key)
identification_response = helper.identify_file(
file_path, profile_ids,
force_short_audio.lower() == "true")
print('Identified Speaker = {0}'.format(identification_response.get_identified_profile_id()))
print('Confidence = {0}'.format(identification_response.get_confidence()))
if __name__ == "__main__":
if len(sys.argv) < 5:
print('Usage: python IdentifyFile.py <subscription_key> <identification_file_path>'
' <profile_ids>...')
print('\t<subscription_key> is the subscription key for the service')
print('\t<identification_file_path> is the audio file path for identification')
print('\t<force_short_audio> True/False waives the recommended minimum audio limit needed '
'for enrollment')
print('\t<profile_ids> the profile IDs for the profiles to identify the audio from.')
sys.exit('Error: Incorrect Usage.')
identify_file(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4:])
这篇关于Microsoft认知服务-说话者识别API-识别-错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!