

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 在批次轉錄中啟用發言者分隔
<a name="conversation-diarization-batch-med"></a>

您可以在批次轉錄作業中使用 [https://docs.aws.amazon.com/transcribe/latest/APIReference/API_StartMedicalTranscriptionJob.html](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_StartMedicalTranscriptionJob.html) API 或 AWS 管理主控台。這讓您可以在臨床醫生和患者對話中，進行每個發言者的分隔，並確定在轉錄輸出中發言者說的內容。

## AWS 管理主控台
<a name="conversation-diarization-batch-med-console"></a>

若要使用 AWS 管理主控台 在轉錄任務中啟用發言者日記，您可以啟用音訊識別，然後啟用發言者分割。

1. 登入 [AWS 管理主控台](https://console.aws.amazon.com/transcribe/)。

1. 在導覽窗格的 Amazon Transcribe Medical 下，選擇**轉錄任務**。

1. 選擇**建立作業**。

1. 在**指定作業詳細資訊**頁面上，提供轉錄作業的相關資訊。

1. 選擇**下一步**。

1. 啟用**音訊識別**。

1. 對於**音訊識別類型**，請選擇**發言者分隔**。

1. 對於**最大發言者數量**，請輸入您認為在音訊檔案中說話的最大發言者數量。

1. 選擇**建立**。

## API
<a name="conversation-diarization-batch-med-api"></a>

**使用批次轉錄作業 (API) 啟用發言者分隔**
+ 對於 [https://docs.aws.amazon.com/transcribe/latest/APIReference/API_StartMedicalTranscriptionJob.html](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_StartMedicalTranscriptionJob.html) API，請指定以下項目。

  1. 對於 `MedicalTranscriptionJobName`，請指定在 AWS 帳戶中唯一的名稱。

  1. 對於 `LanguageCode`，請指定與音訊檔案中所說語言相對應的語言代碼。

  1. 對於 `Media` 物件的 `MediaFileUri` 參數中，指定您要轉錄的音訊檔案名稱。

  1. 對於 `Specialty`，請指定在音訊檔案中說話的臨床醫生的醫療專科。

  1. 對於 `Type`，請指定 `CONVERSATION`。

  1. 對於 `OutputBucketName`，指定儲存 Amazon S3 貯體以存放轉錄結果。

  1. 對於 `Settings` 物件，請指定下列項目：

     1. `ShowSpeakerLabels` – `true`.

     1. `MaxSpeakerLabels`— 介於 2 和 10 之間的整數，表示您認為在音訊中說話的發言者數量。

下列請求使用 適用於 Python (Boto3) 的 AWS SDK 啟動已啟用發言者分割之主要照護臨床醫生患者對話的批次轉錄任務。

```
from __future__ import print_function
import time
import boto3
transcribe = boto3.client('transcribe', 'us-west-2')
job_name = "my-first-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 = 'my-output-files/', 
    LanguageCode = 'en-US',
    Specialty = 'PRIMARYCARE',
    Type = 'CONVERSATION',
    OutputBucketName = 'amzn-s3-demo-bucket',
Settings = {'ShowSpeakerLabels': True,
         'MaxSpeakerLabels': 2
         }
         )
while True:
    status = transcribe.get_medical_transcription_job(MedicalTranscriptionJobName = job_name)
    if status['MedicalTranscriptionJob']['TranscriptionJobStatus'] in ['COMPLETED', 'FAILED']:
        break
    print("Not ready yet...")
    time.sleep(5)
print(status)
```

下列範例程式碼示範啟用發言者分隔的轉錄作業的轉錄結果。

```
{
    "jobName": "job ID",
    "accountId": "111122223333",
    "results": {
        "transcripts": [
            {
                "transcript": "Professional answer."
            }
        ],
        "speaker_labels": {
            "speakers": 1,
            "segments": [
                {
                    "start_time": "0.000000",
                    "speaker_label": "spk_0",
                    "end_time": "1.430",
                    "items": [
                        {
                            "start_time": "0.100",
                            "speaker_label": "spk_0",
                            "end_time": "0.690"
                        },
                        {
                            "start_time": "0.690",
                            "speaker_label": "spk_0",
                            "end_time": "1.210"
                        }
                    ]
                }
            ]
        },
        "items": [
            {
                "start_time": "0.100",
                "end_time": "0.690",
                "alternatives": [
                    {
                        "confidence": "0.8162",
                        "content": "Professional"
                    }
                ],
                "type": "pronunciation"
            },
            {
                "start_time": "0.690",
                "end_time": "1.210",
                "alternatives": [
                    {
                        "confidence": "0.9939",
                        "content": "answer"
                    }
                ],
                "type": "pronunciation"
            },
            {
                "alternatives": [
                    {
                        "content": "."
                    }
                ],
                "type": "punctuation"
            }
        ]
    },
    "status": "COMPLETED"
}
```

## AWS CLI
<a name="diarization-batch-cli"></a>

**轉錄執行初級護理的臨床醫生與患者對話的音訊檔案 (AWS CLI)**
+ 執行下列程式碼。

  ```
                      
  aws transcribe start-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":{
            "ShowSpeakerLabels": true,
            "MaxSpeakerLabels": 2
          }
  }
  ```