

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

# 识别媒体中的主导语言
<a name="lang-id"></a>

Amazon Transcribe 无需指定语言代码即可自动识别媒体中使用的语言。

[批量转录语言识别](lang-id-batch.md)可以识别媒体文件中使用的主导语言，或者，如果您的媒体包含多种语言，则可以识别所有使用的语言。为了提高语言识别的准确性，您可以选择提供一份您认为媒体中可能存在的两种或多种语言的列表。

[流语言识别](lang-id-stream.md)可以在每个声道中识别一种语言（最多支持两个声道），或者，如果流包含多种语言，它可以识别所说的所有语言。流式转录请求中必须至少包含两个额外的语言选项。提供语言选项可以更快地识别语言。Amazon Transcribe 识别语言的速度越快，流式转录前几秒数据丢失的变化就越小。

**重要**  
批量转录和流式转录支持的语言有所不同。有关详细信息，请参阅[支持的语言表](supported-languages.md)中的**数据输入**列。请注意，语言识别目前不支持瑞典语和越南语。

要了解有关使用语言识别的监控和事件的信息，请参阅[语言识别事件](monitoring-events.md#lang-id-event)。

# 批量转录作业的语言识别
<a name="lang-id-batch"></a>

使用批量语言识别来自动识别媒体文件中的一种或多种语言。

如果您的媒体仅包含一种语言，则可以启用[单语言识别](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_StartTranscriptionJob.html#transcribe-StartTranscriptionJob-request-IdentifyLanguage)，该功能可以识别媒体文件中使用的主导语言，并仅使用该语言创建转录。

如果您的媒体包含多种语言，则可以启用[多语言识别](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_StartTranscriptionJob.html#transcribe-StartTranscriptionJob-request-IdentifyMultipleLanguages)，该功能可以识别媒体文件中使用的所有语言，并使用识别出的每种语言创建转录。请注意，这将会生成多语言转录。您可以使用其他服务，例如 Amazon Translate，来翻译您的成绩单。

有关支持的语言和相关语言代码的完整列表，请参阅[支持的语言](supported-languages.md)表。

为获得最佳效果，请确保您的媒体文件包含至少 30 秒的语音。

有关 AWS 管理控制台、 AWS CLI和 AWS Python 开发工具包的用法示例，请参阅[在批量转录中使用语言识别](#lang-id-batch-examples)。

## 识别多语言音频中的语言
<a name="lang-id-batch-multi-language"></a>

多语言识别专为多语言媒体文件而设计，可为您提供反映媒体中使用的所有[支持的语言](supported-languages.md)的转录。这就表示，如果发言者在对话中变换语言，或者如果每个参与者说的是不同的语言，则您的转录输出会正确检测并转录每种语言。例如，如果您的媒体包含双语发言者，其交替使用美国英语 (`en-US`) 和印地语 (`hi-IN`)，则多语言识别可以识别说出的美国英语并转录为 `en-US`，然后将说出的印地语转录为 `hi-IN`。

这不同于单语言识别，后者只使用一种主导语言来创建转录。在这种情况下，主导语言以外的任何语言都会被错误地转录。

**注意**  
多语言识别目前不支持编辑和自定义语言模型。

**注意**  
目前支持多语言识别的语言如下：en-AB、en-AU、en-GB、en-IE、en-IN、en-NZ、en-US、en-WL、en-ZA、es-ES、es-US、fr-CA、fr-FR、zh-CN、zh-TW、pt-BR、pt-PT、de-CH、de-DE、af-ZA、ar-AE、da-DK、he-IL、hi-IN、id-ID、fa-IR、it-IT、ja-JP、ko-KR、ms-MY、nl-NL、ru-RU、ta-IN、te-IN、th-TH、tr-TR 

多语言转录提供检测到的语言的摘要以及每种语言在媒体中使用的总时间。示例如下：

```
"results": {
        "transcripts": [
            {
                "transcript": "welcome to Amazon transcribe. ये तो उदाहरण हैं क्या कैसे कर सकते हैं ।一つのファイルに複数の言語を書き写す"
            }
        ],

    ...

        "language_codes": [
            {
                "language_code": "en-US",
                "duration_in_seconds": 2.45
            },
            {
                "language_code": "hi-IN",
                "duration_in_seconds": 5.325
            },
            {
                "language_code": "ja-JP",
                "duration_in_seconds": 4.15
            }
        ]
}
```

## 提高语言识别的准确性
<a name="lang-id-batch-improve-accuracy"></a>

通过语言识别，您可以选择包含您认为媒体中可能存在的语言列表。包括语言选项 (`LanguageOptions`) 限制仅使用您在 Amazon Transcribe 将音频与正确语言匹配时指定的语言，这可以加快语言识别速度并提高与分配正确语言方言相关的准确性。

如果选择包含语言代码，则必须包含至少两个语言代码。您可以包含的语言代码数量没有限制，但为了获得最佳效率和准确性，我们建议使用两到五个语言代码。

**注意**  
如果您在请求中包含语言代码，而您提供的语言代码均不与您的音频中标识的一个或多个语言相匹配，则请从您指定的语言代码 Amazon Transcribe 中选择最接近的语言匹配项。然后，它会生成该语言的转录。例如，如果您的媒体 Amazon Transcribe 使用的是美国英语 (`en-US`)，并且您提供的语言代码`zh-CN``fr-FR``de-DE`、和， Amazon Transcribe 很可能会将您的媒体与德语 (`de-DE`) 匹配并生成德语转录。语言代码和说出的语言不匹配可能会导致转录不准确，因此我们建议在添加语言代码时要小心谨慎。

## 将语言识别与其他 Amazon Transcribe 功能相结合
<a name="lang-id-batch-features"></a>

您可以将批量语言识别与任何其它 Amazon Transcribe 特征结合使用。如果将语言识别与其它特征结合使用，则只能使用这些特征支持的语言。例如，如果在内容编辑中使用了语言识别，则只能使用美国英语（`en-US`）或美国西班牙语（`es-US`），因为这是编辑支持的唯一语言。有关更多信息，请参阅[支持的语言和特定语言的特征](supported-languages.md)。

**重要**  
如果您在启用了内容编辑功能的情况下使用自动语言识别，并且您的音频包含美国英语（`en-US`）或美国西班牙语（`es-US`）以外的语言，则您的转录文本中只有美国英语内容会被编辑。其它语言则无法编辑，也不会出现警告或作业失败。



**自定义语言模型、自定义词汇表和自定义词汇表过滤器**

如果要在语言识别请求中添加一个或多个自定义语言模型、自定义词汇表或自定义词汇表过滤器，则必须包含 [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_LanguageIdSettings.html](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_LanguageIdSettings.html) 时包含 `LanguageOptions`。例如，如果您指定了`en-US`自定义词汇表，但 Amazon Transcribe 确定媒体中使用的语言是`en-AU`，则您的自定义词汇*不会*应用于您的转录。如果您包含 `LanguageOptions` 并指定 `en-US` 为唯一的英语方言，则您的自定义词汇表*会*应用于您的转录。

有关请求[https://docs.aws.amazon.com/transcribe/latest/APIReference/API_LanguageIdSettings.html](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_LanguageIdSettings.html)中的示例，请参阅该[在批量转录中使用语言识别](#lang-id-batch-examples)部分**AWS CLI**和下**AWS SDKs**拉面板中的选项 2。

## 在批量转录中使用语言识别
<a name="lang-id-batch-examples"></a>

您可以使用、或，在批量转录作业中使用自动语言识别 **AWS SDKs**；有关示例 **AWS 管理控制台**AWS CLI****，请参阅以下内容：

### AWS 管理控制台
<a name="lang-id-console-batch"></a>

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

1. 在导航窗格中，选择**转录作业**，然后选择**创建作业**（右上角）。这将打开**指定作业详细信息**页面。

1. 在**作业设置**面板中，找到**语言设置**部分，然后选择**自动语言识别**或**自动多语言识别**。

   如果您知道音频文件中存在哪些语言，则可以选择多种语言选项（从*选择语言*下拉框中）。提供语言选项可以提高准确性，但不会要求这么做。  
![\[Amazon Transcribe 控制台屏幕截图：“指定作业详细信息” 页面上的 “作业设置” 窗格。\]](http://docs.aws.amazon.com/zh_cn/transcribe/latest/dg/images/lang-id-batch1.png)

1. 在**指定作业详细信息**页面上填写要包含的任何其它字段，然后选择**下一步**。此时您将会看到**配置作业 - *可选***页面。  
![\[Amazon Transcribe 控制台屏幕截图：“配置作业” 页面。\]](http://docs.aws.amazon.com/zh_cn/transcribe/latest/dg/images/lang-id-configure-batch.png)

1. 选择**创建作业**以运行您的转录作业。

### AWS CLI
<a name="lang-id-cli"></a>

此示例使用[start-transcription-job](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/transcribe/start-transcription-job.html)命令和`IdentifyLanguage`参数。有关更多信息，请参阅[https://docs.aws.amazon.com/transcribe/latest/APIReference/API_StartTranscriptionJob.html](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_StartTranscriptionJob.html)和[https://docs.aws.amazon.com/transcribe/latest/APIReference/API_LanguageIdSettings.html](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_LanguageIdSettings.html)。

**选项 1**：不使用 `language-id-settings` 参数。如果您**未**在请求中包含自定义语言模型、自定义词汇表或自定义词汇表过滤器，请使用此选项。虽然 `language-options` 为可选项，我们还是建议使用该选项。

```
aws transcribe start-transcription-job \
--region us-west-2 \
--transcription-job-name my-first-transcription-job \
--media MediaFileUri=s3://amzn-s3-demo-bucket/my-input-files/my-media-file.flac \
--output-bucket-name amzn-s3-demo-bucket \
--output-key my-output-files/ \    
--identify-language \  (or --identify-multiple-languages) \
--language-options "en-US" "hi-IN"
```

**选项 2**：使用 `language-id-settings` 参数。如果您在请求中**包含**了自定义语言模型、自定义词汇表或自定义词汇表过滤器，请使用此选项。

```
aws transcribe start-transcription-job \
--region us-west-2 \
--transcription-job-name my-first-transcription-job \
--media MediaFileUri=s3://amzn-s3-demo-bucket/my-input-files/my-media-file.flac \
--output-bucket-name amzn-s3-demo-bucket \
--output-key my-output-files/ \
--identify-language \  (or --identify-multiple-languages)
--language-options "en-US" "hi-IN" \
--language-id-settings en-US=VocabularyName=my-en-US-vocabulary,en-US=VocabularyFilterName=my-en-US-vocabulary-filter,en-US=LanguageModelName=my-en-US-language-model,hi-IN=VocabularyName=my-hi-IN-vocabulary,hi-IN=VocabularyFilterName=my-hi-IN-vocabulary-filter
```

以下是另一个使用[start-transcription-job](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/transcribe/start-transcription-job.html)命令的示例，以及用于标识语言的请求正文。

```
aws transcribe start-transcription-job \
--region us-west-2 \
--cli-input-json file://filepath/my-first-language-id-job.json
```

*my-first-language-id-job.json* 文件包含以下请求正文。

**选项 1**：不使用 `LanguageIdSettings` 参数。如果您**未**在请求中包含自定义语言模型、自定义词汇表或自定义词汇表过滤器，请使用此选项。虽然 `LanguageOptions` 为可选项，我们还是建议使用该选项。

```
{
  "TranscriptionJobName": "my-first-transcription-job",  
  "Media": {
        "MediaFileUri": "s3://amzn-s3-demo-bucket/my-input-files/my-media-file.flac"
   },
  "OutputBucketName": "amzn-s3-demo-bucket",
  "OutputKey": "my-output-files/", 
  "IdentifyLanguage": true,  (or "IdentifyMultipleLanguages": true),
  "LanguageOptions": [
        "en-US", "hi-IN"  
  ]
}
```

**选项 2**：使用 `LanguageIdSettings` 参数。如果您在请求中**包含**了自定义语言模型、自定义词汇表或自定义词汇表过滤器，请使用此选项。

```
{
   "TranscriptionJobName": "my-first-transcription-job",  
   "Media": {
        "MediaFileUri": "s3://amzn-s3-demo-bucket/my-input-files/my-media-file.flac"
   },
   "OutputBucketName": "amzn-s3-demo-bucket",
   "OutputKey": "my-output-files/", 
   "IdentifyLanguage": true,  (or "IdentifyMultipleLanguages": true)
   "LanguageOptions": [
        "en-US", "hi-IN"  
   ],
   "LanguageIdSettings": { 
         "en-US" : { 
            "LanguageModelName": "my-en-US-language-model",
            "VocabularyFilterName": "my-en-US-vocabulary-filter",
            "VocabularyName": "my-en-US-vocabulary"
         },
         "hi-IN": {
             "VocabularyName": "my-hi-IN-vocabulary",
             "VocabularyFilterName": "my-hi-IN-vocabulary-filter"
         }
    }
}
```

### 适用于 Python (Boto3) 的 AWS SDK
<a name="lang-id-python-batch"></a>

此示例使用 [start\$1transcription\$1](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/transcribe.html#TranscribeService.Client.start_transcription_job) job 方法的`IdentifyLanguage`参数来标识文件的语言。 适用于 Python (Boto3) 的 AWS SDK 有关更多信息，请参阅[https://docs.aws.amazon.com/transcribe/latest/APIReference/API_StartTranscriptionJob.html](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_StartTranscriptionJob.html)和[https://docs.aws.amazon.com/transcribe/latest/APIReference/API_LanguageIdSettings.html](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_LanguageIdSettings.html)。

有关使用的其他示例 AWS SDKs，包括特定功能、场景和跨服务示例，请参阅本章。[使用 Amazon Transcribe 的代码示例 AWS SDKs](service_code_examples.md)

**选项 1**：不使用 `LanguageIdSettings` 参数。如果您**未**在请求中包含自定义语言模型、自定义词汇表或自定义词汇表过滤器，请使用此选项。虽然 `LanguageOptions` 为可选项，我们还是建议使用该选项。

```
from __future__ import print_function
import time
import boto3
transcribe = boto3.client('transcribe', 'us-west-2')
job_name = "my-first-transcription-job"
job_uri = "s3://amzn-s3-demo-bucket/my-input-files/my-media-file.flac"
transcribe.start_transcription_job(
    TranscriptionJobName = job_name,
    Media = {
        'MediaFileUri': job_uri
    },
    OutputBucketName = 'amzn-s3-demo-bucket',
    OutputKey = 'my-output-files/',
    MediaFormat = 'flac',
    IdentifyLanguage = True,  (or IdentifyMultipleLanguages = True),
    LanguageOptions = [
        'en-US', 'hi-IN'
    ]
)

while True:
    status = transcribe.get_transcription_job(TranscriptionJobName = job_name)
    if status['TranscriptionJob']['TranscriptionJobStatus'] in ['COMPLETED', 'FAILED']:
        break
    print("Not ready yet...")
    time.sleep(5)
print(status)
```

**选项 2**：使用 `LanguageIdSettings` 参数。如果您在请求中**包含**了自定义语言模型、自定义词汇表或自定义词汇表过滤器，请使用此选项。

```
from __future__ import print_function
import time
import boto3
transcribe = boto3.client('transcribe')
job_name = "my-first-transcription-job"
job_uri = "s3://amzn-s3-demo-bucket/my-input-files/my-media-file.flac"
transcribe.start_transcription_job(
    TranscriptionJobName = job_name,
    Media = {
        'MediaFileUri': job_uri
    },
    OutputBucketName = 'amzn-s3-demo-bucket',
    OutputKey = 'my-output-files/', 
    MediaFormat='flac',
    IdentifyLanguage=True,  (or IdentifyMultipleLanguages=True)
    LanguageOptions = [
        'en-US', 'hi-IN'
    ],
    LanguageIdSettings={
        'en-US': {
            'VocabularyName': 'my-en-US-vocabulary',
            'VocabularyFilterName': 'my-en-US-vocabulary-filter',
            'LanguageModelName': 'my-en-US-language-model'
        },
        'hi-IN': {
            'VocabularyName': 'my-hi-IN-vocabulary',
            'VocabularyFilterName': 'my-hi-IN-vocabulary-filter'
        }   
    }
)

while True:
    status = transcribe.get_transcription_job(TranscriptionJobName = job_name)
    if status['TranscriptionJob']['TranscriptionJobStatus'] in ['COMPLETED', 'FAILED']:
        break
    print("Not ready yet...")
    time.sleep(5)
print(status)
```

# 流式转录中的语言识别
<a name="lang-id-stream"></a>

流媒体语言识别可以识别您的媒体流中使用的主导语言。 Amazon Transcribe 需要至少一秒钟的语音才能识别语言。

如果流仅包含一种语言，您可以启用单语言识别，这会识别媒体文件中使用的主要语言并仅使用该语言创建转录。

如果流包含多种语言，您可以启用多语言识别，这会识别流中使用的所有语言，并使用每种识别的语言创建转录。请注意，这将会生成多语言转录。您可以使用其他服务，例如 Amazon Transcribe，来翻译您的成绩单。

要使用流式转录语言识别，您必须提供至少两个语言代码，并且对于每个音频流，每种语言只能选择一种语言方言。这表示，您不能为同一个转录选择 `en-US` 和 `en-AU` 作为语言选项。

您还可以选择从您提供的一组语言代码中选择一种首选语言。添加首选语言可以加快语言识别过程，这对于简短的音频片段很有帮助。

**重要**  
如果您提供的语言代码均不与音频中识别的语言相匹配，请从您指定的语言代码 Amazon Transcribe 中选择最接近的语言匹配项。然后，它会生成该语言的转录。例如，如果您的媒体 Amazon Transcribe 使用的是美国英语 (`en-US`)，并且您提供的语言代码`zh-CN``fr-FR``de-DE`、和， Amazon Transcribe 很可能会将您的媒体与德语 (`de-DE`) 匹配并生成德语转录。语言代码和说出的语言不匹配可能会导致转录不准确，因此我们建议在添加语言代码时要小心谨慎。

如果您的媒体包含两个频道，则 Amazon Transcribe 可以识别每个频道中使用的主导语言。在这种情况下，将 [https://docs.aws.amazon.com/transcribe/latest/APIReference/API_Settings.html#transcribe-Type-Settings-ChannelIdentification](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_Settings.html#transcribe-Type-Settings-ChannelIdentification) 参数设置为 `true`，每个声道将分别转录。注意，此参数的默认值为 `false`。如果您不对其进行更改，则只会转录第一个声道，并且只识别一种语言。

流式转录语言识别不能与自定义语言模型或编辑结合使用。如果将语言识别与其它特征结合使用，则只能使用这些特征支持的语言以及流式转录支持的语言。请参阅[支持的语言](supported-languages.md)。

**注意**  
PCM 和 FLAC 是唯一支持的用于流式转录语言识别的音频格式。对于多语言识别，仅支持 PCM。

## 识别多语言音频中的语言
<a name="multi-language-streaming"></a>

多语言识别适用于多语言流，并为您提供反映流中使用的所有支持的语言的转录。这就表示，如果发言者在对话中变换语言，或者如果每个参与者说的是不同的语言，则您的转录输出会正确检测并转录每种语言。

例如，如果流包含交替使用美国英语 (`en-US`) 和印地语 (`hi-IN`) 的双语发言者，则多语言识别可以识别所说的美国英语并转录为 `en-US`，并将所说的印地语转录为 `hi-IN`。这不同于单语言识别，后者只使用一种主要语言来创建转录。在这种情况下，主导语言以外的任何语言都会被错误地转录。

**注意**  
多语言识别目前不支持编辑和自定义语言模型。

## 在流式转录媒体中使用语言识别
<a name="lang-id-stream-examples"></a>

您可以使用**AWS 管理控制台**、**HTTP/2** 或，在流媒体转录中使用自动语言识别 **WebSockets**；有关示例，请参阅以下内容：

### AWS 管理控制台
<a name="lang-id-console-stream"></a>

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

1. 在导航窗格中，选择 **Real-time transcription (实时转录)**。向下滚动到**语言设置**，如果该字段已最小化，则将其展开。  
![\[Amazon Transcribe 控制台屏幕截图：“实时转录” 页面上折叠的 “语言设置” 选项卡。\]](http://docs.aws.amazon.com/zh_cn/transcribe/latest/dg/images/lang-id-stream1.png)

1. 选择**自动语言识别**或**自动多语言识别**。  
![\[Amazon Transcribe 控制台屏幕截图：扩展的 “语言设置” 选项卡。\]](http://docs.aws.amazon.com/zh_cn/transcribe/latest/dg/images/lang-id-stream2.png)

1. 为您的转录提供至少两个语言代码。请注意，每种语言只能提供一种方言。例如，对于同一个转录，您不能同时选择 `en-US` 和 `en-GB` 作为语言选项。  
![\[Amazon Transcribe 控制台屏幕截图：语言代码选择下拉菜单。\]](http://docs.aws.amazon.com/zh_cn/transcribe/latest/dg/images/lang-id-stream3.png)

1. （可选）从您在上一步中选择的语言子集中，您可以为转录选择首选语言。  
![\[Amazon Transcribe 控制台屏幕截图：带有首选语言选项的 “语言设置” 面板。\]](http://docs.aws.amazon.com/zh_cn/transcribe/latest/dg/images/lang-id-stream4.png)

1. 您现在已准备就绪，可以转录音频流了。选择**开始流式转录**并开始讲话。要结束口述，请选择**停止流式转录**。

### HTTP/2 音频流
<a name="lang-id-http2"></a>

此示例创建了一个启用语言识别的 HTTP/2 请求。有关使用 HTTP/2 流式传输的更多信息 Amazon Transcribe，请参阅。[设置 HTTP/2 音频流](streaming-setting-up.md#streaming-http2)有关特定于的参数和标题的更多详细信息 Amazon Transcribe，请参阅[https://docs.aws.amazon.com/transcribe/latest/APIReference/API_streaming_StartStreamTranscription.html](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_streaming_StartStreamTranscription.html)。

```
POST /stream-transcription HTTP/2
host: transcribestreaming.us-west-2.amazonaws.com
X-Amz-Target: com.amazonaws.transcribe.Transcribe.StartStreamTranscription
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-media-encoding: flac
x-amzn-transcribe-sample-rate: 16000    
x-amzn-transcribe-identify-language: true
x-amzn-transcribe-language-options: en-US,de-DE
x-amzn-transcribe-preferred-language: en-US
transfer-encoding: chunked
```

该示例创建一个启用了多语言识别的 HTTP/2 请求。有关使用 HTTP/2 流式传输的更多信息 Amazon Transcribe，请参阅。[设置 HTTP/2 音频流](streaming-setting-up.md#streaming-http2)有关特定于的参数和标题的更多详细信息 Amazon Transcribe，请参阅[https://docs.aws.amazon.com/transcribe/latest/APIReference/API_streaming_StartStreamTranscription.html](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_streaming_StartStreamTranscription.html)。

```
POST /stream-transcription HTTP/2
host: transcribestreaming.us-west-2.amazonaws.com
X-Amz-Target: com.amazonaws.transcribe.Transcribe.StartStreamTranscription
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-media-encoding: flac
x-amzn-transcribe-sample-rate: 16000    
x-amzn-transcribe-identify-multiple-languages: true
x-amzn-transcribe-language-options: en-US,de-DE
x-amzn-transcribe-preferred-language: en-US
transfer-encoding: chunked
```

如果在请求中使用 `identify-language` 或 `identify-multiple-languages`，您还必须包含 `language-options`。不能在同一个请求中同时使用 `language-code` 和 `identify-language`。

参数定义可在 [API 参考](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_Reference.html)中找到；所有 AWS API 操作的通用参数列在[常用参数](https://docs.aws.amazon.com/transcribe/latest/APIReference/CommonParameters.html)部分中。

### WebSocket 直播
<a name="lang-id-websocket"></a>

此示例创建了一个在 WebSocket 直播中使用语言识别的预签名 URL。为了便于阅读，已增加了换行符。有关将 WebSocket 直播与配合使用的更多信息 Amazon Transcribe，请参阅[设置直 WebSocket 播](streaming-setting-up.md#streaming-websocket)。有关参数的更多详细信息，请参阅 [https://docs.aws.amazon.com/transcribe/latest/APIReference/API_streaming_StartStreamTranscription.html](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_streaming_StartStreamTranscription.html)。

```
GET wss://transcribestreaming.us-west-2.amazonaws.com:8443/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
&media-encoding=flac
&sample-rate=16000
&identify-language=true
&language-options=en-US,de-DE
&preferred-language=en-US
```

此示例创建一个在 WebSocket 直播中使用多种语言标识的预签名 URL。为了便于阅读，已增加了换行符。有关将 WebSocket 直播与配合使用的更多信息 Amazon Transcribe，请参阅[设置直 WebSocket 播](streaming-setting-up.md#streaming-websocket)。有关参数的更多详细信息，请参阅 [https://docs.aws.amazon.com/transcribe/latest/APIReference/API_streaming_StartStreamTranscription.html](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_streaming_StartStreamTranscription.html)。

```
GET wss://transcribestreaming.us-west-2.amazonaws.com:8443/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
&media-encoding=flac
&sample-rate=16000
&identify-multiple-languages=true
&language-options=en-US,de-DE
&preferred-language=en-US
```

如果在请求中使用 `identify-language` 或 `identify-multiple-languages`，您还必须包含 `language-options`。不能在同一个请求中同时使用 `language-code` 和 `identify-language`。

参数定义可在 [API 参考](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_Reference.html)中找到；所有 AWS API 操作的通用参数列在[常用参数](https://docs.aws.amazon.com/transcribe/latest/APIReference/CommonParameters.html)部分中。