@mastra/voice-openai-realtime 0.13.8-alpha.0 → 0.13.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -84
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -8,27 +8,15 @@ OpenAI Realtime Voice integration for Mastra, providing real-time voice interact
|
|
|
8
8
|
npm install @mastra/voice-openai-realtime
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
## Configuration
|
|
12
|
-
|
|
13
|
-
The module requires an OpenAI API key, which can be provided through environment variables or directly in the configuration:
|
|
14
|
-
|
|
15
|
-
```bash
|
|
16
|
-
OPENAI_API_KEY=your_api_key
|
|
17
|
-
```
|
|
18
|
-
|
|
19
11
|
## Usage
|
|
20
12
|
|
|
21
13
|
```typescript
|
|
22
14
|
import { OpenAIRealtimeVoice } from '@mastra/voice-openai-realtime';
|
|
23
15
|
import { getMicrophoneStream } from '@mastra/node-audio';
|
|
24
16
|
|
|
25
|
-
// Create a voice instance with default configuration
|
|
26
|
-
const voice = new OpenAIRealtimeVoice();
|
|
27
|
-
|
|
28
|
-
// Create a voice instance with configuration
|
|
29
17
|
const voice = new OpenAIRealtimeVoice({
|
|
30
|
-
apiKey:
|
|
31
|
-
model: 'gpt-4o-mini-realtime',
|
|
18
|
+
apiKey: process.env.OPENAI_API_KEY,
|
|
19
|
+
model: 'gpt-4o-mini-realtime',
|
|
32
20
|
});
|
|
33
21
|
|
|
34
22
|
voice.updateSession({
|
|
@@ -73,78 +61,14 @@ await voice.send(microphoneStream);
|
|
|
73
61
|
voice.close();
|
|
74
62
|
```
|
|
75
63
|
|
|
76
|
-
##
|
|
77
|
-
|
|
78
|
-
- Real-time voice interactions via WebSocket
|
|
79
|
-
- Seamless speech to speech
|
|
80
|
-
- Voice activity detection (VAD)
|
|
81
|
-
- Multiple voice options
|
|
82
|
-
- Event-based audio streaming
|
|
83
|
-
- Tool integration support
|
|
84
|
-
|
|
85
|
-
## Voice Options
|
|
86
|
-
|
|
87
|
-
Available voices include:
|
|
88
|
-
|
|
89
|
-
- alloy (Neutral)
|
|
90
|
-
- ash (Balanced)
|
|
91
|
-
- echo (Warm)
|
|
92
|
-
- shimmer (Clear)
|
|
93
|
-
- coral (Expressive)
|
|
94
|
-
- sage (Professional)
|
|
95
|
-
- ballad (Melodic)
|
|
96
|
-
- verse (Dynamic)
|
|
97
|
-
|
|
98
|
-
## Events
|
|
99
|
-
|
|
100
|
-
The voice instance emits several events:
|
|
101
|
-
|
|
102
|
-
- `speaking`: Emitted while generating speech, provides Int16Array audio data
|
|
103
|
-
- `writing`: Emitted when speech is transcribed to text
|
|
104
|
-
- `error`: Emitted when an error occurs
|
|
105
|
-
|
|
106
|
-
You 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:
|
|
107
|
-
|
|
108
|
-
- `openAIRealtime:conversation.item.completed`
|
|
109
|
-
- `openAIRealtime:conversation.updated`
|
|
64
|
+
## Documentation
|
|
110
65
|
|
|
111
|
-
|
|
66
|
+
- [@mastra/voice-openai-realtime documentation](https://mastra.ai/integrations/voice/openai)
|
|
112
67
|
|
|
113
|
-
|
|
68
|
+
## Changelog
|
|
114
69
|
|
|
115
|
-
|
|
116
|
-
voice.updateConfig({
|
|
117
|
-
voice: 'echo',
|
|
118
|
-
turn_detection: {
|
|
119
|
-
type: 'server_vad',
|
|
120
|
-
threshold: 0.5, // Speech detection sensitivity
|
|
121
|
-
silence_duration_ms: 1000, // Wait time before ending turn
|
|
122
|
-
prefix_padding_ms: 1000, // Audio padding before speech
|
|
123
|
-
},
|
|
124
|
-
});
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
## Tool Integration
|
|
128
|
-
|
|
129
|
-
You can add tools to the voice instance with tools that extend its capabilities:
|
|
130
|
-
|
|
131
|
-
```typescript
|
|
132
|
-
export const menuTool = createTool({
|
|
133
|
-
id: 'menuTool',
|
|
134
|
-
description: 'Get menu items',
|
|
135
|
-
inputSchema: z
|
|
136
|
-
.object({
|
|
137
|
-
query: z.string(),
|
|
138
|
-
})
|
|
139
|
-
.required(),
|
|
140
|
-
execute: async (inputData, context) => {
|
|
141
|
-
// Implement menu search functionality
|
|
142
|
-
},
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
voice.addTools(menuTool);
|
|
146
|
-
```
|
|
70
|
+
See the [package changelog](https://github.com/mastra-ai/mastra/blob/main/voice/openai-realtime-api/CHANGELOG.md) for version history and release notes.
|
|
147
71
|
|
|
148
|
-
##
|
|
72
|
+
## Support
|
|
149
73
|
|
|
150
|
-
|
|
74
|
+
We have an [open community Discord](https://discord.gg/mastra-ai). Come and say hello and let us know if you have any questions or need any help getting things running.
|
package/dist/docs/SKILL.md
CHANGED
|
@@ -3,7 +3,7 @@ name: mastra-voice-openai-realtime
|
|
|
3
3
|
description: Documentation for @mastra/voice-openai-realtime. Use when working with @mastra/voice-openai-realtime APIs, configuration, or implementation.
|
|
4
4
|
metadata:
|
|
5
5
|
package: "@mastra/voice-openai-realtime"
|
|
6
|
-
version: "0.13.8
|
|
6
|
+
version: "0.13.8"
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
## When to use
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/voice-openai-realtime",
|
|
3
|
-
"version": "0.13.8
|
|
3
|
+
"version": "0.13.8",
|
|
4
4
|
"description": "Mastra OpenAI Realtime API integration",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"openai-realtime-api": "^1.0.8",
|
|
27
27
|
"ws": "^8.21.0",
|
|
28
|
-
"@mastra/schema-compat": "1.3.8
|
|
28
|
+
"@mastra/schema-compat": "1.3.8"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/node": "22.20.1",
|
|
@@ -38,9 +38,9 @@
|
|
|
38
38
|
"typescript": "^7.0.2",
|
|
39
39
|
"vitest": "4.1.10",
|
|
40
40
|
"zod": "^4.4.3",
|
|
41
|
-
"@internal/
|
|
42
|
-
"@internal/
|
|
43
|
-
"@internal/
|
|
41
|
+
"@internal/voice": "0.0.28",
|
|
42
|
+
"@internal/types-builder": "0.0.105",
|
|
43
|
+
"@internal/lint": "0.0.130"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
46
|
"zod": "^3.25.0 || ^4.0.0"
|