

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

# 在实时音频流中启用发言者划分
<a name="conversation-diarization-streaming-med"></a>

要对发言者进行分区并在实时流中标记他们的语音，请使用 AWS 管理控制台 或直播请求。发言者划分最适合流式转录中有两到五个发言者。尽管 M Amazon Transcribe edical 可以在一个直播中对五个以上的扬声器进行分区，但如果超过该数字，分区的准确性就会降低。

要启动 HTTP/2 请求，请使用 [https://docs.aws.amazon.com/transcribe/latest/APIReference/API_streaming_StartMedicalStreamTranscription.html](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_streaming_StartMedicalStreamTranscription.html) API。要启动 WebSocket 请求，请使用预签名 URI。URI 包含在应用程序和 Amazon Transcribe Medical 之间建立双向通信所需的信息。

## 在对着麦克风说话的音频中启用发言者划分（AWS 管理控制台）
<a name="conversation-diarization-console"></a>

您可以使用开始实时直播临床医生与患者的对话，或者开始对着麦克风实时说出的听写。 AWS 管理控制台 

1. 登录到 [AWS 管理控制台](https://console.aws.amazon.com/transcribe/)。

1. 在导航窗格中，为 “ Amazon Transcribe 医疗” 选择 “**实时转录**”。

1. 对于**音频输入类型**，选择要转录的医疗语音类型。

1. 对于**其它设置**，请选择**发言者划分**。

1. 选择**开始流式转录**以开始转录您的实时音频。

1. 对着麦克风说话。

## 在 HTTP/2 音频流中启用发言者划分
<a name="conversation-diarization-med-http2"></a>

要在医疗对话的 HTTP/2 音频流中启用发言者划分，请使用 [https://docs.aws.amazon.com/transcribe/latest/APIReference/API_streaming_StartMedicalStreamTranscription.html](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_streaming_StartMedicalStreamTranscription.html) API 并指定以下内容：
+ 对于 `LanguageCode`，指定与流式转录中所用语言对应的语言代码。有效值为 `en-US`。
+ 对于 `MediaSampleHertz`，请指定音频的采样率。
+ 对于 `Specialty`，指定提供者的医学专科。
+ `ShowSpeakerLabel` – `true`

有关设置 HTTP/2 音频流以转录医疗对话的更多信息，请参阅[设置 HTTP/2 音频流](streaming-setting-up.md#streaming-http2)。

## 在请求中启用扬声器分区 WebSocket
<a name="conversation-diarization-med-websocket"></a>

要使用 API 对 WebSocket 直播中的演讲者进行分区，请使用以下格式创建用于启动 WebSocket 请求的预签名 URI 并将其设置`show-speaker-label`为`true`。

```
GET wss://transcribestreaming.us-west-2.amazonaws.com:8443/medical-stream-transcription-websocket
?language-code=languageCode
&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=Signature Version 4 signature 
&X-Amz-SignedHeaders=host
&media-encoding=flac
&sample-rate=16000
&session-id=sessionId
&specialty=medicalSpecialty
&type=CONVERSATION
&vocabulary-name=vocabularyName
&show-speaker-label=boolean
```

以下代码显示了流式转录请求的截断示例响应。

```
{
  "Transcript": {
    "Results": [
      {
        "Alternatives": [
          {
            "Items": [
              {
                "Confidence": 0.97,
                "Content": "From",
                "EndTime": 18.98,
                "Speaker": "0",
                "StartTime": 18.74,
                "Type": "pronunciation",
                "VocabularyFilterMatch": false
              },
              {
                "Confidence": 1,
                "Content": "the",
                "EndTime": 19.31,
                "Speaker": "0",
                "StartTime": 19,
                "Type": "pronunciation",
                "VocabularyFilterMatch": false
              },
              {
                "Confidence": 1,
                "Content": "last",
                "EndTime": 19.86,
                "Speaker": "0",
                "StartTime": 19.32,
                "Type": "pronunciation",
                "VocabularyFilterMatch": false
              },
             ...
              {
                "Confidence": 1,
                "Content": "chronic",
                "EndTime": 22.55,
                "Speaker": "0",
                "StartTime": 21.97,
                "Type": "pronunciation",
                "VocabularyFilterMatch": false
              },
              ...
                "Confidence": 1,
                "Content": "fatigue",
                "EndTime": 24.42,
                "Speaker": "0",
                "StartTime": 23.95,
                "Type": "pronunciation",
                "VocabularyFilterMatch": false
              },
              {
                "EndTime": 25.22,
                "StartTime": 25.22,
                "Type": "speaker-change",
                "VocabularyFilterMatch": false
              },
              {
                "Confidence": 0.99,
                "Content": "True",
                "EndTime": 25.63,
                "Speaker": "1",
                "StartTime": 25.22,
                "Type": "pronunciation",
                "VocabularyFilterMatch": false
              },
              {
                "Content": ".",
                "EndTime": 25.63,
                "StartTime": 25.63,
                "Type": "punctuation",
                "VocabularyFilterMatch": false
              }
            ],
            "Transcript": "From the last note she still has mild sleep deprivation and chronic fatigue True."
          }
        ],
        "EndTime": 25.63,
        "IsPartial": false,
        "ResultId": "XXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXX",
        "StartTime": 18.74
      }
    ]
  }
}
```

Amazon Transcribe Medical 会根据自然的语音片段（例如说话者的变化或音频的暂停）来中断传入的音频流。转录将逐步返回到您的应用程序，每个响应包含更多转录的语音，直到整个片段被转录。前面的代码是完全转录的语音片段的截断示例。只有完全转录的语音片段才会显示发言者标签。

以下列表显示了流式转录输出中对象和参数的组织结构。

**`Transcript`**  
每个语音段都有自己的 `Transcript` 对象。

**`Results`**  
每个 `Transcript` 对象都有自己的 `Results` 对象。此对象包含 `isPartial` 字段。当其值为 `false` 时，返回的结果就是针对整个语音片段的。

**`Alternatives`**  
每个 `Results` 对象都有一个 `Alternatives` 对象。

**`Items`**  
每个 `Alternatives` 对象都有自己的 `Items` 对象，其中包含有关转录输出中每个单词和标点符号的信息。启用扬声器分区后，每个单词都有一个用于`Speaker`标注完全转录的语音片段的标签。 Amazon Transcribe Medical 使用此标签为直播中的每个发言者分配一个唯一的整数。值为 `speaker-change` 的 `Type` 参数表示一个人已停止说话，另一个人即将开始说话。

**`Transcript`**  
每个 Items 对象都包含一个转录的语音片段作为 `Transcript` 字段的值。

有关 WebSocket 请求的更多信息，请参阅[设置直 WebSocket 播](streaming-setting-up.md#streaming-websocket)。