本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
轉錄多聲道音訊
如果您的音訊檔案或串流具有多個頻道,您可以使用頻道識別來轉錄來自每個頻道的語音。 Amazon Transcribe Medical 會分別轉錄來自每個頻道的語音。它將每個聲道的獨立轉錄與單一轉錄輸出結合。
使用聲道識別以識別音訊中不同的聲道,並從每個聲道轉錄語音。在通話者和客服人員案例等情況下啟用此功能。使用此功能可區分通話者與執行藥物安全監控的聯絡中心的錄音或串流中的客服人員。
您可以為批次處理和即時串流,啟用聲道識別。下列清單描述如何為每個方法啟用。
-
批次轉錄 – AWS Management Console 和
StartMedicalTranscriptionJob
API -
串流轉錄 — WebSocket 串流和
StartMedicalStreamTranscription
API
轉錄多聲道音訊檔案
當您轉錄音訊檔案時, Amazon Transcribe Medical 會傳回每個頻道的項目清單。項目是轉錄的單字或標點符號。每個單字都有開始時間和結束時間。如果聲道上的使用者與不同聲道上的某個人說話,則每個聲道項目的開始時間和結束時間會重疊,且個人彼此交談時間也會重疊。
依預設,您可以轉錄有兩個聲道的音訊檔案。如果您需要轉錄有兩個以上聲道的檔案,可以要求提高配額。如需請求提高配額的詳細資訊,請參閱 AWS 服務 配額。
若要在批次轉錄任務中轉錄多聲道音訊,請使用 AWS Management Console 或 StartMedicalTranscriptionJob
API。
若要使用 AWS Management Console 在批次轉錄任務中啟用頻道識別,您可以啟用音訊識別,然後啟用頻道識別。頻道識別是 中音訊識別的子集 AWS Management Console。
-
在導覽窗格的 Amazon Transcribe Medical 下,選擇轉錄任務。
-
選擇建立作業。
-
在指定作業詳細資訊頁面上,提供轉錄作業的相關資訊。
-
選擇下一步。
-
啟用音訊識別。
-
對於音訊識別類型,請選擇聲道識別。
-
選擇建立。
轉錄多聲道音訊檔案 (API)
-
對於
StartMedicalTranscriptionJob
API,請指定以下項目。-
對於
TranscriptionJobName
,指定 AWS 帳戶的唯一名稱。 -
對於
LanguageCode
,請指定與音訊檔案中所說語言相對應的語言代碼。有效值為en-US
。 -
對於
Media
物件的MediaFileUri
參數,指定您要轉錄的媒體檔案名稱。 -
對於
Settings
物件,設定ChannelIdentification
為true
。
-
以下是使用 AWS SDK for Python (Boto3)的範例請求。
from __future__ import print_function import time import boto3 transcribe = boto3.client('transcribe', '
us-west-2
') job_name = "my-first-transcription-job
" job_name = "my-first-med-transcription-job
" job_uri = "s3://amzn-s3-demo-bucket
/my-input-files
/my-media-file
.flac
" transcribe.start_medical_transcription_job( MedicalTranscriptionJobName = job_name, Media = { 'MediaFileUri': job_uri }, OutputBucketName = 'amzn-s3-demo-bucket
', OutputKey = 'output-files
/', LanguageCode = 'en-US', Specialty = 'PRIMARYCARE', Type = 'CONVERSATION', Settings = { 'ChannelIdentification': True } ) while True: status = transcribe.get_transcription_job(MedicalTranscriptionJobName = job_name) if status['MedicalTranscriptionJob']['TranscriptionJobStatus'] in ['COMPLETED', 'FAILED']: break print("Not ready yet...") time.sleep(5) print(status)
使用批次轉錄作業轉錄多聲道音訊檔案 (AWS CLI)
-
執行下列程式碼。
aws transcribe start-medical-transcription-job \ --region
us-west-2
\ --cli-input-json file://example-start-command
.json以下是
example-start-command.json
的程式碼。{ "MedicalTranscriptionJobName": "
my-first-med-transcription-job
", "Media": { "MediaFileUri": "s3://amzn-s3-demo-bucket
/my-input-files
/my-audio-file
.flac
" }, "OutputBucketName": "amzn-s3-demo-bucket
", "OutputKey": "my-output-files
/", "LanguageCode": "en-US", "Specialty": "PRIMARYCARE", "Type": "CONVERSATION", "Settings":{ "ChannelIdentification": true } }
下列程式碼示範在兩個聲道有對話的音訊檔案的轉錄輸出。
{
"jobName": "job id
",
"accountId": "111122223333",
"results": {
"transcripts": [
{
"transcript": "When you try ... It seems to ..."
}
],
"channel_labels": {
"channels": [
{
"channel_label": "ch_0",
"items": [
{
"start_time": "12.282",
"end_time": "12.592",
"alternatives": [
{
"confidence": "1.0000",
"content": "When"
}
],
"type": "pronunciation"
},
{
"start_time": "12.592",
"end_time": "12.692",
"alternatives": [
{
"confidence": "0.8787",
"content": "you"
}
],
"type": "pronunciation"
},
{
"start_time": "12.702",
"end_time": "13.252",
"alternatives": [
{
"confidence": "0.8318",
"content": "try"
}
],
"type": "pronunciation"
},
...
]
},
{
"channel_label": "ch_1",
"items": [
{
"start_time": "12.379",
"end_time": "12.589",
"alternatives": [
{
"confidence": "0.5645",
"content": "It"
}
],
"type": "pronunciation"
},
{
"start_time": "12.599",
"end_time": "12.659",
"alternatives": [
{
"confidence": "0.2907",
"content": "seems"
}
],
"type": "pronunciation"
},
{
"start_time": "12.669",
"end_time": "13.029",
"alternatives": [
{
"confidence": "0.2497",
"content": "to"
}
],
"type": "pronunciation"
},
...
]
}
}
轉錄多聲道音訊串流
您可以使用 StartMedicalStreamTranscription
API 從 HTTP/2 或 WebSocket 串流中的不同聲道轉錄音訊。
依預設,您可以使用兩個聲道轉錄串流。如果您需要轉錄有兩個以上聲道的串流,可以要求提高配額。如需請求提高配額的詳細資訊,請參閱 AWS Service Quotas。
在 HTTP/2 串流中轉錄多聲道音訊
若要轉錄 HTTP/2 串流中的多聲道音訊,請使用 StartMedicalStreamTranscription API 並指定下列項目:
-
LanguageCode
— 音訊的語言代碼。有效值為en-US
。 -
MediaEncoding
— 音訊的編碼。有效值為ogg-opus
、flac
和pcm
。 -
EnableChannelIdentification
–true
-
NumberOfChannels
— 您串流音訊中聲道的數量。
如需設定 HTTP/2 串流以轉錄醫療對話的詳細資訊,請參閱 設定 HTTP/2 串流。
轉錄 WebSocket 串流中的多聲道音訊
若要分隔 WebSocket 串流中的發言者,請使用下列格式以建立預先簽署的 URI 並開始 WebSocket 請求。指定 enable-channel-identification
為 true
和 number-of-channels
串流中的聲道數量。預先簽章的 URI 包含設定應用程式與 Amazon Transcribe Medical 之間的雙向通訊所需的資訊。
GET wss://transcribestreaming.
us-west-2
.amazonaws.com:8443/medical-stream-transcription-websocket ?language-code=languageCode
&X-Amz-Algorithm=AWS4-HMAC-SHA256 &X-Amz-Credential=AKIAIOSFODNN7EXAMPLE
%2F20220208
%2Fus-west-2
%2Ftranscribe
%2Faws4_request &X-Amz-Date=20220208T235959Z
&X-Amz-Expires=300
&X-Amz-Security-Token=security-token
&X-Amz-Signature=Signature Version 4 signature
&X-Amz-SignedHeaders=host &media-encoding=flac
&sample-rate=16000
&session-id=sessionId
&enable-channel-identification=true &number-of-channels=2
您可以在 API 參考中找到參數定義;所有 AWS API 操作常見的參數都列在通用參數區段中。
如需 WebSocket 請求的詳細資訊,請參閱 設定 WebSocket 串流。
多聲道串流輸出
對於 HTTP/2 和 WebSocket 請求,串流轉錄的輸出相同。以下為範例輸出。
{ "resultId": "XXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXX", "startTime": 0.11, "endTime": 0.66, "isPartial": false, "alternatives": [ { "transcript": "Left.", "items": [ { "startTime": 0.11, "endTime": 0.45, "type": "pronunciation", "content": "Left", "vocabularyFilterMatch": false }, { "startTime": 0.45, "endTime": 0.45, "type": "punctuation", "content": ".", "vocabularyFilterMatch": false } ] } ], "channelId": "ch_0" }
對於每個語音區段,都有一個 channelId
標記,指出該語音所屬的聲道。