amazon-transcribe-streaming-sdk: amazon_transcribe.exceptions.BadRequestException: Signature expired Exception
Hi,
I have used this sample
to test with a wav file in local, I have just changed param to point to my audio file in local. This script worked perfectly and I was able to get the transcript text for first 5 minutes.
But after 5 minutes, I got the below exception :
File "test_amazon_transcribe.py", line 82, in basic_transcribe await asyncio.gather(write_chunks(), handler.handle_events()) File "/root/apps/build/python36/lib/python3.6/site-packages/amazon_transcribe/handlers.py", line 26, in handle_events async for event in self._transcript_result_stream: File "/root/apps/build/python36/lib/python3.6/site-packages/amazon_transcribe/eventstream.py", line 666, in __aiter__ parsed_event = self._parser.parse(event) File "/root/apps/build/python36/lib/python3.6/site-packages/amazon_transcribe/deserialize.py", line 147, in parse raise self._parse_event_exception(raw_event) amazon_transcribe.exceptions.BadRequestException: Signature expired: 20201123T084949Z is now earlier than 20201123T084949Z (20201123T085449Z - 5 min.)
I have re run the script for few times, but the issue still exists. Could you please help me?
About this issue
- Original URL
- State: open
- Created 4 years ago
- Comments: 20 (6 by maintainers)
Hi @lalogonzalez
For the first issue, I have used the snap code of this example. All parameters are the same (chunk_size, sample_rate, …), only one different is my audio in local has file size > 100Mb and the audio duration is longer than 1 hour. Original example did not reproduce the issue because the audio duration is too short. To fix the first issue, I have just put one more line code sleep 0.5 seconds just right after you send a audio chunk
I am not sure if this is a good fix or just a workaround, but definitively I did not get any more exception kind of Signature expired
But right now, I sill have second issue
The request signature we calculated does not match the signatureraised in permanent after roughly 30 minutes or more. This issue, I am thinking to retry with a newTranscribeStreamingClientand reused thesession_id,even if this solution works, it sounds to me the workaround as I have to use retry for every times.Is there anyone test successfully for the audio file with the duration longer than 1 hour?
@bangnguyen
Here’s a quick example of what I explained in my previous message, using a modified version of the file based example.
Big disclaimer: I have not thoroughly tested the following code outside of a couple test files – I have no clue how robust the following sample code is but should be close enough to get something functional streaming for long running streams. In particular the parsing code makes some assumptions but should work for basic PCM WAV files.