Use Cases

Use Voicegain to Transcribe Encrypted Twilio Recordings

Twilio platform supports encrypted call recordings. Here is Twillo documentation regarding how to setup encryption for the recordings on their platform.

Voicegain platform supports direct intake of encrypted recordings from the Twilio platform.

The overall diagram of how all of the components work together is as follows:


Bellow we describe how to configure a setup that will automatically submit encrypted recordings from Twilio to Voicegain transcription as soon as those recordings are completed.

Configure the Private Key for decryption

Voicegain will require a Private Key in a PKCS#8 format to decrypt Twilio recordings. Twilio documentation describes how to generate a Private Key in that format.

Once you have the key, you need to upload it via Voicegain Web Console to the Context that you will be using for transcription. This can be done via Settings -> API Security -> Auth Configuration. You need to choose Type: Twilio Encrypted Recording.


Configure AWS Lambda function

We will be handling Twilio recording callbacks using an AWS Lambda function, but you can use an equivalent from a different Cloud platform or you can have your own service that handles https callbacks.

A sample AWS Lambda function in Python is available on Voicegain Github: platform/ at master · voicegain/platform (

You will need to modify that function before it can be used.

First you need to enter the following parameters:

  • voicegainJwt - you need to get the JWT from the same Context that you uploaded the Private Key to
  • myAuthConf - this is the name under which you uploaded the Private Key
  • expectedPublicKeyId - this is the name under which, on Twilio platform, you uploaded the Public Key

The Lambda function receives the callback from Twilio, parses the relevant info from it, and then submits a request to Voicegain STT API for OFFLINE transcription. If you want, you can modify, in the Lambda function code, the body of the request that will be submitted to Voicegain. For example, the github sample submits the results of transcription to be viewable in the Web Console (Portal), but you will likely want to change that, so that the results are submitted via a Callback to your HTTPS endpoint (there is a comment indicating where the change would need to be made).

You can also make other changes to the body of the request as needed. For the complete spec of the Voicegain Transcribe API see here.

Run a Test

Here is a simple python code that can be used to make an outbound Twilio call which will be recorded and then submitted for transcription.

Notice that:

  • We set the URL of the Lambda function in recordingStatusCallback.
  • And we tell Twilio to make the callback only when the call recording is completed in recordingStatusCallbackEvent.

Sign up for an app today
* No credit card required.


Interested in customizing the ASR or deploying Voicegain on your infrastructure?

Contact Us → 
Voicegain - Speech-to-Text
Under Your Control