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
140 stars 38 forks source link

handle_events must return the sub-handler results #91

Open ricardofunke opened 1 year ago

ricardofunke commented 1 year ago

Issue #, if available: When implementing handle_transcript_event() method, one might need to return values from there, but the upper class method handle_events() doesn't return anything, which leads to the lost of the returned value in the implemented method. Thus any calls to handle_events() returns None. Description of changes: Added the return clause to the handle_transcript_event() call inside handle_events()

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

ricardofunke commented 1 year ago

Sorry, I didn't test this suggestion and I just realized I put a return clause inside a for loop. My goal is to have some sort of way to return the value from this method and the called method.

Maybe something like this, I don't know:

return [await self.handle_transcript_event(event) async for event in self._transcript_result_stream if isinstance(event, TranscriptEvent)]

This worked for me

david-oliveira-br commented 11 months ago

@ricardofunke Maybe you should treat as a generator and use yield instead of return