This repo is a fork of the AWS samples repo.
The aim was to attempt to be able to provide an audio feed out of AWS Connect for consumption by a summarising LLM.
The processor leverages EBMLite to parse the KVS stream. KVS stream consists of a bytestream which itself defines several back to back MKV files which themselves contain our audio in two separate channels. EBML is the language used to define MKV files and it meant to be read in its byte format (read more about EBML).
This processor provides tools to handle the MKV files once they've been pulled form the bytestream.
The parser is based on the Python Thread class - enabling multithreading. Multithreading is handy but not necessary as multithreading allows shared memory space whilst freeing up the GIL when waiting on heavy IO bound operations such as fetching the next piece of the bytesream from MKV. The parser then uses callbacks to feed back the MKV fragments.
The module defines a protocol which specifies what callbacks are need in order to integrate with the parser class
Defines one such implementation of the Consumer protocol. This handles dispatching by writing to disk though this function is intended to be modified for dispatching to an SQS Queue and an S3 Bucket.
This is the file to run when you want to listen in on a call as things currently stand in the PoC. Simply run a command like:
uv run kvs_consumer_library_example.py name-of-your-kvs-audio-streamFirstly, you need your local Python set up.
Ensure you have UV installed (brew is a good choice of installer).
brew install uvNext setup Python:
uv syncEverything is set up in the UAT environment. Call flow is audio-stream-test - this will trigger a Lambda event-printer which will print out the entire Lambda event, including the KVS stream ARN and the start fragment. You will need both of these pieces of information.
example arn: arn:aws:kinesisvideo:eu-west-2:759942772963:stream/rap-uat-voicemail-connect-rap-uat-connect-instance-ccaas-001-contact-fde1c9d7-df30-4b95-9833-22569c81aa02/1660714770128
example start fragment number: 91343852333181675028929762615222463140535793063
Now you can call:
uv run kvs_consumer_library_example.py {kvs_arn} {start_frag}
...
uv run kvs_consumer_library_example.py rn:aws:kinesisvideo:eu-west-2:759942772963:stream/rap-uat-voicemail-connect-rap-uat-connect-instance-ccaas-001-contact-fde1c9d7-df30-4b95-9833-22569c81aa02/1660714770128 91343852333181675028929762615222463140535793063If you want to capture a live 2-way conversation:
- Put yourself on the
dave rpin the UAT Connect instance. - Make sure you are set to available
- Have someone call
020 4642 5260 - Answer the call
If you don't have an available partner, you can just call 020 4642 5260. If no one is available the IVR leads you to pseudo voicemail service.
The Contact Flow associated with 020 4642 5260 triggers a Lambda called event-printer. This logs all the details you'll need to invoke the streaming script as described above.
Now all conversational snippets should make their way to the dispatches/ directory as two separate audio streams.
Audio is pulled off the KVS Stream live, each fragment is added to a buffer. Once the buffer fills to configured mx size the buffer is sliced somewhere between the configured min and max chunk size and that chunk is sent to dispatch.
Sample audio from a live rip can be found here