Installation
Install the Stream Deepgram plugin withExample
Check out our Deepgram example to see a practical implementation of the plugin and get inspiration for your own projects, or read on for some key details.Initialisation
The Deepgram plugin for Stream exists in the form of theSTT
class:
To initialise without passing in the API key, make sure the
DEEPGRAM_API_KEY
is available as an environment variable.
You can do this either by defining it in a .env
file or exporting it directly in your terminal.Parameters
These are the parameters available in the DeepgramSTT plugin for you to customise:Name | Type | Default | Description |
---|---|---|---|
api_key | str or None | None | Your Deepgram API key. If not provided, the plugin will use the DEEPGRAM_API_KEY environment variable. |
options | LiveOptions or None | None | Optional Deepgram configuration options, such as tier, model, or features like punctuation or diarization. |
sample_rate | int | 48000 | The sample rate (in Hz) of the audio stream being transcribed. |
language | str | "en-US" | Language code for transcription. |
keep_alive_interval | float | 3.0 | Interval (in seconds) for sending keep-alive messages to maintain the WebSocket connection. |
interim_results | bool | True | Whether to receive partial_transcript events when speaking. |
Functionality
Process Audio
Once you join the call, you can listen to the connection for audio events. You can then pass along the audio events for the STT class to process:Events
Transcript Event
The transcript even is triggered when a final transcript is available from Deepgram:Partial Transcript Event
The partial transcript event is fired in real time as Deepgram generates intermediate (partial) transcriptions:Error Event
If an error occurs, an error event is fired:Close
You can close the STT connection with theclose()
method: