Installation
Set up Micdrop server with WebSocket support for real-time voice conversations.
Package Installation
npm install @micdrop/serverBasic WebSocket Server
Create a simple voice server using the Node.js WebSocket library:
1. Install Dependencies
# Install Micdrop server and WebSocketnpm install @micdrop/server wsnpm install -D @types/ws
# Install AI providersnpm install @micdrop/openai @micdrop/gladia @micdrop/elevenlabs2. Create server.ts
import { MicdropServer } from '@micdrop/server'import { ElevenLabsTTS } from '@micdrop/elevenlabs'import { GladiaSTT } from '@micdrop/gladia'import { OpenaiAgent } from '@micdrop/openai'import { WebSocketServer } from 'ws'
const wss = new WebSocketServer({ port: 8081 })
wss.on('connection', (socket) => { // Setup AI components const agent = new OpenaiAgent({ apiKey: process.env.OPENAI_API_KEY || '', systemPrompt: 'You are a helpful voice assistant. Keep responses concise.', })
const stt = new GladiaSTT({ apiKey: process.env.GLADIA_API_KEY || '', })
const tts = new ElevenLabsTTS({ apiKey: process.env.ELEVENLABS_API_KEY || '', voiceId: process.env.ELEVENLABS_VOICE_ID || '', })
// Create voice conversation handler new MicdropServer(socket, { firstMessage: 'Hello! How can I help you today?', agent, stt, tts, })})
console.log('🎤 Micdrop server running on ws://localhost:8081')Of course you can use any other providers, see AI Integrations for more details.
3. Environment Setup
Create a .env file:
OPENAI_API_KEY=your_openai_api_key_hereELEVENLABS_API_KEY=your_elevenlabs_api_key_hereELEVENLABS_VOICE_ID=your_preferred_voice_idGLADIA_API_KEY=your_gladia_api_key_here4. Run Server
# Install tsx for TypeScript executionnpm install -g tsx
# Run the servertsx server.ts
# Or compile and runnpx tsc server.tsnode server.js