

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 使用文本文件创建医学自定义词汇表
<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 医疗控制台创建自定义词汇表。

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

要使用创建自定义词汇，您需要提供包含您的单词或短语的文本文件的 Amazon S3 URI。 AWS 管理控制台 

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

1. 在导航窗格的 “ Amazon Transcribe 医疗” 下，选择 “**自定义词汇**”。

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
  ```