

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

# 为实时转录创建类别
<a name="tca-categories-stream"></a>

实时呼叫分析支持创建自定义类别，使您能够量身定制转录分析，以便于极大程度地满足您的特定业务需求。

您可以根据需要创建任意数量的类别，以囊括一系列不同的场景。对于您创建的每个类别，必须创建 1 到 20 条规则。实时呼叫分析转录仅支持使用 [https://docs.aws.amazon.com/transcribe/latest/APIReference/API_TranscriptFilter.html](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_TranscriptFilter.html)（关键字匹配）的规则。有关在 [https://docs.aws.amazon.com/transcribe/latest/APIReference/API_CreateCallAnalyticsCategory.html](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_CreateCallAnalyticsCategory.html) 操作中使用规则的更多详细信息，请参阅[实时呼叫分析类别的规则标准](#tca-rules-stream)一节。

如果您的媒体内容符合您在给定类别中指定的所有规则，则 Amazon Transcribe 会使用该类别标记您的输出。有关采用 JSON 输出格式的类别匹配示例，请参阅[类别事件输出](tca-output-streaming.md#tca-output-category-event-stream)。

以下是一些关于如何使用自定义类别的示例：
+ 通过标记和跟踪特定的一组关键字，找出需要立即关注的问题
+ 监控合规性，例如座席说出（或省略）特定短语
+ 实时标记特定的单词和短语；然后，您可以设置类别匹配以设置即时警报。例如，如果您为提出“*要与经理交谈*”的客户创建了实时呼叫分析类别，则可以为该实时类别匹配设置[事件警报](tca-start-stream.md#tca-create-alert-stream)，通知值班经理。

**通话后类别与实时类别**

创建新类别时，您可以指定是要将其创建为通话后类别 (`POST_CALL`)，还是创建为实时类别 (`REAL_TIME`)。如果您没有指定选项，则默认情况下，您的类别将创建为通话后类别。实时类别匹配可用于创建实时警报。有关更多信息，请参阅 [为类别匹配创建实时警报](tca-start-stream.md#tca-create-alert-stream)。

要为实时呼叫分析创建新类别，您可以使用**AWS 管理控制台**AWS CLI****、或 **AWS SDKs**；有关示例，请参阅以下内容：

## AWS 管理控制台
<a name="tca-category-console"></a>

1. 在导航窗格的下方 Amazon Transcribe，选择**Amazon Transcribe 呼叫分析**。

1. 选择**呼叫分析类别**，之后您将进入**呼叫分析类别**页面。选择**创建类别**按钮。  
![\[Amazon Transcribe 控制台屏幕截图：呼叫分析 “类别” 页面。\]](http://docs.aws.amazon.com/zh_cn/transcribe/latest/dg/images/analytics-categories.png)

1. 您现在已进入**创建类别页面**。输入类别的名称，然后在**类别类型**下拉菜单中选择“实时呼叫分析”。  
![\[Amazon Transcribe 控制台屏幕截图：“类别设置” 面板。\]](http://docs.aws.amazon.com/zh_cn/transcribe/latest/dg/images/analytics-categories-type.png)

1. 您可以选择一个模板来创建您的类别，也可以从头开始制作一个模板。

   如果使用模板：选择**使用模板(建议)**，选择所需的模板，然后选择**创建类别**。  
![\[Amazon Transcribe 控制台屏幕截图：显示可选模板的 “类别设置” 面板。\]](http://docs.aws.amazon.com/zh_cn/transcribe/latest/dg/images/analytics-categories-settings-stream.png)

1. 如果要创建自定义类别：请选择**从头开始创建**。  
![\[Amazon Transcribe 控制台屏幕截图：显示 “规则” 窗格的 “创建类别” 页面。\]](http://docs.aws.amazon.com/zh_cn/transcribe/latest/dg/images/analytics-categories-custom.png)

1. 使用下拉菜单向您的类别添加规则。您最多可以为每个类别添加 20 条规则。对于实时呼叫分析转录，您只能包含涉及转录内容匹配的规则。任何匹配项都会实时标记。  
![\[Amazon Transcribe 控制台屏幕截图：带有规则类型列表的 “规则” 窗格。\]](http://docs.aws.amazon.com/zh_cn/transcribe/latest/dg/images/analytics-categories-custom-rules-stream.png)

1. 此处介绍了使用以下规则的类别示例：客户在通话中的任何时候提出“要与经理交谈”。  
![\[Amazon Transcribe 控制台屏幕截图：带有逻辑选项的 “规则” 窗格。\]](http://docs.aws.amazon.com/zh_cn/transcribe/latest/dg/images/analytics-categories-custom-rules-stream2.png)

1. 向类别添加完规则后，选择**创建类别**。

## AWS CLI
<a name="tca-category-cli-stream"></a>

此示例使用[create-call-analytics-category](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/transcribe/create-call-analytics-category.html)命令。有关更多信息，请参阅 [https://docs.aws.amazon.com/transcribe/latest/APIReference/API_CreateCallAnalyticsCategory.html](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_CreateCallAnalyticsCategory.html)、[https://docs.aws.amazon.com/transcribe/latest/APIReference/API_CategoryProperties.html](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_CategoryProperties.html) 和 [https://docs.aws.amazon.com/transcribe/latest/APIReference/API_Rule.html](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_Rule.html)。

下面的示例创建了使用以下规则的类别：
+ 客户在通话中的任何时候提到“要与经理交谈”这句话。

此示例使用[create-call-analytics-category](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/transcribe/create-call-analytics-category.html)命令和请求正文将规则添加到您的类别中。

```
aws transcribe create-call-analytics-category \
--cli-input-json file://filepath/my-first-analytics-category.json
```

*my-first-analytics-category.json* 文件包含以下请求正文。

```
{
  "CategoryName": "my-new-real-time-category",
  "InputType": "REAL_TIME",
  "Rules": [
        {
            "TranscriptFilter": {
                "Negate": false,
                "Targets": [
                    "speak to the manager"
                ],
                "TranscriptFilterType": "EXACT"
            }
        }
    ]
}
```

## 适用于 Python (Boto3) 的 AWS SDK
<a name="tca-category-python-stream"></a>

此示例使用 create\$1call\$1an [alytics\$1category 方法的`CategoryName`和`Rules`参数创建](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/transcribe.html#TranscribeService.Client.create_call_analytics_category)类别。 适用于 Python (Boto3) 的 AWS SDK 有关更多信息，请参阅 [https://docs.aws.amazon.com/transcribe/latest/APIReference/API_CreateCallAnalyticsCategory.html](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_CreateCallAnalyticsCategory.html)、[https://docs.aws.amazon.com/transcribe/latest/APIReference/API_CategoryProperties.html](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_CategoryProperties.html) 和 [https://docs.aws.amazon.com/transcribe/latest/APIReference/API_Rule.html](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_Rule.html)。

有关使用的其他示例 AWS SDKs，包括特定功能、场景和跨服务示例，请参阅本章。[使用 Amazon Transcribe 的代码示例 AWS SDKs](service_code_examples.md)

下面的示例创建了使用以下规则的类别：
+ 客户在通话中的任何时候提到“要与经理交谈”这句话。

```
from __future__ import print_function
import time
import boto3
transcribe = boto3.client('transcribe', 'us-west-2')
category_name = "my-new-real-time-category"
transcribe.create_call_analytics_category(
    CategoryName = category_name,
    InputType = "REAL_TIME",
    Rules = [
        {
            'TranscriptFilter': {
                'Negate': False,
                'Targets': [
                    'speak to the manager'                    
                ],
                'TranscriptFilterType': 'EXACT'
            }
        }
    ]
)

result = transcribe.get_call_analytics_category(CategoryName = category_name)    
print(result)
```

## 实时呼叫分析类别的规则标准
<a name="tca-rules-stream"></a>

本节概述了您可以使用 [https://docs.aws.amazon.com/transcribe/latest/APIReference/API_CreateCallAnalyticsCategory.html](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_CreateCallAnalyticsCategory.html) API 操作创建的自定义 `REAL_TIME` 规则的类型。

问题检测会自动进行，因此您无需创建任何规则或类别来标记问题。

请注意，实时呼叫分析转录仅支持关键字匹配。如果要创建包含中断、沉默或情绪的类别，请参阅[通话后分析类别的规则标准](tca-categories-batch.md#tca-rules-batch)。

### 关键字匹配
<a name="tca-rules-keywords-stream"></a>

使用关键字（[https://docs.aws.amazon.com/transcribe/latest/APIReference/API_TranscriptFilter.html](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_TranscriptFilter.html) 数据类型）的规则旨在匹配：
+ 座席、客户或两者都说了的自定义单词或短语
+ 座席、客户或两者都**没说**的自定义单词或短语
+ 在特定时间范围内出现的自定义单词或短语

以下是 [https://docs.aws.amazon.com/transcribe/latest/APIReference/API_TranscriptFilter.html](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_TranscriptFilter.html) 可用参数的示例：

```
"TranscriptFilter": { 
    "AbsoluteTimeRange": { 
       Specify the time frame, in milliseconds, when the match should occur
    },
    "RelativeTimeRange": { 
       Specify the time frame, in percentage, when the match should occur
    },
    "Negate": Specify if you want to match the presence or absence of your custom keywords,
    "ParticipantRole": Specify if you want to match speech from the agent, the customer, or both,
    "Targets": [ The custom words and phrases you want to match ],
    "TranscriptFilterType": Use this parameter to specify an exact match for the specified targets
}
```

有关这些参数以及与每个参数关联的有效值的更多信息，请参阅 [https://docs.aws.amazon.com/transcribe/latest/APIReference/API_CreateCallAnalyticsCategory.html](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_CreateCallAnalyticsCategory.html) 和 [https://docs.aws.amazon.com/transcribe/latest/APIReference/API_TranscriptFilter.html](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_TranscriptFilter.html)。