在我的应用程序中,我需要记录人与人之间的对话,而物理工作流程中没有空间对每个人的声音进行 20 秒的采样来训练识别器,也没有要求每个人读取预设的密码短语训练。但据我所知,如果不这样做,就无法识别说话者。
有没有什么方法可以只记录 5 个人的讲话,然后让识别器自动将返回的文本分类为属于 5 个不同的人之一,而无需事先进行训练?
(无论如何,IBM Watson 可以做到这一点,尽管在我的测试中它做得不太准确。)
Microsoft Conversation Transcription 处于预览状态,现在针对麦克风阵列设备。因此输入录音应该由麦克风阵列进行录制。如果您的录音来自普通麦克风,则可能无法正常工作,您需要特殊配置。您还可以尝试批量分类,它目前支持离线转录,分类2个说话者,很快就会支持2个以上说话者,可能在这个月。
如果您使用 REST API 那么它将很有帮助。 您可以使用“diarizationEnabled”属性为 true 的批量转录,您将只需要使用 1 个通道,并且您还需要提供最小和最大发言者数量(它最多可以识别 36 个发言者)。也使用 3.1 版本而不是 3.0 的 REST API
我是如何使用它的:
url = f'{<speech_resourse_endpoint>}/speechtotext/v3.0/transcriptions'
data = {
'displayName': 'name that you would like for transcription',
"description": "Description of your task",
'locale': 'en-US',
'contentUrls': [<audio_url>],
'properties': {
'diarizationEnabled': True,
'wordLevelTimestampsEnabled': True,
"displayFormWordLevelTimestampsEnabled": True,
"channels": [0],
"diarization": {
"speakers": {
"minCount": 1,
"maxCount": 20
}
}
},
"languageIdentification": {
"candidateLocales": ["en-US","en-CA"],
},
"customProperties": {}
}
# intializer of transcription process
response = requests.post(url, headers=headers, json=data)
# Get the URL of the transcription status and output files
self_url = response.json()['self']
print(self_url)
files_url = response.json()['links']['files']
status = ""
while status != "Succeeded":
# Send a GET request to get the transcription status
response = requests.get(self_url, headers=headers)
status = response.json()['status']
print(f"Transcription status: {status}")
time.sleep(2)
#request to access list of files
response = requests.get(files_url, headers=headers)
response_json = response.json()
file_url = response_json["values"][0]["links"]["contentUrl"]
print(f"file_url = {file_url}")
转到打印的“file_url”,在名为“recognizedPhrases”的字段中,您将看到已识别说话者的短语
示例输出:
{
"source": "-----",
"timestamp": "2023-10-16T18:13:54Z",
"durationInTicks": 4697600000,
"duration": "PT7M49.76S",
"combinedRecognizedPhrases": [
{
"channel": 0,
"lexical": "....whole transcription....",
"itn": ".....whole transcription....",
"display": ".....whole transcription...."
}
],
"recognizedPhrases": [
{
"recognitionStatus": "Success",
"channel": 0,
"speaker": 1,
"offset": "PT0.72S",
"duration": "PT19.28S",
"offsetInTicks": 7200000.0,
"durationInTicks": 192800000.0,
"nBest": [
{
"confidence": 0.27163595,
"lexical": "----phrash----",
"itn": "-----phrase---",
"maskedITN": "-----phrase----",
"display": "-----phrase----"
},...]