

# Analyzing call center audio with Call Analytics
<a name="call-analytics"></a>

Use Amazon Transcribe Call Analytics to gain insight into customer-agent interactions. Call Analytics is designed specifically for call center audio and automatically provides you with valuable data relating to each call and each participant. You can also hone in on data at specific points throughout call. For example, you can compare customer sentiment in a call's first few seconds to the last quarter of the call to see if your agent provided a positive experience. Other use case examples are listed in the [following section](#call-analytics-use-cases).

Call Analytics is available for post-call and real-time transcriptions. If you're transcribing a file located in an Amazon S3 bucket, you're performing a post-call transcription. If you're transcribing an audio stream, you're performing a real-time transcription. These two transcription methods offer different Call Analytics insights and features. For more detail on each method, see [Post-call analytics](call-analytics-batch.md) and [Real-time Call Analytics](call-analytics-streaming.md).

With real-time Call Analytics transcriptions, you can also include [post-call analytics](tca-post-call.md) in your request. Your post-call analytics transcript is stored in the Amazon S3 bucket that you specify in your request. Refer to [Post-call analytics with real-time transcriptions](tca-post-call.md) for more information.

**API operations specific to Call Analytics**  
Post-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_DeleteCallAnalyticsCategory.html](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_DeleteCallAnalyticsCategory.html), [https://docs.aws.amazon.com/transcribe/latest/APIReference/API_DeleteCallAnalyticsJob.html](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_DeleteCallAnalyticsJob.html), [https://docs.aws.amazon.com/transcribe/latest/APIReference/API_GetCallAnalyticsCategory.html](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_GetCallAnalyticsCategory.html), [https://docs.aws.amazon.com/transcribe/latest/APIReference/API_GetCallAnalyticsJob.html](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_GetCallAnalyticsJob.html), [https://docs.aws.amazon.com/transcribe/latest/APIReference/API_ListCallAnalyticsCategories.html](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_ListCallAnalyticsCategories.html), [https://docs.aws.amazon.com/transcribe/latest/APIReference/API_ListCallAnalyticsJobs.html](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_ListCallAnalyticsJobs.html), [https://docs.aws.amazon.com/transcribe/latest/APIReference/API_StartCallAnalyticsJob.html](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_StartCallAnalyticsJob.html), [https://docs.aws.amazon.com/transcribe/latest/APIReference/API_UpdateCallAnalyticsCategory.html](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_UpdateCallAnalyticsCategory.html)  
Real-time: [https://docs.aws.amazon.com/transcribe/latest/APIReference/API_StartCallAnalyticsStreamTranscription.html](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_StartCallAnalyticsStreamTranscription.html), StartCallAnalyticsStreamTranscriptionWebSocket

## Common use cases
<a name="call-analytics-use-cases"></a>

**Post-call transcriptions:**
+ **Monitor issue frequency over time**: Use [call categorization](call-analytics-batch.md#tca-categorization-batch) to identify recurring keywords within your transcripts.
+ **Gain insight into your customer service experience**: Use [call characteristics](call-analytics-batch.md#tca-characteristics-batch) (non-talk time, talk time, interruptions, voice loudness, talk speed) and sentiment analysis to determine if customer issues are being appropriately resolved during the call.
+ **Ensure regulatory compliance or adherence to company policy**: Set [keywords and phrases](call-analytics-batch.md#tca-categorization-batch) for company-specific greetings or disclaimers to verify that your agents are meeting regulatory requirements.
+ **Improve handling of customers' personal data**: Use [PII redaction](call-analytics-batch.md#tca-pii-redact-batch) in your transcription output or audio file to help protect customer privacy.
+ **Improve staff training**: Use criteria (sentiment, non-talk time, interruptions, talk speed) to flag transcripts that can be used as examples of positive or negative customer interactions.
+ **Measure staff efficacy in creating a positive customer experience**: Use [sentiment analysis](call-analytics-batch.md#tca-sentiment-batch) to measure if your agents are able to turn a negative customer sentiment into a positive one as calls progress.
+ **Improve data organization**: Label and sort calls based on [custom categories](call-analytics-batch.md#tca-categorization-batch) (including keywords and phrases, sentiment, talk time, and interruptions).
+ **Summarize the important aspects of a call using Generative AI**: Use [generative call summarization](call-analytics-batch.md#tca-summarization-batch) to get a concise summary of the transcript, which includes key components such as issues, action items and outcomes discussed in the call.

**Real-time transcriptions:**
+ **Mitigate escalations in real time**: Set up [real-time alerts](tca-start-stream.md#tca-create-alert-stream) for key phrases—such as a customer saying "speak to a manager"—to flag calls as they begin to escalate. You can create real-time alerts using real-time category matches.
+ **Improve handling of customer data**: Use [PII identification](call-analytics-streaming.md#tca-pii-id-stream) or [PII redaction](call-analytics-streaming.md#tca-pii-redact-stream) in your transcription output to help protect customer privacy.
+ **Identify custom keywords and phrases**: Use [custom categories](call-analytics-streaming.md#tca-category-events-stream) to flag specific keywords in a call.
+ **Automatically identify issues**: Use automatic [issue detection](call-analytics-streaming.md#tca-issue-detection-stream) to get a succinct summary of all issues identified in a call.
+ **Measure staff efficacy in creating a positive customer experience**: Use [sentiment analysis](call-analytics-streaming.md#tca-sentiment-stream) to measure if your agents are able to turn a negative customer sentiment into a positive one as calls progress.
+ **Set up agent-assist**: Use the insights of your choice to provide your agents with proactive assistance in resolving customer calls. See [Live Call Analytics and agent assist for your contact center with Amazon language AI services](https://aws.amazon.com/blogs/machine-learning/live-call-analytics-and-agent-assist-for-your-contact-center-with-amazon-language-ai-services/) for more information.

To compare the features available with Call Analytics to those for Amazon Transcribe and Amazon Transcribe Medical, refer to the [feature table](feature-matrix.md).

To get started, see [Starting a post-call analytics transcription](tca-start-batch.md) and [Starting a real-time Call Analytics transcription](tca-start-stream.md). Call Analytics output is similar to that of a standard transcription job, but contains additional analytics data. To view sample output, see [Post-call analytics output](tca-output-batch.md) and [Real-time Call Analytics output](tca-output-streaming.md).

## Considerations and additional information
<a name="tca-considerations"></a>

Before using Call Analytics, note that:
+ Call Analytics only supports two-channel audio, where an agent is present on one channel and a customer is present on a second channel.
+ [Job queueing](job-queueing.md) is always enabled for post-call analytics jobs, so you're limited to 100 concurrent Call Analytics jobs. If you want to request a quota increase, see [AWS service quotas](https://docs.aws.amazon.com/general/latest/gr/aws_service_limits.html).
+ Input files for post-call analytics jobs cannot be greater than 500 MB and must be less than 4 hours. For audio files with frequency greater than 8kHz, the audio duration must be less than or equal to 2 hours. Note that the file size limit may be smaller for certain compressed, non-WAV audio file formats.
+ If using categories, you must create all desired categories before starting a Call Analytics transcription. Any new categories cannot be applied to existing transcriptions. To learn how to create a new category, see [Creating categories for post-call transcriptions](tca-categories-batch.md) and [Creating categories for real-time transcriptions](tca-categories-stream.md).
+ Some Call Analytics quotas differ from Amazon Transcribe and Amazon Transcribe Medical; refer to the [AWS General Reference](https://docs.aws.amazon.com/general/latest/gr/transcribe.html#transcribe_region) for details.

**Dive deeper with the AWS Machine Learning Blog**  
To learn more about Call Analytics options, see:  
[Post Call Analytics for your contact center with Amazon language AI services](https://aws.amazon.com/blogs/machine-learning/post-call-analytics-for-your-contact-center-with-amazon-language-ai-services/)
[Live Call Analytics and agent assist for your contact center with Amazon language AI services](https://aws.amazon.com/blogs/machine-learning/live-call-analytics-and-agent-assist-for-your-contact-center-with-amazon-language-ai-services/)

To view sample Call Analytics output and features, see our [GitHub demo](https://github.com/aws-samples/amazon-transcribe-post-call-analytics). We also offer a [JSON to Word document](https://github.com/aws-samples/amazon-transcribe-output-word-document) application to convert your transcript into an easy-to-read format.

## Region availability and quotas
<a name="tca-regions"></a>

Call Analytics is supported in the following AWS Regions:


| **Region** | **Transcription type** | 
| --- | --- | 
| ap-northeast-1 (Tokyo) | post-call, real-time | 
| ap-northeast-2 (Seoul) | post-call, real-time | 
| ap-south-1 (Mumbai) | post-call | 
| ap-southeast-1 (Singapore) | post-call | 
| ap-southeast-2 (Sydney) | post-call, real-time | 
| ca-central-1 (Canada, Central) | post-call, real-time | 
| eu-central-1 (Frankfurt) | post-call, real-time | 
| eu-west-2 (London) | post-call, real-time | 
| us-east-1 (N. Virginia) | post-call, real-time | 
| us-west-2 (Oregon) | post-call, real-time | 

Note that Region support differs for [Amazon Transcribe](what-is.md#tsc-regions), [Amazon Transcribe Medical](transcribe-medical.md#med-regions), and Call Analytics.

To get the endpoints for each supported Region, see [Service endpoints](https://docs.aws.amazon.com/general/latest/gr/transcribe.html#transcribe_region) in the *AWS General Reference*.

For a list of quotas that pertain to your transcriptions, refer to the [Service quotas](https://docs.aws.amazon.com/general/latest/gr/transcribe.html#limits-amazon-transcribe) in the *AWS General Reference*. Some quotas can be changed upon request. If the **Adjustable** column contains '**Yes**', you can request an increase. To do so, select the provided link.

# Post-call analytics
<a name="call-analytics-batch"></a>

Call Analytics provides post-call analyses, which are useful for monitoring customer service trends. 

Post-call transcriptions offer the following insights:
+ [Call characteristics](#tca-characteristics-batch), including talk time, non-talk time, speaker loudness, interruptions, talk speed, issues, outcomes, and action items
+  [Generative call summarization](#tca-summarization-batch), which creates a concise summary of the entire call 
+ [Custom categorization](#tca-categorization-batch) with rules that you can use to hone in on specific keywords and criteria
+ [PII redaction](#tca-pii-redact-batch) of your text transcript and your audio file
+ [Speaker sentiment](#tca-sentiment-batch) for each caller at various points in a call

## Post-call insights
<a name="call-analytics-insights-batch"></a>

This section details the insights available for post-call analytics transcriptions.

### Call characteristics
<a name="tca-characteristics-batch"></a>

The call characteristics feature measures the quality of agent-customer interactions using these criteria:
+ **Interruption**: Measures if and when one participant cuts off the other participant mid-sentence. Frequent interruptions may be associated with rudeness or anger, and could correlate to negative sentiment for one or both participants.
+ **Loudness**: Measures the volume at which each participant is speaking. Use this metric to see if the caller or the agent is speaking loudly or yelling, which is often indicative of being upset. This metric is represented as a normalized value (speech level per second of speech in a given segment) on a scale from 0 to 100, where a higher value indicates a louder voice.
+ **Non-talk time**: Measures periods of time that do not contain speech. Use this metric to see if there are long periods of silence, such as an agent keeping a customer on hold for an excessive amount of time.
+ **Talk speed**: Measures the speed at which both participants are speaking. Comprehension can be affected if one participant speaks too quickly. This metric is measured in words per minute.
+ **Talk time**: Measures the amount of time (in milliseconds) each participant spoke during the call. Use this metric to help identify if one participant is dominating the call or if the dialogue is balanced.
+ **Issues, Outcomes, and Action Items**: Identifies issues, outcomes and action items from the call transcript.

Here's an [output example](tca-output-batch.md#tca-output-characteristics-batch).

### Generative call summarization
<a name="tca-summarization-batch"></a>

 Generative call summarization creates a concise summary of the entire call, capturing key components such as reason for the call, steps taken to resolve issue, and next steps. 

 Using generative call summarization, you can: 
+ Reduce the need for manual note-taking during and after calls.
+ Improve agent efficiency as they can spend more time talking to callers waiting in queue rather than engaging in after-call work.
+ Speed up supervisor reviews as call summaries are much quicker to review than entire transcripts.

 To use generative call summarization with a post-call analytics job, see [Enabling generative call summarization](https://docs.aws.amazon.com/transcribe/latest/dg/tca-enable-summarization.html). For example output, see [Generative call summarization output example](https://docs.aws.amazon.com/transcribe/latest/dg/tca-output-batch.html#tca-output-summarization-batch). Generative call summarization is priced separately (please refer to [pricing page](https://aws.amazon.com/transcribe/pricing)). 

**Note**  
 Generative call summarization is currently available in `us-east-1` and `us-west-2`. This capability is supported with these English language dialects: Australian (`en-AU`), British (`en-GB`), Indian (`en-IN`), Irish (`en-IE`), Scottish (`en-AB`), US (`en-US`), and Welsh (`en-WL`). 

### Custom categorization
<a name="tca-categorization-batch"></a>

Use call categorization to flag keywords, phrases, sentiment, or actions within a call. Our categorization options can help you triage escalations, such as negative-sentiment calls with many interruptions, or organize calls into specific categories, such as company departments.

The criteria you can add to a category include:
+ **Non-talk time**: Periods of time when neither the customer nor the agent is talking.
+ **Interruptions**: When the customer or the agent is interrupting the other person.
+ **Customer or agent sentiment**: How the customer or the agent is feeling during a specified time period. If at least 50 percent of the conversation turns (the back-and-forth between two speakers) in a specified time period match the specified sentiment, Amazon Transcribe considers the sentiment a match.
+ **Keywords or phrases**: Matches part of the transcription based on an exact phrase. For example, if you set a filter for the phrase "I want to speak to the manager", Amazon Transcribe filters for that *exact* phrase.

You can also flag the inverse of the previous criteria (talk time, lack of interruptions, a sentiment not being present, and the lack of a specific phrase).

Here's an [output example](tca-output-batch.md#tca-output-categorization-batch).

For more information on categories or to learn how to create a new category, see [Creating categories for post-call transcriptions](tca-categories-batch.md).

### Sensitive data redaction
<a name="tca-pii-redact-batch"></a>

Sensitive data redaction replaces personally identifiable information (PII) in the text transcript and the audio file. A redacted transcript replaces the original text with `[PII]`; a redacted audio file replaces spoken personal information with silence. This parameter is useful for protecting customer information.

**Note**  
Post-call PII redaction is supported with US English (`en-US`) and US Spanish (`es-US`).

To view the list of PII that is redacted using this feature, or to learn more about redaction with Amazon Transcribe, see [Redacting or identifying personally identifiable information](pii-redaction.md).

Here is an [output example](tca-output-batch.md#tca-output-pii-redact-batch).

### Sentiment analysis
<a name="tca-sentiment-batch"></a>

Sentiment analysis estimates how the customer and agent are feeling throughout the call. This metric is represented as both a quantitative value (with a range from `5` to `-5`) and a qualitative value (`positive`, `neutral`, `mixed`, or `negative`). Quantitative values are provided per quarter and per call; qualitative values are provided per turn.

This metric can help identify if your agent is able to delight an upset customer by the time the call ends.

Sentiment analysis works out-of-the-box and thus doesn't support customization, such as model training or custom categories.

Here's an [output example](tca-output-batch.md#tca-output-sentiment-batch).

# Creating categories for post-call transcriptions
<a name="tca-categories-batch"></a>

Post-call analytics supports the creation of custom categories, enabling you to tailor your transcript analyses to best suit your specific business needs.

You can create as many categories as you like to cover a range of different scenarios. For each category you create, you must create between 1 and 20 rules. Each rule is based on one of four criteria: interruptions, keywords, non-talk time, or sentiment. For more details on using these criteria with the [https://docs.aws.amazon.com/transcribe/latest/APIReference/API_CreateCallAnalyticsCategory.html](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_CreateCallAnalyticsCategory.html) operation, refer to the [Rule criteria for post-call analytics categories](#tca-rules-batch) section.

If the content in your media matches all the rules you've specified in a given category, Amazon Transcribe labels your output with that category. See [call categorization output](tca-output-batch.md#tca-output-categorization-batch) for an example of a category match in JSON output.

Here are a few examples of what you can do with custom categories:
+ Isolate calls with specific characteristics, such as calls that end with a negative customer sentiment
+ Identify trends in customer issues by flagging and tracking specific sets of keywords
+ Monitor compliance, such as an agent speaking (or omitting) a specific phrase during the first few seconds of a call
+ Gain insight into customer experience by flagging calls with many agent interruptions and negative customer sentiment
+ Compare multiple categories to measure correlations, such as analyzing whether an agent using a welcome phrase correlates with positive customer sentiment

**Post-call versus real-time categories**

When creating a new category, you can specify whether you want it created as a post-call analytics category (`POST_CALL`) or as a real-time Call Analytics category (`REAL_TIME`). If you don't specify an option, your category is created as a post-call category by default. Post-call analytics category matches are available in your output upon completion of your post-call analytics transcription.

To create a new category for post-call analytics, you can use the **AWS Management Console**, **AWS CLI**, or **AWS SDKs**; see the following for examples:

## AWS Management Console
<a name="tca-category-console-batch"></a>

1. In the navigation pane, under Amazon Transcribe, choose **Amazon Transcribe Call Analytics**.

1. Choose **Call analytics categories**, which takes you to the **Call analytics categories** page. Select **Create category**.  
![\[Amazon Transcribe console screenshot: the Call Analytics 'categories' page.\]](http://docs.aws.amazon.com/transcribe/latest/dg/images/analytics-categories.png)

1. You're now on the **Create category page**. Enter a name for your category, then choose 'Batch call analytics' in the **Category type** dropdown menu.  
![\[Amazon Transcribe console screenshot: the 'category settings' panel.\]](http://docs.aws.amazon.com/transcribe/latest/dg/images/analytics-categories-type.png)

1. You can choose a template to create your category or you can make one from scratch.

   If using a template: select **Use a template (recommended)**, choose the template you want, then select **Create category**.  
![\[Amazon Transcribe console screenshot: the 'category settings' panel showing optional templates.\]](http://docs.aws.amazon.com/transcribe/latest/dg/images/analytics-categories-settings-batch.png)

1. If creating a custom category: select **Create from scratch**.  
![\[Amazon Transcribe console screenshot: the 'create category' page showing 'rules' pane.\]](http://docs.aws.amazon.com/transcribe/latest/dg/images/analytics-categories-custom.png)

1. Add rules to your category using the dropdown menu. You can add up to 20 rules per category.  
![\[Amazon Transcribe console screenshot: the 'rules' pane with list of rule types.\]](http://docs.aws.amazon.com/transcribe/latest/dg/images/analytics-categories-custom-rules1.png)

1. Here's an example of a category with two rules: an agent who interrupts a customer for more than 15 seconds during the call and a negative sentiment felt by the customer or the agent in the last two minutes of the call.  
![\[Amazon Transcribe console screenshot: the 'rules' pane with two example rules.\]](http://docs.aws.amazon.com/transcribe/latest/dg/images/analytics-categories-custom-rules2.png)

1. When you're finished adding rules to your category, choose **Create category**.

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

This example uses the [create-call-analytics-category](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/transcribe/create-call-analytics-category.html) command. For more information, see [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), and [https://docs.aws.amazon.com/transcribe/latest/APIReference/API_Rule.html](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_Rule.html).

The following example creates a category with the rules:
+ The customer was interrupted in the first 60,000 milliseconds. The duration of these interruptions lasted at least 10,000 milliseconds.
+ There was a period of silence that lasted at least 20,000 milliseconds between 10% into the call and 80% into the call.
+ The agent had a negative sentiment at some point in the call.
+ The words "welcome" or "hello" were not used in the first 10,000 milliseconds of the call.

This example uses the [create-call-analytics-category](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/transcribe/create-call-analytics-category.html) command, and a request body that adds several rules to your category.

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

The file *my-first-analytics-category.json* contains the following request body.

```
{
  "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"
            }
        }
    ]
}
```

## AWS SDK for Python (Boto3)
<a name="tca-category-python-batch"></a>

This example uses the AWS SDK for Python (Boto3) to create a category using the `CategoryName` and `Rules` arguments for the [create\$1call\$1analytics\$1category](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/transcribe.html#TranscribeService.Client.create_call_analytics_category) method. For more information, see [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), and [https://docs.aws.amazon.com/transcribe/latest/APIReference/API_Rule.html](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_Rule.html).

For additional examples using the AWS SDKs, including feature-specific, scenario, and cross-service examples, refer to the [Code examples for Amazon Transcribe using AWS SDKs](service_code_examples.md) chapter.

The following example creates a category with the rules:
+ The customer was interrupted in the first 60,000 milliseconds. The duration of these interruptions lasted at least 10,000 milliseconds.
+ There was a period of silence that lasted at least 20,000 milliseconds between 10% into the call and 80% into the call.
+ The agent had a negative sentiment at some point in the call.
+ The words "welcome" or "hello" were not used in the first 10,000 milliseconds of the call.

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

## Rule criteria for post-call analytics categories
<a name="tca-rules-batch"></a>

This section outlines the types of custom `POST_CALL` rules that you can create using the [https://docs.aws.amazon.com/transcribe/latest/APIReference/API_CreateCallAnalyticsCategory.html](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_CreateCallAnalyticsCategory.html) API operation.

### Interruption match
<a name="tca-rules-interruptions-batch"></a>

Rules using interruptions ([https://docs.aws.amazon.com/transcribe/latest/APIReference/API_InterruptionFilter.html](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_InterruptionFilter.html) data type) are designed to match:
+ Instances where an agent interrupts a customer
+ Instances where a customer interrupts an agent
+ Any participant interrupting the other
+ A lack of interruptions

Here's an example of the parameters available with [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
},
```

Refer to [https://docs.aws.amazon.com/transcribe/latest/APIReference/API_CreateCallAnalyticsCategory.html](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_CreateCallAnalyticsCategory.html) and [https://docs.aws.amazon.com/transcribe/latest/APIReference/API_InterruptionFilter.html](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_InterruptionFilter.html) for more information on these parameters and the valid values associated with each.

### Keyword match
<a name="tca-rules-keywords-batch"></a>

Rules using keywords ([https://docs.aws.amazon.com/transcribe/latest/APIReference/API_TranscriptFilter.html](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_TranscriptFilter.html) data type) are designed to match:
+ Custom words or phrases spoken by the agent, the customer, or both
+ Custom words or phrases **not** spoken by the agent, the customer, or both
+ Custom words or phrases that occur in a specific time frame

Here's an example of the parameters available with [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
}
```

Refer to [https://docs.aws.amazon.com/transcribe/latest/APIReference/API_CreateCallAnalyticsCategory.html](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_CreateCallAnalyticsCategory.html) and [https://docs.aws.amazon.com/transcribe/latest/APIReference/API_TranscriptFilter.html](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_TranscriptFilter.html) for more information on these parameters and the valid values associated with each.

### Non-talk time match
<a name="tca-rules-nontalktime-batch"></a>

Rules using non-talk time ([https://docs.aws.amazon.com/transcribe/latest/APIReference/API_NonTalkTimeFilter.html](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_NonTalkTimeFilter.html) data type) are designed to match:
+ The presence of silence at specified periods throughout the call
+ The presence of speech at specified periods throughout the call

Here's an example of the parameters available with [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
},
```

Refer to [https://docs.aws.amazon.com/transcribe/latest/APIReference/API_CreateCallAnalyticsCategory.html](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_CreateCallAnalyticsCategory.html) and [https://docs.aws.amazon.com/transcribe/latest/APIReference/API_NonTalkTimeFilter.html](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_NonTalkTimeFilter.html) for more information on these parameters and the valid values associated with each.

### Sentiment match
<a name="tca-rules-sentiment-batch"></a>

Rules using sentiment ([https://docs.aws.amazon.com/transcribe/latest/APIReference/API_SentimentFilter.html](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_SentimentFilter.html) data type) are designed to match:
+ The presence or absence of a positive sentiment expressed by the customer, agent, or both at specified points in the call
+ The presence or absence of a negative sentiment expressed by the customer, agent, or both at specified points in the call
+ The presence or absence of a neutral sentiment expressed by the customer, agent, or both at specified points in the call
+ The presence or absence of a mixed sentiment expressed by the customer, agent, or both at specified points in the call

Here's an example of the parameters available with [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 ]
},
```

Refer to [https://docs.aws.amazon.com/transcribe/latest/APIReference/API_CreateCallAnalyticsCategory.html](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_CreateCallAnalyticsCategory.html) and [https://docs.aws.amazon.com/transcribe/latest/APIReference/API_SentimentFilter.html](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_SentimentFilter.html) for more information on these parameters and the valid values associated with each.

# Starting a post-call analytics transcription
<a name="tca-start-batch"></a>

Before starting a post-call analytics transcription, you must create all the [categories](tca-categories-batch.md) you want Amazon Transcribe to match in your audio.

**Note**  
Call Analytics transcripts can't be retroactively matched to new categories. Only the categories you create *before* starting a Call Analytics transcription can be applied to that transcription output.

If you've created one or more categories, and your audio matches all the rules within at least one of your categories, Amazon Transcribe flags your output with the matching category. If you choose not to use categories, or if your audio doesn't match the rules specified in your categories, your transcript isn't flagged.

To start a post-call analytics transcription, you can use the **AWS Management Console**, **AWS CLI**, or **AWS SDKs**; see the following for examples:

## AWS Management Console
<a name="analytics-start-console-batch"></a>

Use the following procedure to start a post-call analytics job. The calls that match all characteristics defined by a category are labeled with that category.

1. In the navigation pane, under Amazon Transcribe Call Analytics, choose **Call analytics jobs**.

1. Choose **Create job**.  
![\[Amazon Transcribe console screenshot: the 'Call Analytics jobs' page.\]](http://docs.aws.amazon.com/transcribe/latest/dg/images/analytics-start.png)

1. On the **Specify job details** page, provide information about your Call Analytics job, including the location of your input data.  
![\[Amazon Transcribe console screenshot: the 'specify job details' page.\]](http://docs.aws.amazon.com/transcribe/latest/dg/images/analytics-start-settings1.png)

   Specify the desired Amazon S3 location of your output data and which IAM role to use.  
![\[Amazon Transcribe console screenshot: the 'access permissions' panel.\]](http://docs.aws.amazon.com/transcribe/latest/dg/images/analytics-start-settings2.png)

1. Choose **Next**.

1. For **Configure job**, turn on any optional features you want to include with your Call Analytics job. If you previously created categories, they appear in the **Categories** panel and are automatically applied to your Call Analytics job.  
![\[Amazon Transcribe console screenshot: the 'configure job' page showing all custom categories.\]](http://docs.aws.amazon.com/transcribe/latest/dg/images/analytics-start-configure.png)

1. Choose **Create job**.

## AWS CLI
<a name="analytics-start-cli"></a>

This example uses the [start-call-analytics-job](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/transcribe/start-call-analytics-job.html) command and `channel-definitions` parameter. For more information, see [https://docs.aws.amazon.com/transcribe/latest/APIReference/API_StartCallAnalyticsJob.html](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_StartCallAnalyticsJob.html) and [https://docs.aws.amazon.com/transcribe/latest/APIReference/API_ChannelDefinition.html](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_ChannelDefinition.html).

```
aws transcribe start-call-analytics-job \
--region us-west-2 \
--call-analytics-job-name my-first-call-analytics-job \
--media MediaFileUri=s3://amzn-s3-demo-bucket/my-input-files/my-media-file.flac \
--output-location s3://amzn-s3-demo-bucket/my-output-files/ \
--data-access-role-arn arn:aws:iam::111122223333:role/ExampleRole \
--channel-definitions ChannelId=0,ParticipantRole=AGENT ChannelId=1,ParticipantRole=CUSTOMER
```

Here's another example using the [start-call-analytics-job](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/transcribe/start-call-analytics-job.html) command, and a request body that enables Call Analytics for that job.

```
aws transcribe start-call-analytics-job \
--region us-west-2 \
--cli-input-json file://filepath/my-call-analytics-job.json
```

The file *my-call-analytics-job.json* contains the following request body.

```
{
      "CallAnalyticsJobName": "my-first-call-analytics-job",
      "DataAccessRoleArn": "arn:aws:iam::111122223333:role/ExampleRole",
      "Media": {
          "MediaFileUri": "s3://amzn-s3-demo-bucket/my-input-files/my-media-file.flac"
      },
      "OutputLocation": "s3://amzn-s3-demo-bucket/my-output-files/",
      "ChannelDefinitions": [
          {
              "ChannelId": 0,
              "ParticipantRole": "AGENT"
          },
          {
              "ChannelId": 1,
              "ParticipantRole": "CUSTOMER"
          }
      ]
}
```

## AWS SDK for Python (Boto3)
<a name="analytics-start-python-batch"></a>

This example uses the AWS SDK for Python (Boto3) to start a Call Analytics job using the [start\$1call\$1analytics\$1job](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/transcribe.html#TranscribeService.Client.start_call_analytics_job) method. For more information, see [https://docs.aws.amazon.com/transcribe/latest/APIReference/API_StartCallAnalyticsJob.html](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_StartCallAnalyticsJob.html) and [https://docs.aws.amazon.com/transcribe/latest/APIReference/API_ChannelDefinition.html](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_ChannelDefinition.html).

For additional examples using the AWS SDKs, including feature-specific, scenario, and cross-service examples, refer to the [Code examples for Amazon Transcribe using AWS SDKs](service_code_examples.md) chapter.

```
from __future__ import print_function
import time
import boto3
transcribe = boto3.client('transcribe', 'us-west-2')
job_name = "my-first-call-analytics-job"
job_uri = "s3://amzn-s3-demo-bucket/my-input-files/my-media-file.flac"
output_location = "s3://amzn-s3-demo-bucket/my-output-files/"
data_access_role = "arn:aws:iam::111122223333:role/ExampleRole"
transcribe.start_call_analytics_job(
     CallAnalyticsJobName = job_name,
     Media = {
        'MediaFileUri': job_uri
     },
     DataAccessRoleArn = data_access_role,
     OutputLocation = output_location,
     ChannelDefinitions = [
        {
            'ChannelId': 0, 
            'ParticipantRole': 'AGENT'
        },
        {
            'ChannelId': 1, 
            'ParticipantRole': 'CUSTOMER'
        }
     ]
)
    
 while True:
   status = transcribe.get_call_analytics_job(CallAnalyticsJobName = job_name)
   if status['CallAnalyticsJob']['CallAnalyticsJobStatus'] in ['COMPLETED', 'FAILED']:
     break
   print("Not ready yet...")
   time.sleep(5)
 print(status)
```

# Post-call analytics output
<a name="tca-output-batch"></a>

Post-call analytics transcripts are displayed in a turn-by-turn format by segment. They include call categorization, call characteristics (loudness scores, interruptions, non-talk time, talk speed), call summarization (issues, outcomes, and action items), redaction, and sentiment. Additionally, a summary of conversation characteristics is provided at the end of the transcript.

To increase accuracy and further customize your transcripts to your use case, such as including industry-specific terms, add [custom vocabularies](custom-vocabulary.md) or [custom language models](custom-language-models.md) to your Call Analytics request. To mask, remove, or tag words that you don't want in your transcription results, such as profanity, add [vocabulary filtering](vocabulary-filtering.md). If you are unsure of the language code to be passed to the media file, you can enable [batch language identification](https://docs.aws.amazon.com/transcribe/latest/dg/lang-id-batch.html) to automatically identify the language in your media file.

The following sections show examples of JSON output at an insight level. For compiled output, see [Compiled post-call analytics output](#tca-output-batch-compiled).

## Call categorization
<a name="tca-output-categorization-batch"></a>

Here's what a category match looks like in your transcription output. This example shows that the audio from the 40040 millisecond timestamp to the 42460 millisecond timestamp is a match to the 'positive-resolution' category. In this case, the custom 'positive-resolution' category required a positive sentiment in last few seconds of speech.

```
"Categories": {
    "MatchedDetails": {
        "positive-resolution": {
            "PointsOfInterest": [
                {
                    "BeginOffsetMillis":  40040,
                    "EndOffsetMillis":  42460
                }
            ]
        }
    },
    "MatchedCategories": [
        " positive-resolution"
    ]
},
```

## Call characteristics
<a name="tca-output-characteristics-batch"></a>

Here's what call characteristics look like in your transcription output. Note that loudness scores are provided for each conversation turn, while all other characteristics are provided at the end of the transcript.

```
"LoudnessScores": [
    87.54,
    88.74,
    90.16,
    86.36,
    85.56,
    85.52,
    81.79,
    87.74,
    89.82
],
  
...  
    
"ConversationCharacteristics": {
    "NonTalkTime": {
        "Instances": [],
        "TotalTimeMillis": 0
    },
    "Interruptions": {
        "TotalCount": 2,
        "TotalTimeMillis": 10700,
        "InterruptionsByInterrupter": {
            "AGENT": [
                {
                    "BeginOffsetMillis": 26040,
                    "DurationMillis": 5510,
                    "EndOffsetMillis": 31550
                }
            ],
            "CUSTOMER": [
                {
                    "BeginOffsetMillis": 770,
                    "DurationMillis": 5190,
                    "EndOffsetMillis": 5960
                }
            ]
        }
    },
    "TotalConversationDurationMillis": 42460,
  
    ...
    
    "TalkSpeed": {
        "DetailsByParticipant": {
            "AGENT": {
                "AverageWordsPerMinute": 150
            },
            "CUSTOMER": {
                "AverageWordsPerMinute": 167
            }
        }
    },
    "TalkTime": {
        "DetailsByParticipant": {
            "AGENT": {
                "TotalTimeMillis": 32750
            },
            "CUSTOMER": {
                "TotalTimeMillis": 18010
            }
        },
        "TotalTimeMillis": 50760
    }
},
```

 **Issues, Action Items and Next Steps** 
+ In the following example, **issues** are identified as starting at character 7 and ending at character 51, which refers to this section of the text: "*I would like to cancel my recipe subscription*".

  ```
  "Content": "Well, I would like to cancel my recipe subscription.",
      
  "IssuesDetected": [
      {
          "CharacterOffsets": {
              "Begin": 7,
              "End": 51
          }
      }
  ],
  ```
+ In the following example, **outcomes** are identified as starting at character 12 and ending at character 78, which refers to this section of the text: "*I made all changes to your account and now this discount is applied*".

  ```
  "Content": "Wonderful. I made all changes to your account and now this discount is applied, please check.",
  
  "OutcomesDetected": [
      {
          "CharacterOffsets": {
              "Begin": 12,
              "End": 78
          }
      }
  ],
  ```
+ In the following example, **action items** are identified as starting at character 0 and ending at character 103, which refers to this section of the text: "*I will send an email with all the details to you today, and I will call you back next week to follow up*".

  ```
  "Content": "I will send an email with all the details to you today, and I will call you back next week to follow up. Have a wonderful evening.",
      
  "ActionItemsDetected": [
      {
          "CharacterOffsets": {
              "Begin": 0,
              "End": 103
          }
      }
  ],
  ```

## Generative call summarization
<a name="tca-output-summarization-batch"></a>

Here's what generative call summarization looks like in your transcription output:

```
"ContactSummary": {
    "AutoGenerated": {
        "OverallSummary": {
            "Content": "A customer wanted to check to see if we had a bag allowance. We told them that we didn't have it, but we could add the bag from Canada to Calgary and then do the one coming back as well."
        }
    }
}
```

The analytics job will complete without summary generation in the following cases:
+ Insufficient conversation content: The conversation must include at least one turn from both the agent and the customer. When there is insufficient conversation content, the service will return the error code INSUFFICIENT\$1CONVERSATION\$1CONTENT.
+ Safety guardrails: The conversation must meet safety guardrails in place to ensure appropriate summary is generated. When these guardrails are not met, the service will return the error code FAILED\$1SAFETY\$1GUIDELINES.

The error code can be found in `Skipped` section within `AnalyticsJobDetails` in the output. You may also find the error reason in `CallAnalyticsJobDetails` in the [https://docs.aws.amazon.com/transcribe/latest/APIReference/API_GetCallAnalyticsJob.html](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_GetCallAnalyticsJob.html) API Response.

 **Sample Error Output** 

```
{
    "JobStatus": "COMPLETED",
    "AnalyticsJobDetails": {
        "Skipped": [
            {
                "Feature": "GENERATIVE_SUMMARIZATION",
                "ReasonCode": "INSUFFICIENT_CONVERSATION_CONTENT",
                "Message": "The conversation needs to have at least one turn from both the participants to generate summary"
            }
        ]
    },
    "LanguageCode": "en-US",
    "AccountId": "***************",
    "JobName": "Test2-copy",
    ...
}
```

## Sentiment analysis
<a name="tca-output-sentiment-batch"></a>

Here is what sentiment analysis looks like in your transcription output.
+ Qualitative turn-by-turn sentiment values:

  ```
  "Content": "That's very sad to hear. Can I offer you a 50% discount to have you stay with us?",
      
  ...
      
  "BeginOffsetMillis": 12180,
  "EndOffsetMillis": 16960,
  "Sentiment": "NEGATIVE",
  "ParticipantRole": "AGENT"
              
  ...
              
  "Content": "That is a very generous offer. And I accept.",
  
  ...
  
  "BeginOffsetMillis": 17140,
  "EndOffsetMillis": 19860,
  "Sentiment": "POSITIVE",
  "ParticipantRole": "CUSTOMER"
  ```
+ Quantitative sentiment values for the entire call:

  ```
  "Sentiment": {
      "OverallSentiment": {
          "AGENT": 2.5,
          "CUSTOMER": 2.1
      },
  ```
+ Quantitative sentiment values per participant and per call quarter:

  ```
  "SentimentByPeriod": {
      "QUARTER": {
          "AGENT": [
              {
                  "Score": 0.0,
                  "BeginOffsetMillis": 0,
                  "EndOffsetMillis": 9862
              },
              {
                  "Score": -5.0,
                  "BeginOffsetMillis": 9862,
                  "EndOffsetMillis": 19725
              },
              {
                  "Score": 5.0,
                  "BeginOffsetMillis": 19725,
                  "EndOffsetMillis": 29587
              },
              {
                  "Score": 5.0,
                  "BeginOffsetMillis": 29587,
                  "EndOffsetMillis": 39450
              }
          ],
          "CUSTOMER": [
              {
                  "Score": -2.5,
                  "BeginOffsetMillis": 0,
                  "EndOffsetMillis": 10615
              },
              {
                  "Score": 5.0,
                  "BeginOffsetMillis": 10615,
                  "EndOffsetMillis": 21230
              },
              {
                  "Score": 2.5,
                  "BeginOffsetMillis": 21230,
                  "EndOffsetMillis": 31845
              },
              {
                  "Score": 5.0,
                  "BeginOffsetMillis": 31845,
                  "EndOffsetMillis": 42460
              }
          ]
      }
  }
  ```

## PII redaction
<a name="tca-output-pii-redact-batch"></a>

Here is what PII redaction looks like in your transcription output.

```
"Content": "[PII], my name is [PII], how can I help?",
"Redaction": [{
    "Confidence": "0.9998",
    "Type": "NAME",
    "Category": "PII"
}]
```

For more information, refer to [Redacting PII in your batch job](https://docs.aws.amazon.com/transcribe/latest/dg/pii-redaction-batch.html).

## Language identification
<a name="tca-output-language-id-batch"></a>

Here is what Language Identification looks like in your transcription output if the feature is enabled.

```
"LanguageIdentification": [{
  "Code": "en-US",
  "Score": "0.8299"
}, {
  "Code": "en-NZ",
  "Score": "0.0728"
}, {
  "Code": "zh-TW",
  "Score": "0.0695"
}, {
  "Code": "th-TH",
  "Score": "0.0156"
}, {
  "Code": "en-ZA",
  "Score": "0.0121"
}]
```

In the above output example, Language Identification will populate the language codes with confidence scores. The result with the highest score will be selected as the language code for transcription. For mode details refer to [Identifying the dominant languages in your media](https://docs.aws.amazon.com/transcribe/latest/dg/lang-id.html).

## Compiled post-call analytics output
<a name="tca-output-batch-compiled"></a>

For brevity, some content is replaced with ellipses in the following transcription output.

This sample includes optional feature - Generative call summarization.

```
{
    "JobStatus": "COMPLETED",
    "LanguageCode": "en-US",
    "Transcript": [
        {
            "LoudnessScores": [
                78.63,
                78.37,
                77.98,
                74.18
            ],
            "Content": "[PII], my name is [PII], how can I help?",
            
            ...
     
             "Content": "Well, I would like to cancel my recipe subscription.",
             "IssuesDetected": [
                 {
                     "CharacterOffsets": {
                         "Begin": 7,
                         "End": 51
                     }
                 }
             ],
            
            ...
     
            "Content": "That's very sad to hear. Can I offer you a 50% discount to have you stay with us?",
            "Items": [
            ...
             ],
            "Id": "649afe93-1e59-4ae9-a3ba-a0a613868f5d",
            "BeginOffsetMillis": 12180,
            "EndOffsetMillis": 16960,
            "Sentiment": "NEGATIVE",
            "ParticipantRole": "AGENT"
        },
        {     
            "LoudnessScores": [
                    80.22,
                    79.48,
                    82.81
            ],
            "Content": "That is a very generous offer. And I accept.",
            "Items": [
            ...
            ],
            "Id": "f9266cba-34df-4ca8-9cea-4f62a52a7981",
            "BeginOffsetMillis": 17140,
            "EndOffsetMillis": 19860,
            "Sentiment": "POSITIVE",
            "ParticipantRole": "CUSTOMER"
        },
        {
     
     ...
     
            "Content": "Wonderful. I made all changes to your account and now this discount is applied, please check.",
            "OutcomesDetected": [
                {
                    "CharacterOffsets": {
                        "Begin": 12,
                        "End": 78
                    }
                }
            ],
            
            ...
            
            "Content": "I will send an email with all the details to you today, and I will call you back next week to follow up. Have a wonderful evening.",
            "Items": [
            ...   
            ],
            "Id": "78cd0923-cafd-44a5-a66e-09515796572f",
            "BeginOffsetMillis": 31800,
            "EndOffsetMillis": 39450,
            "Sentiment": "POSITIVE",
            "ParticipantRole": "AGENT"
        },
        {
           "LoudnessScores": [
               78.54,
               68.76,
               67.76
           ],
           "Content": "Thank you very much, sir. Goodbye.",
           "Items": [
           ...     
           ],
           "Id": "5c5e6be0-8349-4767-8447-986f995af7c3",
           "BeginOffsetMillis": 40040,
           "EndOffsetMillis": 42460,
           "Sentiment": "POSITIVE",
           "ParticipantRole": "CUSTOMER"
       }
   ],
   
   ...
     
   "Categories": {
        "MatchedDetails": {
            "positive-resolution": {
                "PointsOfInterest": [
                    {
                        "BeginOffsetMillis": 40040,
                        "EndOffsetMillis": 42460
                    }
                ]
            }
        },
        "MatchedCategories": [
            "positive-resolution"
        ]
    },  
 
    ...
    
    "ConversationCharacteristics": {
        "NonTalkTime": {
            "Instances": [],
            "TotalTimeMillis": 0
        },
        "Interruptions": {
            "TotalCount": 2,
            "TotalTimeMillis": 10700,
            "InterruptionsByInterrupter": {
                "AGENT": [
                    {
                        "BeginOffsetMillis": 26040,
                        "DurationMillis": 5510,
                        "EndOffsetMillis": 31550
                    }
                ],
                "CUSTOMER": [
                    {
                        "BeginOffsetMillis": 770,
                        "DurationMillis": 5190,
                        "EndOffsetMillis": 5960
                    }
                ]
            }
        },
        "TotalConversationDurationMillis": 42460,
        "Sentiment": {
            "OverallSentiment": {
                "AGENT": 2.5,
                "CUSTOMER": 2.1
            },
            "SentimentByPeriod": {
                "QUARTER": {
                    "AGENT": [
                        {
                            "Score": 0.0,
                            "BeginOffsetMillis": 0,
                            "EndOffsetMillis": 9862
                        },
                        {
                            "Score": -5.0,
                            "BeginOffsetMillis": 9862,
                            "EndOffsetMillis": 19725
                        },
                        {
                            "Score": 5.0,
                            "BeginOffsetMillis": 19725,
                            "EndOffsetMillis": 29587
                        },
                        {
                            "Score": 5.0,
                            "BeginOffsetMillis": 29587,
                            "EndOffsetMillis": 39450
                        }
                    ],
                    "CUSTOMER": [
                        {
                            "Score": -2.5,
                            "BeginOffsetMillis": 0,
                            "EndOffsetMillis": 10615
                        },
                        {
                            "Score": 5.0,
                            "BeginOffsetMillis": 10615,
                            "EndOffsetMillis": 21230
                        },
                        {
                            "Score": 2.5,
                            "BeginOffsetMillis": 21230,
                            "EndOffsetMillis": 31845
                        },
                        {
                            "Score": 5.0,
                            "BeginOffsetMillis": 31845,
                            "EndOffsetMillis": 42460
                        }
                    ]
                }
            }
        },
        "TalkSpeed": {
            "DetailsByParticipant": {
                "AGENT": {
                    "AverageWordsPerMinute": 150
                },
                "CUSTOMER": {
                    "AverageWordsPerMinute": 167
                }
            }
        },
        "TalkTime": {
            "DetailsByParticipant": {
                "AGENT": {
                    "TotalTimeMillis": 32750
                },
                "CUSTOMER": {
                    "TotalTimeMillis": 18010
                }
            },
            "TotalTimeMillis": 50760
        },
        "ContactSummary": { // Optional feature - Generative call summarization
            "AutoGenerated": {
                "OverallSummary": {
                    "Content": "The customer initially wanted to cancel but the agent convinced them to stay by offering a 50% discount, which the customer accepted after reconsidering cancelling given the significant savings. The agent ensured the discount was applied and said they would follow up to ensure the customer remained happy with the revised subscription."
                }
            }
        }
    },
    "AnalyticsJobDetails": {
        "Skipped": []
    },
    ...
}
```

# Enabling generative call summarization
<a name="tca-enable-summarization"></a>

**Note**  
 **Powered by Amazon Bedrock:** AWS implements [automated abuse detection](https://docs.aws.amazon.com//bedrock/latest/userguide/abuse-detection.html). Because post-contact summarization powered by generative AI is built on Amazon Bedrock, users can take full advantage of the controls implemented in Amazon Bedrock to enforce safety, security, and the responsible use of artificial intelligence (AI). 

To use generative call summarization with a post call analytics job, see the following for examples:

## AWS Management Console
<a name="analytics-summarization-console"></a>

In the Summarization panel, enable Generative call summarization to receive summary in the output.

![\[Amazon Transcribe console screenshot: the 'Call Analytics jobs' page.\]](http://docs.aws.amazon.com/transcribe/latest/dg/images/analytics-summarization.png)


## AWS CLI
<a name="analytics-summarization-cli"></a>

This example uses the [start-call-analytics-job](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/transcribe/start-call-analytics-job.html) command and `Settings` parameter with the `Summarization` sub-parameters. For more information, see [https://docs.aws.amazon.com//transcribe/latest/APIReference/API_StartCallAnalyticsJob.html](https://docs.aws.amazon.com//transcribe/latest/APIReference/API_StartCallAnalyticsJob.html). 

```
aws transcribe start-call-analytics-job \
--region us-west-2 \
--call-analytics-job-name my-first-call-analytics-job \
--media MediaFileUri=s3://amzn-s3-demo-bucket/my-input-files/my-media-file.flac \
--output-location s3://amzn-s3-demo-bucket/my-output-files/ \
--data-access-role-arn arn:aws:iam::111122223333:role/ExampleRole \
--channel-definitions ChannelId=0,ParticipantRole=AGENT ChannelId=1,ParticipantRole=CUSTOMER
--settings '{"Summarization":{"GenerateAbstractiveSummary":true}}'
```

Here's another example using the [start-call-analytics-job](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/transcribe/start-call-analytics-job.html) command, and a request body that enables summarization for that job.

```
aws transcribe start-call-analytics-job \
--region us-west-2 \
--cli-input-json file://filepath/my-call-analytics-job.json
```

The file *my-call-analytics-job.json* contains the following request body.

```
{
  "CallAnalyticsJobName": "my-first-call-analytics-job",
  "DataAccessRoleArn": "arn:aws:iam::111122223333:role/ExampleRole",
  "Media": {
    "MediaFileUri": "s3://amzn-s3-demo-bucket/my-input-files/my-media-file.flac"
  },
  "OutputLocation": "s3://amzn-s3-demo-bucket/my-output-files/",
  "ChannelDefinitions": [
    {
      "ChannelId": 0,
      "ParticipantRole": "AGENT"
    },
    {
      "ChannelId": 1,
      "ParticipantRole": "CUSTOMER"
    }
  ],
  "Settings": {
    "Summarization":{
      "GenerateAbstractiveSummary": true
    }
  }
}
```

## AWS SDK for Python (Boto3)
<a name="analytics-summarization-python"></a>

This example uses the AWS SDK for Python (Boto3) to start a Call Analytics with summarization enabled using the [start\$1call\$1analytics\$1job](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/transcribe.html#TranscribeService.Client.start_call_analytics_job) method. For more information, see [https://docs.aws.amazon.com/transcribe/latest/APIReference/API_StartCallAnalyticsJob.html](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_StartCallAnalyticsJob.html).

For additional examples using the AWS SDKs, including feature-specific, scenario, and cross-service examples, refer to the [Code examples for Amazon Transcribe using AWS SDKs](service_code_examples.md) chapter.

```
from __future__ import print_function
from __future__ import print_function
import time
import boto3
transcribe = boto3.client('transcribe', 'us-west-2')
job_name = "my-first-call-analytics-job"
job_uri = "s3://amzn-s3-demo-bucket/my-input-files/my-media-file.flac"
output_location = "s3://amzn-s3-demo-bucket/my-output-files/"
data_access_role = "arn:aws:iam::111122223333:role/ExampleRole"
transcribe.start_call_analytics_job(
  CallAnalyticsJobName = job_name,
  Media = {
    'MediaFileUri': job_uri
  },
  DataAccessRoleArn = data_access_role,
  OutputLocation = output_location,
  ChannelDefinitions = [
    {
      'ChannelId': 0, 
      'ParticipantRole': 'AGENT'
    },
    {
      'ChannelId': 1, 
      'ParticipantRole': 'CUSTOMER'
    }
  ],
  Settings = {
    "Summarization":
      {
        "GenerateAbstractiveSummary": true
      }
  }
)
    
while True:
  status = transcribe.get_call_analytics_job(CallAnalyticsJobName = job_name)
  if status['CallAnalyticsJob']['CallAnalyticsJobStatus'] in ['COMPLETED', 'FAILED']:
    break
  print("Not ready yet...")
  time.sleep(5)
print(status)
```

# Real-time Call Analytics
<a name="call-analytics-streaming"></a>

Real-time Call Analytics provides real-time insights that can be used for addressing issues and mitigating escalations as they happen.

The following insights are available with real-time Call Analytics:
+ [Category events](#tca-category-events-stream) that use rules to flag specific keywords and phrases; category events can be used to create [real-time alerts](tca-start-stream.md#tca-create-alert-stream)
+ [Issue detection](#tca-issue-detection-stream) identifies the issues spoken within each audio segment
+ [PII (sensitive data) identification](#tca-pii-id-stream) in your text transcript
+ [PII (sensitive data) redaction](#tca-pii-redact-stream) of your text transcript
+ [Sentiment analysis](#tca-sentiment-stream) for each speech segment
+ [Language identification](#tca-language-id-stream) detects the primary language spoken in each audio channel

In addition to real-time Call Analytics, Amazon Transcribe can also perform [post-call analytics](tca-post-call.md) on your media stream. You can include post-call analytics in your real-time Call Analytics request using the [https://docs.aws.amazon.com/transcribe/latest/APIReference/API_streaming_PostCallAnalyticsSettings.html](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_streaming_PostCallAnalyticsSettings.html) parameter.

## Real-time insights
<a name="call-analytics-insights-streaming"></a>

This section details the insights available for real-time Call Analytics transcriptions.

### Category events
<a name="tca-category-events-stream"></a>

Using category events, you can match your transcription based on an exact keyword or phrase. For example, if you set a filter for the phrase "I want to speak to the manager", Amazon Transcribe filters for that *exact* phrase.

Here's an [output example](tca-output-streaming.md#tca-output-category-event-stream).

For more information on creating real-time Call Analytics categories, see [Creating categories for real-time transcriptions](tca-categories-stream.md).

**Tip**  
Category events allow you to set real-time alerts; see [Creating real-time alerts for category matches](tca-start-stream.md#tca-create-alert-stream) for more information.

### Issue detection
<a name="tca-issue-detection-stream"></a>

Issue detection provides succinct summaries of detected issues within each audio segment. Using the issue detection feature, you can:
+ Reduce the need for manual note-taking during and after calls
+ Improve agent efficiency, allowing them to respond faster to customers

**Note**  
Issue detection is supported with these English language dialects: Australian (`en-AU`), British (`en-GB`), and US (`en-US`).

The issue detection feature works across all industries and business sectors, and is context-based. It works out-of-the-box and thus doesn't support customization, such as model training or custom categories.

Issue detection with real-time Call Analytics is performed on each complete audio segment.

Here's an [output example](tca-output-streaming.md#tca-output-issue-detection-stream).

### PII (sensitive data) identification
<a name="tca-pii-id-stream"></a>

Sensitive data identification labels personally identifiable information (PII) in the text transcript. This parameter is useful for protecting customer information.

**Note**  
Real-time PII identification is supported with these English language dialects: Australian (`en-AU`), British (`en-GB`), US (`en-US`) and with Spanish language dialect (`es-US`).

PII identification with real-time Call Analytics is performed on each complete audio segment.

To view the list of PII that is identified using this feature, or to learn more about PII identification with Amazon Transcribe, see [Redacting or identifying personally identifiable information](pii-redaction.md).

Here is an [output example](tca-output-streaming.md#tca-output-pii-id-stream).

### PII (sensitive data) redaction
<a name="tca-pii-redact-stream"></a>

Sensitive data redaction replaces personally identifiable information (PII) in your text transcript with the type of PII (for example, `[NAME]`). This parameter is useful for protecting customer information.

**Note**  
Real-time PII redaction is supported with these English language dialects: Australian (`en-AU`), British (`en-GB`), US (`en-US`) and with Spanish language dialect (`es-US`).

PII redaction with real-time Call Analytics is performed on each complete audio segment.

To view the list of PII that is redacted using this feature, or to learn more about redaction with Amazon Transcribe, see [Redacting or identifying personally identifiable information](pii-redaction.md).

Here is an [output example](tca-output-streaming.md#tca-output-pii-redact-stream).

### Sentiment analysis
<a name="tca-sentiment-stream"></a>

Sentiment analysis estimates how the customer and agent are feeling throughout the call. This metric is provided for every speech segment and is represented as a qualitative value (`positive`, `neutral`, `mixed`, or `negative`).

Using this parameter, you can qualitatively evaluate the overall sentiment for each call participant and the sentiment for each participant during each speech segment. This metric can help identify if your agent is able to delight an upset customer by the time the call ends.

Sentiment analysis with real-time Call Analytics is performed on each complete audio segment.

Sentiment analysis works out-of-the-box and thus doesn't support customization, such as model training or custom categories.

Here's an [output example](tca-output-streaming.md#tca-output-sentiment-stream).

### Language identification
<a name="tca-language-id-stream"></a>

Language identification automatically recognizes and determines the primary language being spoken within each channel of your audio streams during real-time Call Analytics. Once identified, Call Analytics will process and return the most suitable transcription based on the detected language, delivering this information back through the stream in real-time.

This feature allows you to automatically recognize and identify the dominant language spoken in each channel of your audio stream. Once the language is detected, Call Analytics processes and delivers the appropriate transcription for the identified language in real-time.

Automatic language identification is supported for all [Call Analytics streaming supported languages](https://docs.aws.amazon.com/transcribe/latest/dg/supported-languages.html) that are currently supported for streaming transcriptions at no additional cost, and is available in the Call Analytics streaming supported [AWS Regions](https://docs.aws.amazon.com/general/latest/gr/transcribe.html#transcribe_region).

**Important**  
Call Analytics supports single-language identification only, which identifies the dominant language spoken in your audio channel. Multi-language identification is not supported, meaning each channel can only be transcribed in one language.  
To use language identification, you must provide at least two language codes and at most five language codes, and you can select only one language dialect per language per stream from [supported Call Analytics streaming languages](https://docs.aws.amazon.com/transcribe/latest/dg/supported-languages.html). This means that you cannot select en-US and en-AU as language options for the same transcription. When utilizing this feature, the LanguageCode parameter must remain null in the request, as LanguageCode and IdentifyLanguage are mutually exclusive options.

**Warning**  
If your specified language codes don't match the actual spoken language, the system will select the most similar language from your options, which may result in inaccurate transcriptions.

Using the language identification feature, you can:
+ Automatically detect the dominant language in real-time
+ Process different languages across separate channels
+ Receive confidence scores for language detection
+ Apply language-specific custom vocabularies

To use language identification, you must configure the following parameters:

**Required parameters:**
+ `identifyLanguage` - Set to true to enable language identification.
+ `languageOptions` - A list of possible language codes to use when identifyLanguage is set to true. You must provide a minimum of two language selections, as single-language selection is not supported.

**Optional parameters:**
+ `preferredLanguage` - Your expected primary language from provided languageOptions. Adding a preferred language can help Call Analytics identify the language faster.
+ `vocabularyNames` - Custom vocabulary names for improved accuracy. Note that vocabulary names are case-sensitive, and if the custom vocabulary's language doesn't match the identified media language, it won't be applied to the transcription.
+ `vocabularyFilterNames` - Vocabulary filter names to customize the transcript output.

Here's an [output example](tca-output-streaming.md#tca-output-language-id-stream).

# Creating categories for real-time transcriptions
<a name="tca-categories-stream"></a>

Real-time Call Analytics supports the creation of custom categories, which you can use to tailor your transcript analyses to best suit your specific business needs.

You can create as many categories as you like to cover a range of different scenarios. For each category you create, you must create between 1 and 20 rules. Real-time Call Analytics transcriptions only support rules that use [https://docs.aws.amazon.com/transcribe/latest/APIReference/API_TranscriptFilter.html](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_TranscriptFilter.html) (keyword matches). For more detail on using rules with the [https://docs.aws.amazon.com/transcribe/latest/APIReference/API_CreateCallAnalyticsCategory.html](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_CreateCallAnalyticsCategory.html) operation, refer to the [Rule criteria for real-time Call Analytics categories](#tca-rules-stream) section.

If the content in your media matches all the rules you've specified in a given category, Amazon Transcribe labels your output with that category. See [category event output](tca-output-streaming.md#tca-output-category-event-stream) for an example of a category match in JSON output format.

Here are a few examples of what you can do with custom categories:
+ Identify issues that warrant immediate attention by flagging and tracking specific sets of keywords
+ Monitor compliance, such as an agent speaking (or omitting) a specific phrase
+ Flag specific words and phrases in real time; you can then set your category match to set an immediate alert. For example, if you create a real-time Call Analytics category for a customer saying "*speak to a manager*," you can set an [event alert](tca-start-stream.md#tca-create-alert-stream) for this real-time category match that notifies the on-duty manager.

**Post-call versus real-time categories**

When creating a new category, you can specify whether you want it created as a post-call category (`POST_CALL`) or as a real-time category (`REAL_TIME`). If you don't specify an option, your category is created as a post-call category by default. Real-time category matches can be used to create real-time alerts. For more information, see [Creating real-time alerts for category matches](tca-start-stream.md#tca-create-alert-stream).

To create a new category for real-time Call Analytics, you can use the **AWS Management Console**, **AWS CLI**, or **AWS SDKs**; see the following for examples:

## AWS Management Console
<a name="tca-category-console"></a>

1. In the navigation pane, under Amazon Transcribe, choose **Amazon Transcribe Call Analytics**.

1. Choose **Call analytics categories**, which takes you to the **Call analytics categories** page. Select the **Create category** button.  
![\[Amazon Transcribe console screenshot: the Call Analytics 'categories' page.\]](http://docs.aws.amazon.com/transcribe/latest/dg/images/analytics-categories.png)

1. You're now on the **Create category page**. Enter a name for your category, then choose 'Real time call analytics' in the **Category type** dropdown menu.  
![\[Amazon Transcribe console screenshot: the 'category settings' panel.\]](http://docs.aws.amazon.com/transcribe/latest/dg/images/analytics-categories-type.png)

1. You can choose a template to create your category or you can make one from scratch.

   If using a template: select **Use a template (recommended)**, choose the template you want, then select **Create category**.  
![\[Amazon Transcribe console screenshot: the 'category settings' panel showing optional templates.\]](http://docs.aws.amazon.com/transcribe/latest/dg/images/analytics-categories-settings-stream.png)

1. If creating a custom category: select **Create from scratch**.  
![\[Amazon Transcribe console screenshot: the 'create category' page showing 'rules' pane.\]](http://docs.aws.amazon.com/transcribe/latest/dg/images/analytics-categories-custom.png)

1. Add rules to your category using the dropdown menu. You can add up to 20 rules per category. With real-time Call Analytics transcriptions, you can only include rules that involve transcript content matches. Any matches are flagged in real time.  
![\[Amazon Transcribe console screenshot: the 'rules' pane with list of rule types.\]](http://docs.aws.amazon.com/transcribe/latest/dg/images/analytics-categories-custom-rules-stream.png)

1. Here's an example of a category with one rule: a customer who says "speak to a manager" at any point in the call.  
![\[Amazon Transcribe console screenshot: the 'rules' pane with logic options.\]](http://docs.aws.amazon.com/transcribe/latest/dg/images/analytics-categories-custom-rules-stream2.png)

1. When you're finished adding rules to your category, choose **Create category**.

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

This example uses the [create-call-analytics-category](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/transcribe/create-call-analytics-category.html) command. For more information, see [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), and [https://docs.aws.amazon.com/transcribe/latest/APIReference/API_Rule.html](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_Rule.html).

The following example creates a category with the rule:
+ The customer spoke the phrase "speak to the manager" at any point in the call.

This example uses the [create-call-analytics-category](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/transcribe/create-call-analytics-category.html) command, and a request body that adds a rule to your category.

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

The file *my-first-analytics-category.json* contains the following request body.

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

## AWS SDK for Python (Boto3)
<a name="tca-category-python-stream"></a>

This example uses the AWS SDK for Python (Boto3) to create a category using the `CategoryName` and `Rules` arguments for the [create\$1call\$1analytics\$1category](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/transcribe.html#TranscribeService.Client.create_call_analytics_category) method. For more information, see [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), and [https://docs.aws.amazon.com/transcribe/latest/APIReference/API_Rule.html](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_Rule.html).

For additional examples using the AWS SDKs, including feature-specific, scenario, and cross-service examples, refer to the [Code examples for Amazon Transcribe using AWS SDKs](service_code_examples.md) chapter.

The following example creates a category with the rule:
+ The customer spoke the phrase "speak to the manager" at any point in the call.

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

## Rule criteria for real-time Call Analytics categories
<a name="tca-rules-stream"></a>

This section outlines the types of custom `REAL_TIME` rules that you can create using the [https://docs.aws.amazon.com/transcribe/latest/APIReference/API_CreateCallAnalyticsCategory.html](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_CreateCallAnalyticsCategory.html) API operation.

Issue detection occurs automatically, so you don't need to create any rules or categories to flag issues.

Note that only keyword matches are supported for real-time Call Analytics transcriptions. If you want to create categories that include interruptions, silence, or sentiment, refer to [Rule criteria for post-call analytics categories](tca-categories-batch.md#tca-rules-batch).

### Keyword match
<a name="tca-rules-keywords-stream"></a>

Rules using keywords ([https://docs.aws.amazon.com/transcribe/latest/APIReference/API_TranscriptFilter.html](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_TranscriptFilter.html) data type) are designed to match:
+ Custom words or phrases spoken by the agent, the customer, or both
+ Custom words or phrases **not** spoken by the agent, the customer, or both
+ Custom words or phrases that occur in a specific time frame

Here's an example of the parameters available with [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
}
```

Refer to [https://docs.aws.amazon.com/transcribe/latest/APIReference/API_CreateCallAnalyticsCategory.html](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_CreateCallAnalyticsCategory.html) and [https://docs.aws.amazon.com/transcribe/latest/APIReference/API_TranscriptFilter.html](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_TranscriptFilter.html) for more information on these parameters and the valid values associated with each.

# Post-call analytics with real-time transcriptions
<a name="tca-post-call"></a>

Post-call analytics is an optional feature available with real-time Call Analytics transcriptions. In addition to the standard [real-time analytics insights](call-analytics-streaming.md#call-analytics-insights-streaming), post-call analytics provides you with the following:
+ **Action items**: Lists any action items identified in the call
+ **Interruptions**: Measures if and when one participant cuts off the other participant midsentence
+ **Issues**: Provides the issues identified in the call
+ **Loudness**: Measures the volume at which each participant is speaking
+ **Non-talk time**: Measures periods of time that do not contain speech
+ **Outcomes**: Provides the outcome, or resolution, identified in the call
+ **Talk speed**: Measures the speed at which both participants are speaking
+ **Talk time**: Measures the amount of time (in milliseconds) each participant spoke during the call

When enabled, post-call analytics from an audio stream produces a transcript similar to a [post-call analytics from an audio file](call-analytics-batch.md) and stores it in the Amazon S3 bucket specified in `OutputLocation`. Additionally, post-call analytics records your audio stream and saves it as an audio file (`WAV` format) in the same Amazon S3 bucket. If you enable redaction, a redacted transcript and a redacted audio file are also stored in the specified Amazon S3 bucket. Enabling post-call analytics with your audio stream produces between two and four files, as described here:
+ If redaction is **not** enabled, your output files are:

  1. An unredacted transcript

  1. An unredacted audio file
+ If redaction is enabled **without** the unredacted option (`redacted`), your output files are:

  1. A redacted transcript

  1. A redacted audio file
+ If redaction is enabled **with** the unredacted option (`redacted_and_unredacted`), your output files are:

  1. A redacted transcript

  1. A redacted audio file

  1. An unredacted transcript

  1. An unredacted audio file

Note that if you enable post-call analytics ([https://docs.aws.amazon.com/transcribe/latest/APIReference/API_streaming_PostCallAnalyticsSettings.html](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_streaming_PostCallAnalyticsSettings.html)) with your request, and you're using `FLAC` or `OPUS-OGG` media, you **do not** get `loudnessScore` in your transcript and no audio recordings of your stream are created. Transcribe may also not be able to provide post-call analytics for long-running audio streams lasting longer than 90 minutes.

For more information on the insights available with post-call analytics for audio streams, refer to the [post-call analytics insights](call-analytics-batch.md#call-analytics-insights-batch) section.

**Tip**  
If you enable post-call analytics with your real-time Call Analytics request, all of your `POST_CALL` and `REAL-TIME` categories are applied to your post-call analytics transcription.

## Enabling post-call analytics
<a name="tca-post-call-enable"></a>

To enable post-call analytics, you must include the [https://docs.aws.amazon.com/transcribe/latest/APIReference/API_streaming_PostCallAnalyticsSettings.html](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_streaming_PostCallAnalyticsSettings.html) parameter in your real-time Call Analytics request. The following parameters must be included when `PostCallAnalyticsSettings` is enabled:
+ `OutputLocation`: The Amazon S3 bucket where you want your post-call transcript stored.
+ `DataAccessRoleArn`: The Amazon Resource Name (ARN) of the Amazon S3 role that has permissions to access the specified Amazon S3 bucket. Note that you must also use the [Trust policy for real-time analytics](security_iam_id-based-policy-examples.md#trust-policy).

If you want a redacted version of your transcript, you can include `ContentRedactionOutput` or `ContentRedactionType` in your request. For more information on these parameters, see [https://docs.aws.amazon.com/transcribe/latest/APIReference/API_streaming_StartCallAnalyticsStreamTranscription.html](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_streaming_StartCallAnalyticsStreamTranscription.html) in the API Reference.

To start a real-time Call Analytics transcription with post-call analytics enabled, you can use the **AWS Management Console** (demo only), **HTTP/2**, or **WebSockets**. For examples, see [Starting a real-time Call Analytics transcription](tca-start-stream.md).

**Important**  
Currently, the AWS Management Console only offers a demo for real-time Call Analytics with pre-loaded audio examples. If you want to use your own audio, you must use the API (HTTP/2, WebSockets, or an SDK).

## Example post-call analytics output
<a name="tca-output-post-call"></a>

Post-call transcripts are displayed in a turn-by-turn format by segment. They include call characteristics, sentiment, call summarization, issue detection, and (optionally) PII redaction. If any of your post-call categories are a match to the audio content, these are also present in your output.

To increase accuracy and further customize your transcripts to your use case, such as including industry-specific terms, add [custom vocabularies](custom-vocabulary.md) or [custom language models](custom-language-models.md) to your Call Analytics request. To mask, remove, or tag words you don't want in your transcription results, such as profanity, add [vocabulary filtering](vocabulary-filtering.md).

Here is a compiled post-call analytics output example:

```
{
    "JobStatus": "COMPLETED",
    "LanguageCode": "en-US",
    "AccountId": "1234567890",
    "Channel": "VOICE",
    "Participants": [{
        "ParticipantRole": "AGENT"
    }, 
    {
        "ParticipantRole": "CUSTOMER"
    }],
    "SessionId": "12a3b45c-de6f-78g9-0123-45h6ab78c901",
    "ContentMetadata": {
        "Output": "Raw"
    }
    "Transcript": [{
        "LoudnessScores": [
            78.63,
            78.37,
            77.98,
            74.18
        ],
        "Content": "[PII], my name is [PII], how can I help?",

            ...

        "Content": "Well, I would like to cancel my recipe subscription.",
            "IssuesDetected": [{
                "CharacterOffsets": {
                    "Begin": 7,
                    "End": 51
                }
            }],

            ...

        "Content": "That's very sad to hear. Can I offer you a 50% discount to have you stay with us?",
        "Id": "649afe93-1e59-4ae9-a3ba-a0a613868f5d",
        "BeginOffsetMillis": 12180,
        "EndOffsetMillis": 16960,
        "Sentiment": "NEGATIVE",
        "ParticipantRole": "AGENT"
    },
    {
        "LoudnessScores": [
            80.22,
            79.48,
            82.81
        ],
        "Content": "That is a very generous offer. And I accept.",
        "Id": "f9266cba-34df-4ca8-9cea-4f62a52a7981",
        "BeginOffsetMillis": 17140,
        "EndOffsetMillis": 19860,
        "Sentiment": "POSITIVE",
        "ParticipantRole": "CUSTOMER"
    },
            ...

        "Content": "Wonderful. I made all changes to your account and now this discount is applied, please check.",
        "OutcomesDetected": [{
        "CharacterOffsets": {
            "Begin": 12,
            "End": 78
        }
        }],

            ...

        "Content": "I will send an email with all the details to you today, and I will call you back next week to follow up. Have a wonderful evening.",
        "Id": "78cd0923-cafd-44a5-a66e-09515796572f",
        "BeginOffsetMillis": 31800,
        "EndOffsetMillis": 39450,
        "Sentiment": "POSITIVE",
        "ParticipantRole": "AGENT"
    },
    {
        "LoudnessScores": [
            78.54,
            68.76,
            67.76
        ],
        "Content": "Thank you very much, sir. Goodbye.",
        "Id": "5c5e6be0-8349-4767-8447-986f995af7c3",
        "BeginOffsetMillis": 40040,
        "EndOffsetMillis": 42460,
        "Sentiment": "POSITIVE",
        "ParticipantRole": "CUSTOMER"
    }
    ],

    ...

    "Categories": {
        "MatchedDetails": {
            "positive-resolution": {
                "PointsOfInterest": [{
                    "BeginOffsetMillis": 40040,
                    "EndOffsetMillis": 42460
                }]
            }
        },
        "MatchedCategories": [
            "positive-resolution"
        ]
    },

    ...

    "ConversationCharacteristics": {
        "NonTalkTime": {
            "Instances": [],
            "TotalTimeMillis": 0
        },
        "Interruptions": {
            "TotalCount": 2,
            "TotalTimeMillis": 10700,
            "InterruptionsByInterrupter": {
                "AGENT": [{
                    "BeginOffsetMillis": 26040,
                    "DurationMillis": 5510,
                    "EndOffsetMillis": 31550
                }],
                "CUSTOMER": [{
                    "BeginOffsetMillis": 770,
                    "DurationMillis": 5190,
                    "EndOffsetMillis": 5960
                }]
            }
        },
        "TotalConversationDurationMillis": 42460,
        "Sentiment": {
            "OverallSentiment": {
                "AGENT": 2.5,
                "CUSTOMER": 2.1
            },
            "SentimentByPeriod": {
                "QUARTER": {
                    "AGENT": [{
                        "Score": 0.0,
                        "BeginOffsetMillis": 0,
                        "EndOffsetMillis": 9862
                    },
                    {
                        "Score": -5.0,
                        "BeginOffsetMillis": 9862,
                        "EndOffsetMillis": 19725
                    },
                    {
                        "Score": 5.0,
                        "BeginOffsetMillis": 19725,
                        "EndOffsetMillis": 29587
                    },
                    {
                       "Score": 5.0,
                        "BeginOffsetMillis": 29587,
                        "EndOffsetMillis": 39450
                    }
                    ],
                    "CUSTOMER": [{
                        "Score": -2.5,
                        "BeginOffsetMillis": 0,
                        "EndOffsetMillis": 10615
                    },
                    {
                        "Score": 5.0,
                        "BeginOffsetMillis": 10615,
                        "EndOffsetMillis": 21230
                    },
                    {
                        "Score": 2.5,
                        "BeginOffsetMillis": 21230,
                        "EndOffsetMillis": 31845
                    },
                    {
                        "Score": 5.0,
                        "BeginOffsetMillis": 31845,
                        "EndOffsetMillis": 42460
                    }
                    ]
                }
            }
        },
        "TalkSpeed": {
            "DetailsByParticipant": {
                "AGENT": {
                    "AverageWordsPerMinute": 150
                },
                "CUSTOMER": {
                    "AverageWordsPerMinute": 167
                }
            }
        },
        "TalkTime": {
            "DetailsByParticipant": {
                "AGENT": {
                    "TotalTimeMillis": 32750
                },
                "CUSTOMER": {
                    "TotalTimeMillis": 18010
                }
            },
            "TotalTimeMillis": 50760
        }
    },
    ...
}
```

# Starting a real-time Call Analytics transcription
<a name="tca-start-stream"></a>

Before starting a real-time Call Analytics transcription, you must create all the [categories](tca-categories-stream.md) you want Amazon Transcribe to match in your call.

**Note**  
Call Analytics transcripts can't be retroactively matched to new categories. Only the categories you create *before* starting a Call Analytics transcription can be applied to that transcription output.

If you've created one or more categories, and your audio matches all the rules within at least one of your categories, Amazon Transcribe flags your output with the matching categories. If you choose not to use categories, or if your audio doesn't match the rules specified in your categories, your transcript isn't flagged.

To include post-call analytics with your real-time Call Analytics transcription, you must provide an Amazon S3 bucket in your request using the `OutputLocation` parameter. You must also include a `DataAccessRoleArn` that has write permissions to the specified bucket. A separate transcript is produced and stored in the specified bucket upon completion of your real-time Call Analytics streaming session.

With real-time Call Analytics, you also have the option to create real-time category alerts; refer to [Creating real-time alerts for category matches](#tca-create-alert-stream) for instructions.

To start a real-time Call Analytics transcription, you can use the **AWS Management Console**, **HTTP/2**, or **WebSockets**; see the following for examples:

**Important**  
Currently, the AWS Management Console only offers a demo for real-time Call Analytics with pre-loaded audio examples. If you want to use your own audio, you must use the API (HTTP/2, WebSockets, or an SDK).

## AWS Management Console
<a name="analytics-start-console-stream"></a>

Use the following procedure to start a Call Analytics request. The calls that match all characteristics defined by a category are labeled with that category.

**Note**  
Only a demo is available in the AWS Management Console. To start a custom real-time analytics transcription, you must use the [API](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_streaming_StartCallAnalyticsStreamTranscription.html).

1. In the navigation pane, under Amazon Transcribe Call Analytics, choose **Analyze a real-time call**.  
![\[Amazon Transcribe console screenshot: the 'analyze a streaming call' demo page.\]](http://docs.aws.amazon.com/transcribe/latest/dg/images/analytics-start-stream.png)

1. For **Step 1: Specify input audio**, choose a demo test file from the dropdown menu.  
![\[Amazon Transcribe console screenshot: a dropdown selection for the demo's input audio.\]](http://docs.aws.amazon.com/transcribe/latest/dg/images/analytics-start-stream-settings1.png)

1. For **Step 2: Review call categories**, you have the option to review the real-time Call Analytics categories you previously created. All real-time Call Analytics categories are applied to your transcription.

   Choosing **View categories** opens a new pane that shows your existing real-time Call Analytics categories and provides a link to create new ones.  
![\[Amazon Transcribe console screenshot: the 'call analytics categories' page.\]](http://docs.aws.amazon.com/transcribe/latest/dg/images/analytics-start-stream-settings2.png)

1. For **Step 3: Configure input and output**, you have the option to apply additional settings.

   Choosing **Configure advanced settings** opens a new pane where you can specify content redaction settings.  
![\[Amazon Transcribe console screenshot: the advanced settings panels, all collapsed.\]](http://docs.aws.amazon.com/transcribe/latest/dg/images/analytics-start-stream-settings3.png)

   Once you've made all your selections, choose **Save** to return to the main page.

1. To apply additional analytics, you can toggle on **Post-call Analytics**. This provides you with the same analytics as a post-call analytics transcription, including interruptions, loudness, non-talk time, talk speed, talk time, issues, action items, and outcomes. Post-call analytics output is stored in a separate file from your real-time Call Analytics transcript.  
![\[Amazon Transcribe console screenshot: the post-call analytics panel, collapsed.\]](http://docs.aws.amazon.com/transcribe/latest/dg/images/analytics-start-stream-post-call1.png)

   If you apply post-call analytics, you must specify an Amazon S3 output file destination and an IAM role. You can optionally choose to encrypt your output.  
![\[Amazon Transcribe console screenshot: the post-call analytics panel, expanded.\]](http://docs.aws.amazon.com/transcribe/latest/dg/images/analytics-start-stream-post-call1a.png)

1. Choose **Start streaming**.

## HTTP/2 stream
<a name="analytics-start-http2"></a>

This example creates an HTTP/2 request with Call Analytics enabled. For more information on using HTTP/2 streaming with Amazon Transcribe, see [Setting up an HTTP/2 stream](streaming-setting-up.md#streaming-http2). For more detail on parameters and headers specific to Amazon Transcribe, see [https://docs.aws.amazon.com/transcribe/latest/APIReference/API_streaming_StartCallAnalyticsStreamTranscription.html](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_streaming_StartCallAnalyticsStreamTranscription.html).

This example includes [post-call analytics](tca-post-call.md). If you don't want post-call analytics, remove the `PostCallAnalyticsSettings` section from the request.

Note that the configuration event shown in the following example needs to be passed as the first event in the stream.

```
POST /stream-transcription HTTP/2
host: transcribestreaming.us-west-2.amazonaws.com
X-Amz-Target: com.amazonaws.transcribe.Transcribe.StartCallAnalyticsStreamTranscription
Content-Type: application/vnd.amazon.eventstream
X-Amz-Content-Sha256: string
X-Amz-Date: 20220208T235959Z
Authorization: AWS4-HMAC-SHA256 Credential=access-key/20220208/us-west-2/transcribe/aws4_request, SignedHeaders=content-type;host;x-amz-content-sha256;x-amz-date;x-amz-target;x-amz-security-token, Signature=string
x-amzn-transcribe-language-code: en-US
x-amzn-transcribe-media-encoding: flac
x-amzn-transcribe-sample-rate: 16000  
transfer-encoding: chunked
    
{
    "AudioStream": { 
        "AudioEvent": { 
            "AudioChunk": blob
        },
        "ConfigurationEvent": {
            "ChannelDefinitions": [
                {
                    "ChannelId": 0,
                    "ParticipantRole": "AGENT"
                },
                {
                     "ChannelId": 1,
                    "ParticipantRole": "CUSTOMER"
                }
            ],
            "PostCallAnalyticsSettings": {
                "OutputLocation": "s3://amzn-s3-demo-bucket/my-output-files/",
                "DataAccessRoleArn": "arn:aws:iam::111122223333:role/ExampleRole"
            }
        }
    }
}
```

Parameter definitions can be found in the [API Reference](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_Reference.html); parameters common to all AWS API operations are listed in the [Common Parameters](https://docs.aws.amazon.com/transcribe/latest/APIReference/CommonParameters.html) section.

## WebSocket stream
<a name="analytics-start-websocket"></a>

This example creates a presigned URL that uses Call Analytics in a WebSocket stream. Line breaks have been added for readability. For more information on using WebSocket streams with Amazon Transcribe, see [Setting up a WebSocket stream](streaming-setting-up.md#streaming-websocket). For more detail on parameters, see [https://docs.aws.amazon.com/transcribe/latest/APIReference/API_streaming_StartCallAnalyticsStreamTranscription.html](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_streaming_StartCallAnalyticsStreamTranscription.html).

This example includes [post-call analytics](tca-post-call.md). If you don't want post-call analytics, remove the `PostCallAnalyticsSettings` section from the request.

Note that the configuration event shown in the following example needs to be passed as the first event in the stream.

```
GET wss://transcribestreaming.us-west-2.amazonaws.com:8443/call-analytics-stream-transcription-websocket?
&X-Amz-Algorithm=AWS4-HMAC-SHA256
&X-Amz-Credential=AKIAIOSFODNN7EXAMPLE%2F20220208%2Fus-west-2%2Ftranscribe%2Faws4_request
&X-Amz-Date=20220208T235959Z
&X-Amz-Expires=300
&X-Amz-Security-Token=security-token
&X-Amz-Signature=string
&X-Amz-SignedHeaders=content-type%3Bhost%3Bx-amz-date
&language-code=en-US
&media-encoding=flac    
&sample-rate=16000

{
    "AudioStream": { 
        "AudioEvent": { 
            "AudioChunk": blob
        },
        "ConfigurationEvent": {
            "ChannelDefinitions": [
                {
                    "ChannelId": 0,
                    "ParticipantRole": "AGENT"
                },
                {
                     "ChannelId": 1,
                    "ParticipantRole": "CUSTOMER"
                }
            ],
            "PostCallAnalyticsSettings": {
                "OutputLocation": "s3://amzn-s3-demo-bucket/my-output-files/",
                "DataAccessRoleArn": "arn:aws:iam::111122223333:role/ExampleRole"
            }
        }
    }
}
```

Parameter definitions can be found in the [API Reference](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_Reference.html); parameters common to all AWS API operations are listed in the [Common Parameters](https://docs.aws.amazon.com/transcribe/latest/APIReference/CommonParameters.html) section.

**Tip**  
The above HTTP/2 and WebSocket examples include post-call analytics. If you don't want post-call analytics, remove the `PostCallAnalyticsSettings` section from the request.  
If you enable `PostCallAnalyticsSettings`, you must send a configuration event as the first event. Your configuration event includes settings for `ChannelDenifitions` and `PostStreamAnalyticsSettings`, as shown in the preceding examples.  
Binary data are passed as a binary message with `content-type application/octet-stream` and the configuration event is passed as a text message with `content-type application/json`.  
For more information, see [Setting up a streaming transcription](streaming-setting-up.md).

## Creating real-time alerts for category matches
<a name="tca-create-alert-stream"></a>

To set up real-time alerts, you must first create a [https://docs.aws.amazon.com/transcribe/latest/APIReference/API_TranscriptFilter.html](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_TranscriptFilter.html) category with the `REAL_TIME` flag. This flag allows your category to be applied to real-time Call Analytics transcriptions.

For instructions on creating a new category, see [Creating categories for real-time transcriptions](tca-categories-stream.md).

When you start your real-time Call Analytics transcription, all categories that have the `REAL_TIME` flag are automatically applied to your transcription output at a segment level. If a `TranscriptFilterType` match occurs, it appears under the `CategoryEvent` section of your transcript. You can then use this parameter and its sub-parameters, `MatchedCategories` and `MatchedDetails`, to set up custom real-time alerts.

Here's an example of real-time Call Analytics transcription output for a `CategoryEvent` match:

```
"CategoryEvent": { 
    "MatchedCategories": [ "shipping-complaint" ],
    "MatchedDetails": { 
        "my package never arrived" : { 
            "TimestampRanges": [    
                { 
                    "BeginOffsetMillis": 19010,
                    "EndOffsetMillis": 22690
                }
            ]
        }
    }
},
```

The previous example represents an exact text match to the speech "*my package never arrived*," which represents a rule within the 'shipping-complaint' category.

You can set up your real-time alert to include any combination of the listed parameters. For example, you could set your alert to include only the phrase that was matched (`MatchedDetails`) or only the category name (`MatchedCategories`). Or you could set your alert to include all parameters.

How you set up your real-time alerts depends on your organization's interfaces and your desired alert type. For example, you could set a `CategoryEvent` match to send a pop-up notification, an email, a text, or any other alert your system can accept.

# Real-time Call Analytics output
<a name="tca-output-streaming"></a>

Real-time Call Analytics transcripts are displayed in a turn-by-turn format by segment. They include category events, issue detection, sentiment, and PII identification and redaction. Category events allow you to set real-time alerts; see [Creating real-time alerts for category matches](tca-start-stream.md#tca-create-alert-stream) for more information.

To increase accuracy and further customize your transcripts to your use case, such as including industry-specific terms, add [custom vocabularies](custom-vocabulary.md) or [custom language models](custom-language-models.md) to your Call Analytics request. To mask, remove, or tag words you don't want in your transcription results, such as profanity, add [vocabulary filtering](vocabulary-filtering.md).

The following sections show examples of JSON output for real-time Call Analytics transcriptions.

## Category events
<a name="tca-output-category-event-stream"></a>

Here's what a category match looks like in your transcription output. This example shows that the audio from the 19010 millisecond timestamp to the 22690 millisecond timestamp is a match to the 'network-complaint' category. In this case, the custom 'network-complaint' category required that the customer said "*network issues*" (exact word match).

```
"CategoryEvent": { 
    "MatchedCategories": [ 
        "network-complaint" 
    ],
    "MatchedDetails": { 
        "network issues" : { 
            "TimestampRanges": [    
                { 
                    "BeginOffsetMillis": 9299375,
                    "EndOffsetMillis": 7899375
                }
            ]
        }
    }
},
```

## Issue detection
<a name="tca-output-issue-detection-stream"></a>

Here's what an issue detection match looks like in your transcription output. This example shows that the text from character 26 to character 62 describes an issue.

```
"UtteranceEvent": {
    ...
    "Transcript": "Wang Xiulan I'm tired of the network issues my phone is having.",
    ...
    "IssuesDetected": [
        {
            "CharacterOffsets": {
                "BeginOffsetChar": 26,
                "EndOffsetChar": 62
            }
        }
    ]
},
```

## Sentiment
<a name="tca-output-sentiment-stream"></a>

Here's what sentiment analysis looks like in your transcription output.

```
"UtteranceEvent": {    
    ...
    "Sentiment": "NEGATIVE",
    "Items": [{
        ...
```

## PII identification
<a name="tca-output-pii-id-stream"></a>

Here's what PII identification looks like in your transcription output.

```
"Entities": [
    {
        "Content": "Wang Xiulan",
        "Category": "PII",
        "Type": "NAME",
        "BeginOffsetMillis": 7999375,
        "EndOffsetMillis": 199375,
        "Confidence": 0.9989
    }
],
```

## PII redaction
<a name="tca-output-pii-redact-stream"></a>

Here's what PII redaction looks like in your transcription output.

```
"Content": "[NAME]. Hi, [NAME]. I'm [NAME] Happy to be helping you today.",
"Redaction": {
    "RedactedTimestamps": [
        {
            "BeginOffsetMillis": 32670,
            "EndOffsetMillis": 33343
        }, 
        {
            "BeginOffsetMillis": 33518,
            "EndOffsetMillis": 33858
        }, 
        {
            "BeginOffsetMillis": 34068,
            "EndOffsetMillis": 34488
        }
    ]
},
```

## Language identification
<a name="tca-output-language-id-stream"></a>

Here's what Language identification looks like in your transcription output.

```
{
  "LanguageCode": "en-US",
  "LanguageIdentification": [
    {
      "Code": "en-US",
      "Score": 0.823
    },
    {
      "Code": "de-DE",
      "Score": 0.177
    }
  ]
}
```

## Compiled real-time Call Analytics output
<a name="tca-output-streaming-compiled"></a>

For brevity, some content is replaced with ellipses in the following transcription output.

```
{
    "CallAnalyticsTranscriptResultStream": {
        "BadRequestException": {},
        "ConflictException": {},
        "InternalFailureException": {},
        "LimitExceededException": {},
        "ServiceUnavailableException": {},
        "UtteranceEvent": {
            "UtteranceId": "58c27f92-7277-11ec-90d6-0242ac120003",
            "ParticipantRole": "CUSTOMER",
            "IsPartial": false,
            "Transcript": "Wang Xiulan I'm tired of the network issues my phone is having.",
            "BeginOffsetMillis": 19010,
            "EndOffsetMillis": 22690,
            "Sentiment": "NEGATIVE",
            "Items": [{
                    "Content": "Wang",
                    "BeginOffsetMillis": 379937,
                    "EndOffsetMillis": 299375,
                    "Type": "pronunciation",
                    "Confidence": 0.9961,
                    "VocabularyFilterMatch": false
                },
                {
                    "Content": "Xiulan",
                    "EndOffsetMillis": 5899375,
                    "BeginOffsetMillis": 3899375,
                    "Type": "pronunciation",
                    "Confidence": 0.9961,
                    "VocabularyFilterMatch": false
                },
                ...
                {
                    "Content": "network",
                    "EndOffsetMillis": 199375,
                    "BeginOffsetMillis": 9299375,
                    "Type": "pronunciation",
                    "Confidence": 0.9961,
                    "VocabularyFilterMatch": false
                },
                {
                    "Content": "issues",
                    "EndOffsetMillis": 7899375,
                    "BeginOffsetMillis": 5999375,
                    "Type": "pronunciation",
                    "Confidence": 0.9961,
                    "VocabularyFilterMatch": false
                },
                {
                    "Content": "my",
                    "EndOffsetMillis": 9199375,
                    "BeginOffsetMillis": 7999375,
                    "Type": "pronunciation",
                    "Confidence": 0.9961,
                    "VocabularyFilterMatch": false
                },
                {
                    "Content": "phone",
                    "EndOffsetMillis": 199375,
                    "BeginOffsetMillis": 9299375,
                    "Type": "pronunciation",
                    "Confidence": 0.9961,
                    "VocabularyFilterMatch": false
                },
                ...
            ],
            "Entities": [{
                "Content": "Wang Xiulan",
                "Category": "PII",
                "Type": "NAME",
                "BeginOffsetMillis": 7999375,
                "EndOffsetMillis": 199375,
                "Confidence": 0.9989
            }],
            "IssuesDetected": [{
                "CharacterOffsets": {
                    "BeginOffsetChar": 26,
                    "EndOffsetChar": 62
                }
            }],
            "LanguageCode": "en-US",
            "LanguageIdentification": [
                {
                    "Code": "en-US",
                    "Score": 0.823
                },
                {
                    "Code": "de-DE",
                    "Score": 0.177
                }
            ]
        },
        "CategoryEvent": { 
            "MatchedCategories": [ 
                "network-complaint" 
            ],
            "MatchedDetails": { 
                "network issues" : { 
                    "TimestampRanges": [    
                        { 
                            "BeginOffsetMillis": 9299375,
                            "EndOffsetMillis": 7899375
                        }
                    ]
                }
            }
        }
    }
}
```