Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 3 additions & 0 deletions examples/540-livekit-example-node/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
DEEPGRAM_API_KEY=your_deepgram_api_key
LIVEKIT_API_KEY=your_livekit_api_key
LIVEKIT_HOST=http://your-livekit-host-url
4 changes: 4 additions & 0 deletions examples/540-livekit-example-node/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Environment variables for Livekit and Deepgram integration example
DEEPGRAM_API_KEY=
LIVEKIT_API_KEY=
LIVEKIT_HOST=
80 changes: 80 additions & 0 deletions examples/540-livekit-example-node/BLOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Building a Livekit and Deepgram Integration in Node.js

Integrating audio streaming services with transcription capabilities can greatly enhance real-time communication applications. In this guide, we'll explore how to integrate Livekit, a popular audio/video conferencing API, with Deepgram, a leading speech-to-text service, using Node.js.

## Prerequisites

Before diving in, ensure you have the following:

- **Node.js** installed on your machine.
- A **Deepgram API key**. Sign up at [Deepgram](https://deepgram.com) if you haven't yet.
- A **Livekit account** or a local Livekit server setup. [Livekit Documentation](https://docs.livekit.io) provides details on getting started.

## Step 1: Setup Your Node.js Environment

First, create a new directory for your project and initialize a Node.js project:

```bash
mkdir livekit-deepgram-integration
cd livekit-deepgram-integration
npm init -y
```

Install the necessary dependencies:

```bash
npm install @deepgram/sdk livekit-server-sdk dotenv
```

We'll use `dotenv` to manage environment variables, `@deepgram/sdk` for Deepgram API interactions, and `livekit-server-sdk` for Livekit operations.

## Step 2: Configuring Environment Variables

Create a `.env` file to store your API keys and server details:

```plaintext
DEEPGRAM_API_KEY=your_deepgram_api_key
LIVEKIT_API_KEY=your_livekit_api_key
LIVEKIT_HOST=https://your-livekit-host
```

Make sure to replace the placeholder values with your actual credentials.

## Step 3: Implement the Integration

Create a new file `src/index.js` where we'll write the integration code:

```javascript
require('dotenv').config();
const { Deepgram } = require('@deepgram/sdk');
const { connect } = require('livekit-server-sdk');

// Initialize Deepgram SDK
const deepgram = new Deepgram(process.env.DEEPGRAM_API_KEY);

// Connect to Livekit
async function connectToLivekit() {
const livekitHost = process.env.LIVEKIT_HOST;
const livekitApiKey = process.env.LIVEKIT_API_KEY;

const room = await connect(livekitHost, livekitApiKey);

// Add your logic for handling audio streams from Livekit and sending them to Deepgram here
}

connectToLivekit().catch(console.error);
```

## Step 4: Running the Example

With everything set up, run your application:

```bash
node src/index.js
```

If configured correctly, the app will connect to the Livekit server, and you should see transcriptions of any audio input in the console.

## What's Next?

Explore more with handling multiple streams or integrating video capabilities using Livekit. Check Deepgram's advanced models for transcription to improve accuracy.
26 changes: 26 additions & 0 deletions examples/540-livekit-example-node/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Livekit and Deepgram Integration Example (Node.js)

This example demonstrates how to integrate Livekit with Deepgram for real-time audio transcription using Node.js.

## Prerequisites

- Node.js and npm installed
- Deepgram API Key
- Livekit cloud account or local server setup

## Environment Variables

- `DEEPGRAM_API_KEY`: Your Deepgram API key
- `LIVEKIT_API_KEY`: Your Livekit API key (if using Livekit cloud)
- `LIVEKIT_HOST`: Host URL for Livekit server

## Running the Example

1. Clone the repository and navigate to this example's directory.
2. Install the dependencies with `npm install`.
3. Set up the `.env` file using `.env.example` as a template.
4. Run the example using `node src/index.js`.

## What to Expect

Once the application is running, it will connect to a Livekit room and start transcribing any audio input in real-time using Deepgram. The transcriptions will be printed in the console.
158 changes: 158 additions & 0 deletions examples/540-livekit-example-node/node_modules/.package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading