1. SDKs & Tools
  2. SDKs
  3. Node SDK
  4. Streaming Transcription

Streaming Transcription

The transcription.live function encapsulates a websocket connection to the Deepgram API and returns a Node.js event emitter. Events received from the Deepgram API are emitted for consumption by your application.

Parameters

Additional options can be provided for streaming transcriptions. They are provided as an object of the transcription.live function. Each of these parameters map to a feature in the Deepgram API. Reference the features documentation to learn what features may be appropriate for your request.

OptionType
modelstring
versionstring
languagestring
punctuateboolean
profanity_filterboolean
redact[string]
diarizeboolean
multichannelboolean
alternativesnumber
numeralsboolean
search[string]
callbackstring
keywords[string]
interim_resultsboolean
endpointingboolean
vad_turnoffnumber
encodingstring
channelsnumber
sample_ratenumber

Initiating a Connection

The transcription.live function will return a Node.js event emitter that your application can subscribe to events on.

const deepgramLive = deepgram.transcription.live({
  punctuate: true,
  // additional options
})

Events

The following events are fired by the live transcription object:

EventDescriptionData
openThe websocket connection to Deepgram has been opened.The DG live transcription object
closeThe websocket connection to Deepgram has been closed.WebSocket.CloseEvent
errorAn error occurred with the websocket connectionError object
transcriptReceivedDeepgram has responded with a transcriptionTranscription response

Listening to Events

Use the addListener function to listen for events fired on the object returned from the transcription.live function.

deepgramLive.addListener('transcriptReceived', (transcription) => {
  console.log(transcription.data)
})

Functions

The object returned by the transcription.live function provides several functions to make using the Deepgram API easier. They are send, getReadyState, and finish.

Sending Data

The send function sends raw audio data to the Deepgram API.

deepgramLive.send(AUDIO_STREAM_DATA)

Get Ready State

The getReadyState function returns the ready state of the websocket connection to Deepgram.

const websocketReadyState = deepgramLive.getReadyState()

Closing the Connection

The finish function closes the Websocket connection to Deepgram.

deepgramLive.finish()

FEEDBACK