

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

# 建立即時轉錄的類別
<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 將標示輸出為該類別。請參閱[類別事件輸出](tca-output-streaming.md#tca-output-category-event-stream)，了解 JSON 輸出格式中相符類別的範例。

以下是您可以使用自訂類別執行的幾個範例：
+ 標記和追蹤特定的關鍵字集，識別需要立即關注的問題
+ 監控合規性，例如客服人員說出 (或省略) 特定片語
+ 即時標記特定單字和片語；然後您可以設定類別相符項目以設定立即警示。例如，如果您為客戶建立「*與經理對話*」的即時通話分析類別，您可以為此即時類別配對，設定[事件警示](tca-start-stream.md#tca-create-alert-stream)，以通知值班經理。

**通話後與即時類別**

建立新類別時，您可以指定建立為通話後類別 (`POST_CALL`) 或建立為即時類別 (`REAL_TIME`)。如果未指定選項，則預設會將類別建立為通話後類別。即時類別相符項目可用於建立即時警示。如需詳細資訊，請參閱[建立類別配對的即時警示](tca-start-stream.md#tca-create-alert-stream)。

若要建立即時通話分析的新類別，您可以使用 **AWS 管理主控台**、**AWS CLI** 或 **AWS SDK**；請參閱下列範例：

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

1. 在導覽窗格中， Amazon Transcribe選擇**Amazon Transcribe 通話分析**。

1. 選擇**通話分析類別**，將引導您進入**通話分析類別**頁面。選擇**建立類別**按鈕。  
![\[Amazon Transcribe 主控台螢幕擷取畫面：呼叫分析「類別」頁面。\]](http://docs.aws.amazon.com/zh_tw/transcribe/latest/dg/images/analytics-categories.png)

1. 您現在已進入**建立類別頁面**。輸入類別的名稱，然後在**類別類型**下拉式功能表中，選擇「即時通話分析」。  
![\[Amazon Transcribe 主控台螢幕擷取畫面：「類別設定」面板。\]](http://docs.aws.amazon.com/zh_tw/transcribe/latest/dg/images/analytics-categories-type.png)

1. 您可以選擇範本，以建立您的類別，也可以從頭開始建立範本。

   如果使用範本：選擇**使用範本 (建議選項)**，選擇您要的範本，然後選擇**建立類別**。  
![\[Amazon Transcribe 主控台螢幕擷取畫面：顯示選用範本的「類別設定」面板。\]](http://docs.aws.amazon.com/zh_tw/transcribe/latest/dg/images/analytics-categories-settings-stream.png)

1. 如果建立自訂類別：選擇**從頭開始建立**。  
![\[Amazon Transcribe 主控台螢幕擷取畫面：顯示「規則」窗格的「建立類別」頁面。\]](http://docs.aws.amazon.com/zh_tw/transcribe/latest/dg/images/analytics-categories-custom.png)

1. 使用下拉式功能表將規則新增至您的類別。每個類別最多可新增 20 個規則。使用即時通話分析轉錄時，您只能納入涉及文字記錄內容配對的規則。任何相符項目都會即時標記。  
![\[Amazon Transcribe 主控台螢幕擷取畫面：具有規則類型清單的「規則」窗格。\]](http://docs.aws.amazon.com/zh_tw/transcribe/latest/dg/images/analytics-categories-custom-rules-stream.png)

1. 這是帶一個規則的類別範例：通話的任何時間點說出「與經理談談」的客戶。  
![\[Amazon Transcribe 主控台螢幕擷取畫面：具有邏輯選項的「規則」窗格。\]](http://docs.aws.amazon.com/zh_tw/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>

此範例使用 適用於 Python (Boto3) 的 AWS SDK ，使用 [create\$1call\$1analytics\$1category](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/transcribe.html#TranscribeService.Client.create_call_analytics_category) 方法的 `CategoryName`和 `Rules`引數來建立類別。如需詳細資訊，請參閱[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)，了解這些參數與這些參數相關的有效值的詳細資訊。