awslabs / amazon-transcribe-streaming-sdk

The Amazon Transcribe Streaming SDK is an async Python SDK for converting audio into text via Amazon Transcribe.
Apache License 2.0
153 stars 41 forks source link

Closing HTTP2 connection and exception handling #36

Closed ajay960singh closed 3 years ago

ajay960singh commented 3 years ago

Hey guys,

I want to know two things:

  1. How can I close the HTTP2 stream connection for the SDK? Acc. to the documentation, for just HTTP2, you have to send an end frame so how can I do that with the SDK?

  2. I get exceptions like 'amazon_transcribe.exceptions.BadRequestException: Your request timed out because no new audio was received for 15 seconds'. How can I handle these exceptions in the streaming SDK script?

joguSD commented 3 years ago

The stream has an end_stream method that will handle this closure of the stream. This handles 1 and should avoid 2.

E.g.:

await stream.input_stream.end_stream()