Skip to main content

Voice Transcription

Voice transcription extension allows you to convert an audio message into text.

Before you begin

  1. Sign up with Rev.ai
  2. Get your Access Token for configuring this extension.

Extension settings

  1. Login to CometChat and select your app.
  2. Go to the Extensions section and enable the Voice Transcription extension.
  3. Open the Settings for this extension.
  4. Enter the Rev.ai Access Token, and click on save.

How does it work?

Once the Extension is enabled for your App and the settings are done, the recipients will receive metadata with the transcription details.

The transcription information will be updated later for the message and hence you need to implement the onMessageEdited listener. Please check our Edit ,message documentation under the SDK of your choice.

Here is a sample response:

"@injected": {
"extensions": {
"voice-transcription": {
"transcribed_message": "This is a test"
}
}

If the voice-transcription key is missing, it means that either the extension is not enabled or has timed out.

Implementation

At the recipients' end, from the message object, you can fetch the metadata by calling the getMetadata() method. Using this metadata, you can fetch the Rich Media Embed.

var metadata = message.getMetadata();
if (metadata != null) {
var injectedObject = metadata["@injected"];
if (injectedObject != null && injectedObject.hasOwnProperty("extensions")) {
var extensionsObject = injectedObject["extensions"];
if (
extensionsObject != null &&
extensionsObject.hasOwnProperty("voice-transcription")
) {
var voiceTranscriptionObject = extensionsObject["voice-transcription"];
var transcribed_message = voiceTranscriptionObject["transcribed_message"];
}
}
}