

기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.

# 배치 트랜스크립션에서 화자 파티셔닝 활성화
<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 Management Console을 사용하여 배치 트랜스크립션 작업을 활성화할 수 있습니다. 이를 통해 의사와 환자의 대화에서 화자별로 텍스트를 분할하고 트랜스크립션 출력에서 누가 무슨 말을 했는지 확인할 수 있습니다.

## AWS Management Console
<a name="conversation-diarization-batch-med-console"></a>

 AWS Management Console 를 사용하여 트랜스크립션 작업에서 화자 분할을 활성화하려면 오디오 식별을 활성화한 다음 화자 파티셔닝을 활성화합니다.

1. [AWS Management Console](https://console.aws.amazon.com/transcribe/)에 로그인합니다.

1. 탐색 창의 Amazon Transcribe Medical에서 **트랜스크립션 작업을** 선택합니다.

1. **작업 생성**을 선택합니다.

1. **작업 세부 정보 지정** 페이지에서 트랜스크립션 작업에 대한 정보를 제공합니다.

1. **다음**을 선택합니다.

1. **오디오 식별**을 활성화합니다.

1. **오디오 식별 유형**에서 **화자 파티셔닝**을 선택합니다.

1. **최대 화자 수**에는 오디오 파일에서 말하고 있다고 생각되는 최대 화자 수를 입력합니다.

1. **생성(Create)**을 선택합니다.

## 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. 에서 트랜스크립션 결과를 저장할 Amazon S3 버킷을 `OutputBucketName`지정합니다.

  1. `Settings` 객체에서 다음을 지정합니다.

     1. `ShowSpeakerLabels` – `true`.

     1. `MaxSpeakerLabels` - 오디오에서 말하는 것으로 생각되는 화자의 수를 나타내는 2에서 10 사이의 정수.

다음 요청은 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_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>

**1차 의료를 담당하는 임상의와 환자 간의 대화를 녹음한 오디오 파일을 트랜스크립션하려면(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
          }
  }
  ```