

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

# Amazon EventBridge 搭配 使用 Amazon Transcribe
<a name="monitoring-events"></a>

使用 Amazon EventBridge，您可以透過在其他 中啟動事件來回應任務 Amazon Transcribe 中的狀態變更 AWS 服務。當轉錄任務變更狀態時， EventBridge 會自動將事件傳送至事件串流。您會建立規則以定義要在事件串流中監控的事件，以及發生這些事件時 EventBridge 應該採取的動作。例如，將事件路由到另一個服務 (或目標)，此服務可接著採取動作。例如，您可以設定規則，在轉錄任務成功完成時將事件路由至 AWS Lambda 函數。若要定義[EventBridge 規則](#defining-rules)，請參閱下列各節。

您可以透過多個管道接收事件的通知，包括電子郵件、[聊天應用程式中的 Amazon Q Developer](https://docs.aws.amazon.com/chatbot/latest/adminguide/what-is.html) 聊天通知或[AWS Console Mobile Application](https://docs.aws.amazon.com/consolemobileapp/latest/userguide/what-is-consolemobileapp.html)推播通知。您也可以在[主控台通知中心](https://console.aws.amazon.com/notifications/)查看通知。如果您想要設定通知，您可以使用 [AWS 使用者通知](https://docs.aws.amazon.com/notifications/latest/userguide/what-is.html). AWS 使用者通知 supports 彙總，這可以減少您在特定事件期間收到的通知數量。

## 定義 EventBridge 規則
<a name="defining-rules"></a>

若要定義 EventBridge 規則，請使用 [AWS 管理主控台](https://console.aws.amazon.com/events)。定義規則時，請使用 Amazon Transcribe 做為服務名稱。如需如何建立 EventBridge 規則的範例，請參閱 [Amazon EventBridge 規則](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-rules.html)。

使用前 EventBridge，請注意下列定義：
+ **事件**–事件表示您其中一個轉錄作業的狀態變更。例如，工作的 `TranscriptionJobStatus` 從 `IN_PROGRESS` 變更為 `COMPLETED`。
+ **目標**-目標是處理事件的另一個 AWS 服務 。例如， AWS Lambda 或 Amazon Simple Notification Service (Amazon SNS)。目標會收到 JSON 格式的事件。
+ **規則** – 規則符合您要 EventBridge 監看的傳入事件，並將其路由至目標或目標進行處理。如果規則將事件路由到多個目標，所有的目標都會平行處理事件。規則可自訂傳送到目標的 JSON。

Amazon EventBridge 事件會盡最大努力發出。如需在 中建立和管理事件的詳細資訊 EventBridge，請參閱*Amazon EventBridge 《 使用者指南*》中的[Amazon EventBridge 事件](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-events.html)。

以下是轉錄任務的狀態變更為 `COMPLETED`或 時 Amazon Transcribe 啟動的 EventBridge 規則範例`FAILED`。

```
{
    "source": [
        "aws.transcribe"
    ],
    "detail-type": [
        "Transcribe Job State Change"
    ],
    "detail": {
        "TranscriptionJobStatus": [
            "COMPLETED",
            "FAILED"
        ]
    }
}
```

該規則包含下列欄位：
+ `source`–事件的來源。對於 Amazon Transcribe，這一律是 `aws.transcribe`。
+ `detail-type`–事件詳細資訊的識別子。對於 Amazon Transcribe，這一律為 `Transcribe Job State Change`。
+ `detail`–轉錄作業的新作業狀態。在這個範例中，規則會在工作狀態變更為 `COMPLETED` 或 `FAILED` 時啟動事件。

## Amazon Transcribe 事件
<a name="events"></a>

Amazon EventBridge 會記錄數個 Amazon Transcribe 事件：
+ [轉錄作業事件](#job-event)
+ [語言識別事件](#lang-id-event)
+ [呼叫分析事件](#analytics-event)
+ [通話分析通話後事件](#analytics-stream-event)
+ [詞彙事件](#vocab-event)

這些事件都包含下列共用欄位：
+ `version`：事件資料的版本。這個值一律為 `0`。
+ `id`： EventBridge 為事件產生的唯一識別符。
+ `detail-type`：事件詳細資訊的識別子。例如 `Transcribe Job State Change`。
+ `source`：事件的來源。因此一律 Amazon Transcribe 為 `aws.transcribe`。
+ `account`：產生 API 呼叫的帳戶 AWS 帳戶 ID。
+ `time`：事件傳送的日期和時間。
+ `region`：發出請求 AWS 區域 的 。
+ `resources`：API 呼叫使用的資源。對於 Amazon Transcribe，此欄位一律為空白。
+ `detail`：有關事件的其他詳細資訊。
  + `FailureReason`：如果狀況或狀態變更為 `FAILED`，則會顯示此欄位，並描述 `FAILED` 狀況或狀態的原因。
  + 每個事件類型都有其他唯一欄位，顯示在 `detail` 下方。這些唯一欄位會在每個事件範例後的下列各節定義。

### 轉錄作業事件
<a name="job-event"></a>

當任務的狀態從 變更為 `IN_PROGRESS``COMPLETED`或 時`FAILED`， Amazon Transcribe 會產生事件。若要識別變更狀態且在目標中啟動事件的工作，請使用該事件的 `TranscriptionJobName` 欄位。 Amazon Transcribe 事件包含下列資訊。如果您的轉錄作業狀態為 `FAILED`，則會在 `detail` 下方新增 `FailureReason` 欄位。

請注意，此事件僅適用於 [https://docs.aws.amazon.com/transcribe/latest/APIReference/API_StartTranscriptionJob.html](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_StartTranscriptionJob.html) API 操作。

```
{
    "version": "0",
    "id": "event ID",
    "detail-type":"Transcribe Job State Change",
    "source": "aws.transcribe",
    "account": "111122223333",
    "time": "timestamp",
    "region": "us-west-2",
    "resources": [],
    "detail": {
          "TranscriptionJobName": "my-first-transcription-job",
          "TranscriptionJobStatus": "COMPLETED" (or "FAILED")
    }   
}
```
+ `TranscriptionJobName`：您為轉錄作業選擇的唯一名稱。
+ `TranscriptionJobStatus `：轉錄作業的狀態。此值可以為 `COMPLETED` 或 `FAILED`。

### 語言識別事件
<a name="lang-id-event"></a>

您啟用[自動語言識別](lang-id.md)時， Amazon Transcribe 會在語言識別狀態為 `COMPLETED` 或 `FAILED` 時產生事件。若要識別變更狀態且在目標中啟動事件的工作，請使用該事件的 `JobName` 欄位。 Amazon Transcribe 事件包含下列資訊。如果您的語言識別狀態為 `FAILED`，則會在 `detail` 下方新增 `FailureReason` 欄位。

請注意，此事件僅適用於包含 [https://docs.aws.amazon.com/transcribe/latest/APIReference/API_LanguageIdSettings.html](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_LanguageIdSettings.html) 參數時的 [https://docs.aws.amazon.com/transcribe/latest/APIReference/API_StartTranscriptionJob.html](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_StartTranscriptionJob.html) API 操作。

```
{
    "version": "0",
    "id": "event ID",
    "detail-type": "Language Identification State Change",
    "source": "aws.transcribe",
    "account": "111122223333",
    "time": "timestamp",
    "region": "us-west-2",
    "resources": [],
    "detail": {
        "JobType": "TranscriptionJob",
        "JobName": "my-first-lang-id-job",
        "LanguageIdentificationStatus": "COMPLETED" (or "FAILED")
    }
}
```
+ `JobType`: 對於轉錄作業，此值必須是 `TranscriptionJob`。
+ `JobName`：轉錄作業的唯一名稱。
+ `LanguageIdentificationStatus`：轉錄作業中語言識別的狀態。此值可以為 `COMPLETED` 或 `FAILED`。

### 呼叫分析事件
<a name="analytics-event"></a>

[通話分析](call-analytics.md)工作狀態從 `IN_PROGRESS` 變更為 `COMPLETED` 或 `FAILED` 時， Amazon Transcribe 就會產生事件。若要識別變更狀態且在目標中啟動事件的通話分析工作，請使用該事件的 `JobName` 欄位。 Amazon Transcribe 事件包含下列資訊。如果您的通話分析工作狀態為 `FAILED`，則會在 `detail` 下方新增 `FailureReason` 欄位。

請注意，此事件僅適用於 [https://docs.aws.amazon.com/transcribe/latest/APIReference/API_StartCallAnalyticsJob.html](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_StartCallAnalyticsJob.html) API 操作。

```
{
    "version": "0",
    "id": "event ID",
    "detail-type": "Call Analytics Job State Change",
    "source": "aws.transcribe",
    "account": "111122223333",
    "time": "timestamp",
    "region": "us-west-2",
    "resources": [],
    "detail": {
        "JobName": "my-first-analytics-job",
        "JobStatus": "COMPLETED" (or "FAILED"),
        "FailureReason": "failure reason", // only present when JobStatus is FAILED
        "AnalyticsJobDetails": { // only when you enable optional features such as Generative Call Summarization
            "Skipped": []
        }
    }
}
```
+ `JobName`：通話分析轉錄作業的唯一名稱。
+ `JobStatus`：您的通話分析轉錄作業的狀態。可以是 `COMPLETED` 或 `FAILED`。
+ `FailureReason`：只有在 `JobStatus`為 時，才會出現此欄位`FAILED`，並說明失敗的原因。
+ `AnalyticsJobDetails`：通話分析轉錄任務的詳細資訊，包括略過的分析功能的相關資訊。

### 通話分析通話後事件
<a name="analytics-stream-event"></a>

[通話後分析](tca-post-call.md)轉錄狀態從 `IN_PROGRESS` 變更為 `COMPLETED` 或 `FAILED` 時， Amazon Transcribe 會產生事件。若要識別變更狀態且在目標中啟動事件的通話分析通話後工作，請使用該事件的 `StreamingSessionId` 欄位。

請注意，此事件僅適用於包含 [https://docs.aws.amazon.com/transcribe/latest/APIReference/API_streaming_PostCallAnalyticsSettings.html](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_streaming_PostCallAnalyticsSettings.html) 參數時的 [https://docs.aws.amazon.com/transcribe/latest/APIReference/API_streaming_StartCallAnalyticsStreamTranscription.html](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_streaming_StartCallAnalyticsStreamTranscription.html)API 操作。

`COMPLETED` 事件包含下列資訊：

```
{
    "version": "0",
    "id": "event ID",
    "detail-type": "Call Analytics Post Call Job State Change",
    "source": "aws.transcribe",
    "account": "111122223333",
    "time": "timestamp",
    "region": "us-west-2",
    "resources": [],
    "detail": {
        "StreamingSessionId": "session-id",
        "PostCallStatus": "COMPLETED",
        "Transcript": {
            "RedactedTranscriptFileUri": "s3://amzn-s3-demo-bucket/my-output-files/my-redacted-file.JSON",
            "TranscriptFileUri": "s3://amzn-s3-demo-bucket/my-output-files/my-file.JSON"
        },
        "Media": {
            "MediaFileUri": "s3://amzn-s3-demo-bucket/my-output-files/my-redacted-file.WAV",
            "RedactedMediaFileUri": "s3://amzn-s3-demo-bucket/my-output-files/my-redacted-file.WAV"
        }
    }
}
```

`FAILED` 事件包含下列資訊：

```
{
    "version": "0",
    "id": "event ID",
    "detail-type": "Call Analytics Post Call Job State Change",
    "source": "aws.transcribe",
    "account": "111122223333",
    "time": "timestamp",
    "region": "us-west-2",
    "resources": [],
    "detail": {
        "StreamingSessionId": "session-id",
        "PostCallStatus": "FAILED"
    }
}
```
+ `StreamingSessionId`：指定給您即時通話分析轉錄請求的識別號碼。
+ `PostCallStatus`：通話後通話分析轉錄的狀態。可以是 `COMPLETED` 或 `FAILED`。
+ `Transcript`：您修訂和未修訂的文字記錄的 URI。
+ `Media`：您修訂和未修訂的音訊檔案的 URI。

### AWS HealthScribe 串流後分析事件
<a name="health-scribe-analytics-stream-event"></a>

當 a AWS HealthScribe 串流後分析操作的狀態變更時，例如從 變更為 `IN_PROGRESS` 的 [ClinicalNoteGenerationResult](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_streaming_ClinicalNoteGenerationResult.html)`COMPLETED`， AWS HealthScribe 會產生包含下列資訊的事件：

```
{
   "version":"0",
   "id":"event ID",
   "detail-type":"MedicalScribe Post Stream Analytics Update",
   "source":"aws.transcribe",
   "account":"111122223333",
   "time":"timestamp",
   "region":"us-east-1",
   "resources":[],
   "detail":{
      "SessionId": <SessionID>,
      "UpdateType": "ClinicalNoteGenerationResult",
      "ClinicalNoteGenerationResult": {
          "ClinicalNoteOutputLocation": s3://amzn-s3-demo-bucket/clinical-note-output-files/clinical-notes.JSON,
          "TranscriptOutputLocation": s3://amzn-s3-demo-bucket/my-output-files/my-file.JSON,
          "Status": <IN_PROGRESS | COMPLETED | FAILED>,
          "FailureReason": <failure_reason>
    }
   }
}
```
+ `UpdateType`：產生事件的串流後分析操作類型。結果物件的內容會根據 而有所不同`UpdateType`。
+ `SessionId`： AWS HealthScribe 串流的識別號碼。使用此 ID 來識別原始串流工作階段，然後尋找產生事件的串流後分析。
+ `Status`：串流後分析操作的狀態。此值可以為 `IN_PROGRESS`、`COMPLETED` 或 `FAILED`。
+ `ClinicalNoteOutputLocation`： 輸出 Amazon S3 儲存貯體的 URI`ClinicalNoteGenerationResult`。
+ `TranscriptOutputLocation`：文字記錄的 URI。

### 詞彙事件
<a name="vocab-event"></a>

當[自訂詞彙](custom-vocabulary.md)的狀態從 變更為 `PENDING``READY`或 時`FAILED`， Amazon Transcribe 會產生事件。若要識別變更狀態且在目標中啟動事件的自訂詞彙工作，請使用該事件的 `VocabularyName` 欄位。 Amazon Transcribe 事件包含下列資訊。如果您的自訂詞彙狀態為 `FAILED`，則會在 `detail` 下方新增 `FailureReason` 欄位。

**注意**  
此事件僅適用於 [https://docs.aws.amazon.com/transcribe/latest/APIReference/API_CreateVocabulary.html](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_CreateVocabulary.html) API 操作。

```
{
    "version": "0",
    "id": "event ID",
    "detail-type": "Vocabulary State Change",
    "source": "aws.transcribe",
    "account": "111122223333",
    "time": "timestamp",
    "region": "us-west-2",
    "resources": [],
    "detail": {
        "VocabularyName": "unique-vocabulary-name",
        "VocabularyState": "READY" (or "FAILED")
    }
}
```
+ `VocabularyName`：您自訂詞彙的唯一名稱。
+ `VocabularyState`：自訂詞彙的處理狀態。此值可以為 `READY` 或 `FAILED`。