{"_id":"@caleblawson/voice-openai-realtime","name":"@caleblawson/voice-openai-realtime","dist-tags":{"latest":"0.10.2"},"versions":{"0.10.2":{"name":"@caleblawson/voice-openai-realtime","version":"0.10.2","description":"Mastra OpenAI Realtime API integration","type":"module","main":"dist/index.js","types":"dist/index.d.ts","exports":{".":{"import":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"require":{"types":"./dist/index.d.cts","default":"./dist/index.cjs"}},"./package.json":"./package.json"},"license":"Elastic-2.0","dependencies":{"openai-realtime-api":"^1.0.7","ws":"^8.18.2","zod-to-json-schema":"^3.24.5"},"devDependencies":{"@microsoft/api-extractor":"^7.52.8","@types/node":"^20.19.0","@types/ws":"^8.18.1","eslint":"^9.28.0","tsup":"^8.5.0","typescript":"^5.8.3","vitest":"^2.1.9","zod":"^3.25.57","@internal/lint":"0.0.13","@mastra/core":"npm:@caleblawson/core@0.10.7-alpha.0"},"peerDependencies":{"@mastra/core":"^0.10.0-alpha.0","zod":"^3.0.0"},"scripts":{"build":"tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake","build:watch":"pnpm build --watch","test":"vitest run","lint":"eslint ."},"gitHead":"c31e90130a5c9765c23f688ecea70adc6164543d","_id":"@caleblawson/voice-openai-realtime@0.10.2","_integrity":"sha512-FMZJ/rNwj5WKeKnYhwZslaM4JrwvaPVrQ6uyKmfTZ4pFiHxq5eOTNVBbZVL58Vo2AigD/xkQlHAtL/xj1r491Q==","_resolved":"C:\\Users\\caleb\\AppData\\Local\\Temp\\5856bb7567be4fd07bfa3f5116a8ffbf\\caleblawson-voice-openai-realtime-0.10.2.tgz","_from":"file:caleblawson-voice-openai-realtime-0.10.2.tgz","_nodeVersion":"21.2.0","_npmVersion":"10.2.3","dist":{"integrity":"sha512-FMZJ/rNwj5WKeKnYhwZslaM4JrwvaPVrQ6uyKmfTZ4pFiHxq5eOTNVBbZVL58Vo2AigD/xkQlHAtL/xj1r491Q==","shasum":"b6a90e22c32e0f41350ee5cfab16caf0aa9d3d93","tarball":"https://registry.npmjs.org/@caleblawson/voice-openai-realtime/-/voice-openai-realtime-0.10.2.tgz","fileCount":18,"unpackedSize":124635,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCICUC3Do10tOYLFDYXYDwl8D/RLFElP+mSClbTGDnYpvdAiEAwm49b4CDZimHadPHqYhh6kyRSU5tOOZ1UcOU+tOLSj0="}]},"_npmUser":{"name":"caleblawson","email":"caleb.lawson@dynapt.com","actor":{"name":"caleblawson","email":"caleb.lawson@dynapt.com","type":"user"}},"directories":{},"maintainers":[{"name":"caleblawson","email":"caleb.lawson@dynapt.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/voice-openai-realtime_0.10.2_1750741061586_0.5166679495295565"},"_hasShrinkwrap":false}},"time":{"created":"2025-06-24T04:57:41.455Z","0.10.2":"2025-06-24T04:57:41.762Z","modified":"2025-06-24T04:57:42.063Z"},"maintainers":[{"name":"caleblawson","email":"caleb.lawson@dynapt.com"}],"description":"Mastra OpenAI Realtime API integration","license":"Elastic-2.0","readme":"# @mastra/voice-openai-realtime\r\n\r\nOpenAI Realtime Voice integration for Mastra, providing real-time voice interaction capabilities using OpenAI's WebSocket-based API. This integration enables seamless voice conversations with real-time speech to speech capabilities.\r\n\r\n## Installation\r\n\r\n```bash\r\nnpm install @mastra/voice-openai-realtime\r\n```\r\n\r\n## Configuration\r\n\r\nThe module requires an OpenAI API key, which can be provided through environment variables or directly in the configuration:\r\n\r\n```bash\r\nOPENAI_API_KEY=your_api_key\r\n```\r\n\r\n## Usage\r\n\r\n```typescript\r\nimport { OpenAIRealtimeVoice } from '@mastra/voice-openai-realtime';\r\nimport { getMicrophoneStream } from '@mastra/node-audio';\r\n\r\n// Create a voice instance with default configuration\r\nconst voice = new OpenAIRealtimeVoice();\r\n\r\n// Create a voice instance with configuration\r\nconst voice = new OpenAIRealtimeVoice({\r\n  apiKey: 'your-api-key', // Optional, can use OPENAI_API_KEY env var\r\n  model: 'gpt-4o-mini-realtime', // Optional, uses latest model by default\r\n});\r\n\r\nvoice.updateSession({\r\n  turn_detection: {\r\n    type: 'server_vad',\r\n    threshold: 0.5,\r\n    silence_duration_ms: 1000,\r\n  },\r\n});\r\n\r\n// Connect to the realtime service\r\nawait voice.open();\r\n\r\n// Audio data from voice provider\r\nvoice.on('speaking', (audioData: Int16Array) => {\r\n  // Handle audio data\r\n});\r\n\r\n// Text data from voice provider\r\nvoice.on('writing', (text: string) => {\r\n  // Handle transcribed text\r\n});\r\n\r\n// Error from voice provider\r\nvoice.on('error', (error: Error) => {\r\n  console.error('Voice error:', error);\r\n});\r\n\r\n// Generate speech\r\nawait voice.speak('Hello from Mastra!', {\r\n  speaker: 'echo', // Optional: override default speaker\r\n});\r\n\r\n// Listen to audio input\r\nawait voice.listen(audioData);\r\n\r\n// Process audio input\r\nconst microphoneStream = getMicrophoneStream();\r\nawait voice.send(microphoneStream);\r\n\r\n// Clean up\r\nvoice.close();\r\n```\r\n\r\n## Features\r\n\r\n- Real-time voice interactions via WebSocket\r\n- Seamless speech to speech\r\n- Voice activity detection (VAD)\r\n- Multiple voice options\r\n- Event-based audio streaming\r\n- Tool integration support\r\n\r\n## Voice Options\r\n\r\nAvailable voices include:\r\n\r\n- alloy (Neutral)\r\n- ash (Balanced)\r\n- echo (Warm)\r\n- shimmer (Clear)\r\n- coral (Expressive)\r\n- sage (Professional)\r\n- ballad (Melodic)\r\n- verse (Dynamic)\r\n\r\n## Events\r\n\r\nThe voice instance emits several events:\r\n\r\n- `speaking`: Emitted while generating speech, provides Int16Array audio data\r\n- `writing`: Emitted when speech is transcribed to text\r\n- `error`: Emitted when an error occurs\r\n\r\nYou can also listen to OpenAI Realtime [sdk utility events](https://github.com/openai/openai-realtime-api-beta/tree/main?tab=readme-ov-file#reference-client-utility-events) by prefixing with 'openAIRealtime:', such as:\r\n\r\n- `openAIRealtime:conversation.item.completed`\r\n- `openAIRealtime:conversation.updated`\r\n\r\n## Voice Activity Detection\r\n\r\nThe realtime voice integration includes server-side VAD (Voice Activity Detection) with configurable parameters:\r\n\r\n```typescript\r\nvoice.updateConfig({\r\n  voice: 'echo',\r\n  turn_detection: {\r\n    type: 'server_vad',\r\n    threshold: 0.5, // Speech detection sensitivity\r\n    silence_duration_ms: 1000, // Wait time before ending turn\r\n    prefix_padding_ms: 1000, // Audio padding before speech\r\n  },\r\n});\r\n```\r\n\r\n## Tool Integration\r\n\r\nYou can add tools to the voice instance with tools that extend its capabilities:\r\n\r\n```typescript\r\nexport const menuTool = createTool({\r\n  id: 'menuTool',\r\n  description: 'Get menu items',\r\n  inputSchema: z\r\n    .object({\r\n      query: z.string(),\r\n    })\r\n    .required(),\r\n  execute: async ({ context }) => {\r\n    // Implement menu search functionality\r\n  },\r\n});\r\n\r\nvoice.addTools(menuTool);\r\n```\r\n\r\n## API Reference\r\n\r\nFor detailed API documentation, refer to the JSDoc comments in the source code or generate documentation using TypeDoc.\r\n","readmeFilename":"README.md","_rev":"1-c1b9ce1980c455022b665027bfbae9d6"}