You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Azure文本无关说话人识别注册报错‘Activation Phrase未匹配’求助

问题:Azure文本无关说话人识别注册时出现"Activation Phrase is not matched"错误

我希望使用Azure Speech to Text实现说话人识别功能,已成功执行CreateProfile.py代码创建识别Profile,但在运行CreateEnrollment.py将语音数据注册至该Profile时,收到400错误响应,错误信息为:

{'code': 'InvalidRequest', 'message': 'Activation Phrase is not matched'}

根据官方文档说明,文本无关的说话人识别无需使用激活短语(Activation Phrase)。现将相关代码附上,请问文本无关说话人识别是否确实需要激活短语,或是我的代码存在问题?


CreateProfile.py

########### module #############
import sys                  
import requests             
import json                 
import base64
import csv

########### Args & variable #########################
args = sys.argv
Profile_Name = args[1]
Profile_List = 'app/Profile_List.csv'

########### Create Profile #########################
with open(Profile_List) as fp:
    lst = list(csv.reader(fp))

for i in lst:
    if Profile_Name in i:
        print('The specified user is already registered.')
        sys.exit()

ApiPath = 'https://eastasia.api.cognitive.microsoft.com/speaker-recognition/identification/text-independent/profiles?api-version=2021-09-05'


headers = {
    # Request headers
    'Content-Type': 'application/json',
    'Ocp-Apim-Subscription-Key': 'XXXXXXXXXXXXXXXXXXXXXXXXXXX',
}

body = {
    'locale':'ja-JP',
}

r = requests.post(
    ApiPath,            
    headers = headers,  
    json = body         
)

try:
    ProfileId = r.json()['profileId']
except Exception:
    print('Error:{}'.format(r.status_code))
    print(r.json())
    sys.exit()

print(ProfileId)

f = open(Profile_List, 'a')
writer = csv.writer(f, lineterminator='\n')
writer.writerow([Profile_Name, ProfileId])

CreateEnrollment.py

########### module #############
import sys                  
import requests             
import json                 
import base64
import csv
import time

########### Args & variable #########################
args = sys.argv
Profile_Name = args[1]
Profile_List = 'app/Profile_List.csv'
WavFile = f'app/{Profile_Name}.wav'

with open(Profile_List) as fp:
    lst = list(csv.reader(fp))

for i in lst:
    if Profile_Name in i:
        break

j = lst.index(i)
ProfileId = lst[j][1]

########### Create Enrollment #########################
ApiPath = f'https://eastasia.api.cognitive.microsoft.com/speaker-recognition/identification/text-independent/profiles/{ProfileId}/enrollments?api-version=2021-09-05'

headers = {
    # Request headers
    'Content-Type': 'application/octet-stream',
    'Ocp-Apim-Subscription-Key': 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
}

with open(WavFile, 'rb') as f:
    body = f.read()

r = requests.post(
    ApiPath,            # URL
    headers = headers,  # ヘッダー
    data = body         # ボディ
)

print(ProfileId)

try:
    response = r
    print('response:', response.status_code)
    if response.status_code == 202:
        print(response.headers['Operation-Location'])
        operation_url = response.headers['Operation-Location']
    else:
        print(response.json()['error'])
        sys.exit()
except Exception:
    print(r.json()['error'])
    sys.exit()
####################################
########### Get Operation Status #########################
url = operation_url

headers = {
    # Request headers
    'Ocp-Apim-Subscription-Key': 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
}

status = ''
while status != 'succeeded':

    r = requests.get(
        url,            # URL
        headers = headers,  # ヘッダー
    )

    try:
        response = r
        print('response:', response.status_code)
        if response.status_code == 200:
            status = response.json()['status']
            print(f'現在の状態;{status}')
            if status == 'failed':
                message = response.json()['message']
                print(f'error:{message}')
                sys.exit()
            elif status != 'succeeded':
                time.sleep(3)
        else:
            print(r.json()['error'])
            sys.exit()
    except Exception:
        print(r.json()['error'])
        sys.exit()

enrollmentStatus = response.json()['processingResult']['enrollmentStatus']
remainingEnrollmentSpeechTime = response.json()['processingResult']['remainingEnrollmentSpeechTime']
speechTime = response.json()['processingResult']['speechTime']

内容的提问来源于stack exchange,提问作者midorikawa iru

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.28 11:05:54