

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

# 为通话后转录创建类别
<a name="tca-categories-batch"></a>

通话后分析支持创建自定义类别，使您能够自定义转录分析，以便于极大程度地满足您的特定业务需求。

您可以根据需要创建任意数量的类别，以囊括一系列不同的场景。对于您创建的每个类别，必须创建 1 到 20 条规则。每条规则都基于以下四个标准之一：中断、关键字、非通话时间或情绪。有关在 [https://docs.aws.amazon.com/transcribe/latest/APIReference/API_CreateCallAnalyticsCategory.html](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_CreateCallAnalyticsCategory.html) 操作中使用这些条件的更多详细信息，请参阅[通话后分析类别的规则标准](#tca-rules-batch)一节。

如果您的媒体内容符合您在给定类别中指定的所有规则，则 Amazon Transcribe 会使用该类别标记您的输出。有关 JSON 输出中类别匹配的示例，请参阅[呼叫分类输出](tca-output-batch.md#tca-output-categorization-batch)。

以下是一些关于如何使用自定义类别的示例：
+ 隔离具有特定特点的通话，例如以负面客户情绪结束的通话
+ 通过标记和跟踪特定的一组关键字来识别客户问题的动态
+ 监控合规性，例如座席在通话的最初几秒钟内说出（或省略）特定短语
+ 通过标记多次出现座席中断和负面客户情绪的通话，深入了解客户体验
+ 比较多个类别以衡量相关性，例如分析座席使用欢迎短语是否与积极的客户情绪相关

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

创建新类别时，您可以指定是要将其创建为通话后分析类别 (`POST_CALL`)，还是创建为实时呼叫分析类别 (`REAL_TIME`)。如果您没有指定选项，则默认情况下，您的类别将创建为通话后类别。通话后分析转录完成后，您的输出中就会显示通话后分析类别的匹配项。

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

## AWS 管理控制台
<a name="tca-category-console-batch"></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-batch.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-rules1.png)

1. 以下是包含两条规则的类别示例：座席在通话期间打断客户超过 15 秒，以及客户或座席在通话的最后两分钟内感受到负面情绪。  
![\[Amazon Transcribe 控制台屏幕截图：带有两个示例规则的 “规则” 窗格。\]](http://docs.aws.amazon.com/zh_cn/transcribe/latest/dg/images/analytics-categories-custom-rules2.png)

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

## AWS CLI
<a name="tca-category-cli-batch"></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)。

下面的示例创建了使用以下规则的类别：
+ 客户在最初的 60000 毫秒被中断了。这些中断的持续时间至少持续了 10000 毫秒。
+ 有一段沉默时间至少持续了 20000 毫秒，通话进行 10％ 到通话进行 80％ 之间。
+ 该座席在通话中的某个时刻有负面情绪。
+ 在通话的前 10000 毫秒内没有使用“欢迎”或“您好”这两个词。

此示例使用[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-category",
  "InputType": "POST_CALL",
  "Rules": [
        {
            "InterruptionFilter": {
                "AbsoluteTimeRange": {
                    "First": 60000
                },
                "Negate": false,
                "ParticipantRole": "CUSTOMER",
                "Threshold": 10000
            }
        },
        {
            "NonTalkTimeFilter": {
                "Negate": false,
                "RelativeTimeRange": {
                    "EndPercentage": 80,
                    "StartPercentage": 10
                },
                "Threshold": 20000
            }
        },
        {
            "SentimentFilter": {
                "ParticipantRole": "AGENT",
                "Sentiments": [
                    "NEGATIVE"                    
                ]
            }
        },
        {
            "TranscriptFilter": {
                "Negate": true,
                "AbsoluteTimeRange": {
                    "First": 10000
                },
                "Targets": [
                    "welcome",
                    "hello"
                ],
                "TranscriptFilterType": "EXACT"
            }
        }
    ]
}
```

## 适用于 Python (Boto3) 的 AWS SDK
<a name="tca-category-python-batch"></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)

下面的示例创建了使用以下规则的类别：
+ 客户在最初的 60000 毫秒被中断了。这些中断的持续时间至少持续了 10000 毫秒。
+ 有一段沉默时间至少持续了 20000 毫秒，通话进行 10％ 到通话进行 80％ 之间。
+ 该座席在通话中的某个时刻有负面情绪。
+ 在通话的前 10000 毫秒内没有使用“欢迎”或“您好”这两个词。

```
from __future__ import print_function
import time
import boto3
transcribe = boto3.client('transcribe', 'us-west-2')
category_name = "my-new-category"
transcribe.create_call_analytics_category(
    CategoryName = category_name,
    InputType = POST_CALL,
    Rules = [
        {
            'InterruptionFilter': {
                'AbsoluteTimeRange': {
                    'First': 60000
                },
                'Negate': False,
                'ParticipantRole': 'CUSTOMER',
                'Threshold': 10000
            }
        },
        {
            'NonTalkTimeFilter': {
                'Negate': False,
                'RelativeTimeRange': {
                    'EndPercentage': 80,
                    'StartPercentage': 10
                },
                'Threshold': 20000
            }
        },
        {
            'SentimentFilter': {
                'ParticipantRole': 'AGENT',
                'Sentiments': [
                    'NEGATIVE'                    
                ]
            }
        },
        {
            'TranscriptFilter': {
                'Negate': True,
                'AbsoluteTimeRange': {
                    'First': 10000
                },
                'Targets': [
                    'welcome',
                    'hello'
                ],
                'TranscriptFilterType': 'EXACT'
            }
        }
    ]
    
)

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

## 通话后分析类别的规则标准
<a name="tca-rules-batch"></a>

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

### 中断匹配
<a name="tca-rules-interruptions-batch"></a>

使用中断（[https://docs.aws.amazon.com/transcribe/latest/APIReference/API_InterruptionFilter.html](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_InterruptionFilter.html) 数据类型）的规则旨在匹配：
+ 座席打断客户的情况
+ 客户打断座席的情况
+ 任何参与者打断对方的情况
+ 没有中断

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

```
"InterruptionFilter": { 
    "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 interruptions,
    "ParticipantRole": Specify if you want to match speech from the agent, the customer, or both,    
    "Threshold": Specify a threshold for the amount of time, in seconds, interruptions occurred during the call
},
```

有关这些参数以及与每个参数关联的有效值的更多信息，请参阅 [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_InterruptionFilter.html](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_InterruptionFilter.html)。

### 关键字匹配
<a name="tca-rules-keywords-batch"></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)。

### 非通话时间匹配
<a name="tca-rules-nontalktime-batch"></a>

使用非通话时间（[https://docs.aws.amazon.com/transcribe/latest/APIReference/API_NonTalkTimeFilter.html](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_NonTalkTimeFilter.html) 数据类型）的规则旨在匹配：
+ 在整个通话过程中，在指定时段存在沉默的情况
+ 在整个通话过程中，在指定时段有语音的情况

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

```
"NonTalkTimeFilter": { 
    "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 speech,      
    "Threshold": Specify a threshold for the amount of time, in seconds, silence (or speech) occurred during the call
},
```

有关这些参数以及与每个参数关联的有效值的更多信息，请参阅 [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_NonTalkTimeFilter.html](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_NonTalkTimeFilter.html)。

### 情绪匹配
<a name="tca-rules-sentiment-batch"></a>

使用情绪（[https://docs.aws.amazon.com/transcribe/latest/APIReference/API_SentimentFilter.html](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_SentimentFilter.html) 数据类型）的规则旨在匹配：
+ 客户、座席或两者在通话的指定时刻是否存在正面情绪的情况
+ 客户、座席或两者在通话中的指定时刻是否存在负面情绪的情况
+ 客户、座席或两者在通话的指定时刻是否存在中性情绪的情况
+ 客户、座席或两者在通话的指定时刻是否正负面情绪兼有的情况

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

```
"SentimentFilter": { 
    "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 chosen sentiment,
    "ParticipantRole": Specify if you want to match speech from the agent, the customer, or both,    
    "Sentiments": [ The sentiments you want to match ]
},
```

有关这些参数以及与每个参数关联的有效值的更多信息，请参阅 [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_SentimentFilter.html](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_SentimentFilter.html)。