【问题标题】:Microsoft Cognitive Services - Speaker Recognition API - Identification - errorMicrosoft 认知服务 - 说话人识别 API - 识别 - 错误
【发布时间】:2020-06-16 21:57:06
【问题描述】:

在这个API中我已经成功创建了Identification Profile,也成功创建了注册并检查了操作状态,收到成功注册。

现在我正在尝试识别说话者,但我得到了 一个错误 : b'{"error":{"code":"BadRequest","message":"Audio too long"}}' b'{"error":{"code":"BadRequest","message":"音频太短"}}'

我尝试了各种不同大小的语音样本,例如 5-Second、10-Second、15-Second、30-Second、40-Second、80-Second。 还提到了 IdentificationProfileIds 应该是字符串(如何做)

对于录音,我使用的是 $rec -c 1 -r 16000 -b 16 xa.wav

但仍然出现相同的错误,我希望我的代码中可能存在一些问题。 请帮我 如果您能提供演讲者 - 识别代码,那将非常有帮助

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-cognitive voice-recognition azure-cognitive-services


    【解决方案1】:

    您可以尝试使用 Speaker Recognition Python 示例应用程序作为开始并从那里开始工作,您可以在 GitHub 上通过 Microsoft here 公开获取该应用程序

    你必须在各自的文件中设置你的值,特别是寻找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:])
    

    【讨论】:

      猜你喜欢
      • 2020-06-13
      • 1970-01-01
      • 2017-06-08
      • 2021-06-19
      • 1970-01-01
      • 2018-11-27
      • 1970-01-01
      • 1970-01-01
      • 2020-09-02
      相关资源
      最近更新 更多