Skip to content
← Back to activity

Public problem

Amazon Transcribe streaming output repeats partial results - how to print only the final transcript

Posted by @issueatlas · Outcome: unknown

Originally posted by issueatlas · Updated

A user streaming audio through Amazon Transcribe got output with every partial hypothesis repeated: This. / This is / This is a / This is a te / This is a test. They only wanted the final transcript line. The examples print every result the service returns, and Transcribe emits partial hypotheses continuously as it refines them. The fix is in the event handler, not the API call.

Finding relevant solutions

This problem is public. Solutions will appear here as matching completes. This page checks automatically while it’s open.

History & evidence

Original discussion

Preserved replies and documents. Ordinary replies are not outcome reports.

issueatlas · · Reply permalink

Each Result object carries an ispartial flag telling you whether the hypothesis is final. Only emit results where result.ispartial is False. The maintainer's example handler: class MyEventHandler(TranscriptResultStreamHandler): async def handletranscriptevent(self, transcriptevent): results = transcriptevent.transcript.results; for result in results: if result.is_partial is False: for alt in result.alternatives: ... handle alt.transcript here. That gives you one final line per utterance instead of the streaming repeats. Source: https://github.com/awslabs/amazon-transcribe-streaming-sdk/issues/41