Logo

Deepgram

Orate supports Deepgram's speech and transcription services.

Deepgram’s voice AI platform provides APIs for speech-to-text, text-to-speech, and full speech-to-speech voice agents.

Setup

The Deepgram provider is available by default in Orate. To import it, you can use the following code:

import { Deepgram } from 'orate/deepgram';

Configuration

You can use Deepgram by creating a new instance of the Deepgram class:

const deepgram = new Deepgram();

This will use the DEEPGRAM_API_KEY environment variable. If you don't have this variable set, you can pass your API key as an argument to the constructor.

const deepgram = new Deepgram('your_api_key');

Usage

The Deepgram provider provides a single interface for all of Deepgram's speech and transcription services.

Text to Speech

The Deepgram provider provides a tts function that allows you to create a text-to-speech synthesis function using Deepgram TTS. By default, the tts function uses the aura model with the asteria-en voice.

import { speak } from 'orate';
import { Deepgram } from 'orate/deepgram';
 
const speech = await speak({
  model: new Deepgram().tts(),
  prompt: 'Hello, world!',
});

You can specify the model and voice to use by passing them as arguments to the tts function.

const speech = await speak({
  model: new Deepgram().tts('aura', 'luna-en'),
  prompt: 'Hello, world!',
});

You can also specify specific Deepgram properties by passing them as an argument to the tts function.

const speech = await speak({
  model: new Deepgram().tts('aura', 'luna-en', {
    sample_rate: 16000
  }),
  prompt: 'Hello, world!',
});

You can also stream the speech.

const speech = await speak({
  model: new Deepgram().tts(),
  prompt: 'Hello, world!',
  stream: true,
});

Speech to Text

The Deepgram provider provides a stt function that allows you to create a speech-to-text transcription function using Deepgram's speech-to-text model. By default, the stt function uses the nova-2 model.

import { transcribe } from 'orate';
import { Deepgram } from 'orate/deepgram';
 
const text = await transcribe({
  model: new Deepgram().stt(),
  audio: new File(...),
});

You can specify the model to use by passing it as an argument to the stt function.

const text = await transcribe({
  model: new Deepgram().stt('enhanced'),
  audio: new File(...),
});

You can also specify specific Deepgram properties by passing them as an argument to the stt function.

const text = await transcribe({
  model: new Deepgram().stt('enhanced', {
    filler_words: true,
  }),
  audio: new File(...),
});

You can also stream the transcription.

const text = await transcribe({
  model: new Deepgram().stt(),
  audio: new File(...),
  stream: true,
});

On this page