Amazon Transcribe
开发人员指南
AWS 文档中描述的 AWS 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅中国的 AWS 服务入门

使用 Amazon Transcribe 流式处理

流式转录可以获取音频数据流并对其进行实时转录。转录将在转录事件流中返回到您的应用程序。

要开始转录流音频,请使用 StartStreamTranscription 操作。您最多可以转录 4 个小时的流音频。

Amazon Transcribe 根据自然语音段中断您的传入音频流,例如,扬声器的更改或音频中的暂停。转录将逐步返回到您的应用程序,每个响应包含更多转录的语音,直到整个片段被转录。

在以下示例中,每一行都是流式传输的音频片段的部分结果转录输出:

the amazon is the largest the amazon is the largest the amazon is the largest the amazon is the largest rainforest the amazon is the largest rainforest the amazon is the largest rainforest the amazon is the largest rainforest on the the amazon is the largest rainforest on the the amazon is the largest rainforest on the planet the amazon is the largest rainforest on the planet the amazon is the largest rainforest on the planet the amazon is the largest rainforest on the planet the amazon is the largest rainforest on the planet covering over the amazon is the largest rainforest on the planet covering over the amazon is the largest rainforest on the planet covering over two million

响应中的每个结果对象均包含一个名为 IsPartial 的字段,该字段指示响应是否为包含到目前为止的转录结果的部分响应,或是否为音频片段的完整转录。

每个结果对象还包含音频流中期限的开始时间和结束时间,以便您可以将转录与视频同步。

以下示例是来自 StartStreamTranscription 操作的部分转录响应。

{ "TranscriptResultStream": { "TranscriptEvent": { "Transcript": { "Results": [ { "Alternatives": [ { "Items": [ { "Content": "the", "EndTime": 0.3799375, "StartTime": 0.0299375, "Type": "pronunciation" }, { "Content": "amazon", "EndTime": 0.5899375, "StartTime": 0.3899375, "Type": "pronunciation" }, { "Content": "is", "EndTime": 0.7899375, "StartTime": 0.5999375, "Type": "pronunciation" }, { "Content": "the", "EndTime": 0.9199375, "StartTime": 0.7999375, "Type": "pronunciation" }, { "Content": "largest", "EndTime": 1.0199375, "StartTime": 0.9299375, "Type": "pronunciation" } ], "Transcript": "the amazon is the largest" } ], "EndTime": 1.02, "IsPartial": true, "ResultId": "2db76dc8-d728-11e8-9f8b-f2801f1b9fd1", "StartTime": 0.0199375 } ] } } } }