@micdrop/openai
v1.3.0
Published
OpenAI implementation for @micdrop/server
Readme
@micdrop/openai
Micdrop website | Documentation
OpenAI implementation for @micdrop/server.
Installation
npm install @micdrop/openaiOpenAI Agent
Usage
import { OpenaiAgent } from '@micdrop/openai'
import { MicdropServer } from '@micdrop/server'
const agent = new OpenaiAgent({
apiKey: process.env.OPENAI_API_KEY || '',
model: 'gpt-4o', // Default model
systemPrompt: 'You are a helpful assistant',
// Advanced features (optional)
autoEndCall: true, // Automatically end call when user requests
autoSemanticTurn: true, // Handle incomplete sentences
autoIgnoreUserNoise: true, // Filter out meaningless sounds
// Custom OpenAI settings (optional)
settings: {
temperature: 0.7,
max_output_tokens: 150,
},
})
// Use with MicdropServer
new MicdropServer(socket, {
agent,
// ... other options
})OpenAI STT (Speech-to-Text)
Usage
import { OpenaiSTT } from '@micdrop/openai'
import { MicdropServer } from '@micdrop/server'
const stt = new OpenaiSTT({
apiKey: process.env.OPENAI_API_KEY || '',
model: 'gpt-4o-transcribe',
language: 'en',
})
// Use with MicdropServer
new MicdropServer(socket, {
stt,
// ... other options
})OpenAI TTS (Text-to-Speech)
Usage
import { OpenaiTTS } from '@micdrop/openai'
import { MicdropServer } from '@micdrop/server'
const tts = new OpenaiTTS({
apiKey: process.env.OPENAI_API_KEY || '',
model: 'gpt-4o-mini-tts', // Default model
voice: 'alloy', // Default voice
// Prosody control, only for gpt-4o-mini-tts (optional)
instructions: 'Speak in a calm and friendly tone',
// Speech speed from 0.25 to 4.0, only for tts-1 / tts-1-hd (optional)
// speed: 1,
})
// Use with MicdropServer
new MicdropServer(socket, {
tts,
// ... other options
})Language: OpenAI's speech API has no language parameter, the voice follows the language of the input text. To influence the spoken language or accent, use
instructions(e.g.'Speak in French') with thegpt-4o-mini-ttsmodel.
Documentation
Read full documentation of the OpenAI integration for Micdrop on the website.
License
MIT
Author
Originally developed for Raconte.ai and open sourced by Lonestone (GitHub)
