

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

# 使用文字檔案建立醫學自訂詞彙
<a name="create-med-custom-vocabulary"></a>

若要建立自訂詞彙，您必須備妥文字檔案，其中包含字詞或片語的集合。 Amazon Transcribe Medical 使用此文字檔案來建立自訂詞彙，您可以用來改善這些字詞或片語的轉錄準確性。您可以使用 [https://docs.aws.amazon.com/transcribe/latest/APIReference/API_CreateMedicalVocabulary.html](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_CreateMedicalVocabulary.html) API 或 Amazon Transcribe Medical 主控台建立自訂詞彙。

## AWS 管理主控台
<a name="create-med-custom-vocab-console"></a>

若要使用 AWS 管理主控台 建立自訂詞彙，請提供文字檔案的 Amazon S3 URI，其中包含您的單字或片語。

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

1. 在導覽窗格的 Amazon Transcribe Medical 下，選擇**自訂詞彙**。

1. 對於**詞彙設定**下的**名稱**，選擇自訂詞彙的名稱。

1. 在 Amazon S3中指定音訊檔案或影片檔案的位置：
   + 對於**詞彙設定**下的 **S3 詞彙輸入檔案位置**，指定 Amazon S3 URI，識別用於建立自訂詞彙之文字檔案。
   + 對於 **S3 中的詞彙輸入檔案位置**，選擇**瀏覽 S3** 以瀏覽文字檔案並選擇。

1. 選擇**建立詞彙**。

您可以在 AWS 管理主控台中查看自訂詞彙的處理狀態。

## API
<a name="create-med-custom-vocab-api"></a>

**建立醫療自訂詞彙 (API)**
+ 對於 [https://docs.aws.amazon.com/transcribe/latest/APIReference/API_StartTranscriptionJob.html](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_StartTranscriptionJob.html) API，請指定以下項目。

  1. 對於 `LanguageCode`，請指定 `en-US`。

  1. 針對 `VocabularyFileUri`，指定您用來定義自訂詞彙的文字檔案 Amazon S3 位置。

  1. 對於 `VocabularyName`，指定自訂詞彙的名稱。您指定的名稱在 中必須是唯一的 AWS 帳戶。

若要查看自訂詞彙的處理狀態，使用 [https://docs.aws.amazon.com/transcribe/latest/APIReference/API_GetMedicalVocabulary.html](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_GetMedicalVocabulary.html) API。

以下是使用 適用於 Python (Boto3) 的 AWS SDK 建立自訂詞彙的範例請求。

```
from __future__ import print_function
import time
import boto3  
transcribe = boto3.client('transcribe', 'us-west-2')
vocab_name = "my-first-vocabulary"
response = transcribe.create_medical_vocabulary(
    VocabularyName = job_name,
    VocabularyFileUri = 's3://amzn-s3-demo-bucket/my-vocabularies/my-vocabulary-table.txt'
    LanguageCode = 'en-US',
  )
  
while True:
    status = transcribe.get_medical_vocabulary(VocabularyName = vocab_name)
    if status['VocabularyState'] in ['READY', 'FAILED']:
        break
    print("Not ready yet...")
    time.sleep(5)
print(status)
```

## AWS CLI
<a name="create-med-custom-vocab-cli"></a>

**在批次轉錄作業中啟用發言者分隔 (AWS CLI)**
+ 執行下列程式碼。

  ```
  aws transcribe create-medical-vocabulary \
  --vocabulary-name my-first-vocabulary \ 
  --vocabulary-file-uri s3://amzn-s3-demo-bucket/my-vocabularies/my-vocabulary-file.txt \
  --language-code en-US
  ```