@micdrop/client 1.8.1 → 2.0.0
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 +81 -30
- package/dist/index.d.mts +192 -96
- package/dist/index.d.ts +192 -96
- package/dist/index.js +675 -664
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +665 -657
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -5
package/README.md
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
|
+
# 🖐️🎤 Micdrop: Real-Time Voice Conversations with AI
|
|
2
|
+
|
|
3
|
+
Micdrop is a set of open source Typescript packages to build real-time voice conversations with AI agents. It handles all the complexities on the browser and server side (microphone, speaker, VAD, network communication, etc) and provides ready-to-use implementations for various AI providers.
|
|
4
|
+
|
|
1
5
|
# @micdrop/client
|
|
2
6
|
|
|
3
|
-
|
|
7
|
+
The browser implementation of [Micdrop](../../README.md).
|
|
8
|
+
|
|
9
|
+
It is framework agnostic, you can use it with React, Vue, Angular or any other framework. See [demo-client](../../examples/demo-client/README.md) for a complete example with React.
|
|
4
10
|
|
|
5
11
|
For server implementation, see [@micdrop/server](../server/README.md) package.
|
|
6
12
|
|
|
@@ -31,58 +37,100 @@ pnpm add @micdrop/client
|
|
|
31
37
|
|
|
32
38
|
## Quick Start
|
|
33
39
|
|
|
40
|
+
### Start a call
|
|
41
|
+
|
|
42
|
+
`Micdrop` is a singleton instance of `MicdropClient` that can be used to start, stop and manage a call.
|
|
43
|
+
|
|
34
44
|
```typescript
|
|
35
|
-
import {
|
|
45
|
+
import { Micdrop } from '@micdrop/client'
|
|
36
46
|
|
|
37
|
-
//
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
vad: ['volume', 'silero'],
|
|
47
|
+
// Start a call
|
|
48
|
+
await Micdrop.start({
|
|
49
|
+
url: 'wss://your-server.com/ws',
|
|
41
50
|
})
|
|
51
|
+
```
|
|
42
52
|
|
|
43
|
-
|
|
44
|
-
call.url = 'wss://your-server.com/ws'
|
|
45
|
-
call.params = {
|
|
46
|
-
/* your parameters (to check auth, etc) */
|
|
47
|
-
}
|
|
53
|
+
### Control the call
|
|
48
54
|
|
|
49
|
-
|
|
50
|
-
|
|
55
|
+
```typescript
|
|
56
|
+
// Pause/resume
|
|
57
|
+
Micdrop.pause()
|
|
58
|
+
Micdrop.resume()
|
|
59
|
+
|
|
60
|
+
// Stop the call
|
|
61
|
+
await Micdrop.stop()
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Listen for events
|
|
65
|
+
|
|
66
|
+
You can listen for events to get the state of the call and handle errors.
|
|
67
|
+
|
|
68
|
+
```typescript
|
|
69
|
+
Micdrop.on('StateChange', () => {
|
|
51
70
|
console.log('State changed')
|
|
52
71
|
})
|
|
53
|
-
|
|
72
|
+
Micdrop.on('EndCall', () => {
|
|
54
73
|
console.log('Call ended by assistant')
|
|
55
74
|
})
|
|
56
|
-
|
|
75
|
+
Micdrop.on('Error', (error) => {
|
|
57
76
|
console.error('Error occurred:', error)
|
|
58
77
|
})
|
|
78
|
+
```
|
|
59
79
|
|
|
60
|
-
|
|
61
|
-
|
|
80
|
+
### Complete Example
|
|
81
|
+
|
|
82
|
+
```typescript
|
|
83
|
+
import { Micdrop } from '@micdrop/client'
|
|
84
|
+
|
|
85
|
+
// Start a call
|
|
86
|
+
await Micdrop.start({
|
|
87
|
+
// URL of the WebSocket server (using @micdrop/server)
|
|
88
|
+
url: 'wss://your-server.com/ws',
|
|
89
|
+
// Parameters (optional) to check auth or provide other data
|
|
90
|
+
params: {
|
|
91
|
+
authorization: '1234',
|
|
92
|
+
lang: navigator.language,
|
|
93
|
+
},
|
|
94
|
+
// Voice Activity Detection (see docs)
|
|
95
|
+
vad: ['volume', 'silero'],
|
|
96
|
+
// Disable ability for the user to interrupt the assistant when it is speaking
|
|
97
|
+
disableInterruption: true,
|
|
98
|
+
// Enable debug logging
|
|
99
|
+
debugLog: true,
|
|
100
|
+
})
|
|
101
|
+
|
|
102
|
+
// Listen for events
|
|
103
|
+
Micdrop.on('StateChange', (state) => {
|
|
104
|
+
console.log('State:', state)
|
|
105
|
+
})
|
|
106
|
+
Micdrop.on('EndCall', () => {
|
|
107
|
+
console.log('Call ended by assistant')
|
|
108
|
+
})
|
|
109
|
+
Micdrop.on('Error', (error) => {
|
|
110
|
+
console.error('Error occurred:', error)
|
|
111
|
+
})
|
|
62
112
|
|
|
63
113
|
// Pause/resume
|
|
64
|
-
|
|
65
|
-
|
|
114
|
+
Micdrop.pause()
|
|
115
|
+
Micdrop.resume()
|
|
66
116
|
|
|
67
117
|
// Stop the call
|
|
68
|
-
await
|
|
118
|
+
await Micdrop.stop()
|
|
69
119
|
```
|
|
70
120
|
|
|
71
121
|
## Demo
|
|
72
122
|
|
|
73
|
-
Check out the demo implementation in the [
|
|
123
|
+
Check out the demo implementation in the [demo-client example](../../examples/demo-client/README.md) package. It shows:
|
|
74
124
|
|
|
75
125
|
- Setting up a React application with WebSocket communication
|
|
76
|
-
- Configuring the
|
|
126
|
+
- Configuring the MicdropClient with custom parameters
|
|
77
127
|
- Managing microphone input and audio playback
|
|
78
128
|
- Handling conversation state and UI updates
|
|
79
129
|
- Error handling patterns
|
|
80
130
|
|
|
81
|
-
Here's a simplified version from the demo:
|
|
82
|
-
|
|
83
131
|
## Documentation
|
|
84
132
|
|
|
85
|
-
- **[
|
|
133
|
+
- **[MicdropClient](./docs/MicdropClient.md)** - Manages WebSocket connections, audio streaming, and conversation state
|
|
86
134
|
|
|
87
135
|
- **[MicRecorder](./docs/MicRecorder.md)** - Records audio from microphone with voice activity detection and speech events
|
|
88
136
|
|
|
@@ -90,14 +138,19 @@ Here's a simplified version from the demo:
|
|
|
90
138
|
|
|
91
139
|
- **[Speaker](./docs/Speaker.md)** - Handles audio output devices and playback with analysis capabilities
|
|
92
140
|
|
|
141
|
+
- **[VAD](./docs/VAD.md)** - Voice Activity Detection, how to use and customize
|
|
142
|
+
|
|
93
143
|
## Browser Support
|
|
94
144
|
|
|
145
|
+
Fully supported in Chrome, Firefox, Safari and Edge.
|
|
146
|
+
|
|
95
147
|
Requires browsers with support for:
|
|
96
148
|
|
|
97
149
|
- WebSocket API
|
|
98
|
-
- MediaRecorder API
|
|
99
150
|
- Web Audio API
|
|
100
|
-
-
|
|
151
|
+
- MediaDevices API
|
|
152
|
+
- MediaRecorder API
|
|
153
|
+
- MediaSource Extensions (MSE)
|
|
101
154
|
|
|
102
155
|
## License
|
|
103
156
|
|
|
@@ -105,6 +158,4 @@ MIT
|
|
|
105
158
|
|
|
106
159
|
## Author
|
|
107
160
|
|
|
108
|
-
Originally developed for [Raconte.ai](https://www.raconte.ai)
|
|
109
|
-
|
|
110
|
-
by [Lonestone](https://www.lonestone.io) ([GitHub](https://github.com/lonestone))
|
|
161
|
+
Originally developed for [Raconte.ai](https://www.raconte.ai) and open sourced by [Lonestone](https://www.lonestone.io) ([GitHub](https://github.com/lonestone))
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import EventEmitter from 'eventemitter3';
|
|
2
|
-
import {
|
|
2
|
+
import { MicdropConversation as MicdropConversation$1, VAD as VAD$1 } from '@micdrop/client';
|
|
3
|
+
import { Readable } from 'stream';
|
|
3
4
|
|
|
4
5
|
interface AudioAnalyserEvents {
|
|
5
6
|
volume: [number];
|
|
@@ -16,13 +17,11 @@ declare class AudioAnalyser extends EventEmitter<AudioAnalyserEvents> {
|
|
|
16
17
|
private getMaxVolume;
|
|
17
18
|
}
|
|
18
19
|
|
|
19
|
-
declare
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
declare class Mic$1 {
|
|
21
|
+
analyser: AudioAnalyser;
|
|
22
|
+
deviceId: string | undefined;
|
|
22
23
|
private audioStream;
|
|
23
24
|
private sourceNode;
|
|
24
|
-
analyser: AudioAnalyser;
|
|
25
|
-
constructor();
|
|
26
25
|
private getMicConstraints;
|
|
27
26
|
/**
|
|
28
27
|
* Starts the microphone
|
|
@@ -35,10 +34,26 @@ declare class Mic {
|
|
|
35
34
|
*/
|
|
36
35
|
stop(): void;
|
|
37
36
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
37
|
+
|
|
38
|
+
interface SpeakerEvents {
|
|
39
|
+
StartPlaying: void;
|
|
40
|
+
StopPlaying: void;
|
|
41
|
+
}
|
|
42
|
+
declare class Speaker$1 extends EventEmitter<SpeakerEvents> {
|
|
43
|
+
isPlaying: boolean;
|
|
44
|
+
analyser: AudioAnalyser;
|
|
45
|
+
deviceId: string | undefined;
|
|
46
|
+
devices: MediaDeviceInfo[];
|
|
47
|
+
private audioStream?;
|
|
48
|
+
private audioSourceNode?;
|
|
49
|
+
private audioElementDestination?;
|
|
50
|
+
start(): Promise<void>;
|
|
51
|
+
playAudio(blob: Blob): Promise<void>;
|
|
52
|
+
stopAudio(): Promise<void>;
|
|
53
|
+
changeDevice(deviceId: string): Promise<void>;
|
|
54
|
+
get isDefaultDevice(): boolean;
|
|
55
|
+
private setIsPlaying;
|
|
56
|
+
private setDevice;
|
|
42
57
|
}
|
|
43
58
|
|
|
44
59
|
interface VADEvents {
|
|
@@ -58,6 +73,7 @@ declare enum VADStatus {
|
|
|
58
73
|
* VAD = Voice Activity Detection
|
|
59
74
|
*/
|
|
60
75
|
declare abstract class VAD extends EventEmitter<VADEvents> {
|
|
76
|
+
readonly name: string;
|
|
61
77
|
status: VADStatus;
|
|
62
78
|
delay: number;
|
|
63
79
|
/**
|
|
@@ -105,17 +121,17 @@ interface MicRecorderEvents {
|
|
|
105
121
|
}
|
|
106
122
|
declare class MicRecorder extends EventEmitter<MicRecorderEvents> {
|
|
107
123
|
state: MicRecorderState;
|
|
124
|
+
vad: VAD;
|
|
108
125
|
private audioInfo;
|
|
109
|
-
private vad;
|
|
110
126
|
private recorder;
|
|
111
127
|
private delayedStream;
|
|
112
128
|
private speakingConfirmed;
|
|
113
129
|
private queuedChunks;
|
|
114
130
|
constructor(vadConfig?: VADConfig);
|
|
115
|
-
start(stream: MediaStream)
|
|
116
|
-
mute()
|
|
117
|
-
unmute()
|
|
118
|
-
stop()
|
|
131
|
+
start: (stream: MediaStream) => Promise<void>;
|
|
132
|
+
mute: () => void;
|
|
133
|
+
unmute: () => void;
|
|
134
|
+
stop: () => void;
|
|
119
135
|
private startSpeakingDetection;
|
|
120
136
|
private stopSpeakingDetection;
|
|
121
137
|
private onStartSpeaking;
|
|
@@ -127,31 +143,6 @@ declare class MicRecorder extends EventEmitter<MicRecorderEvents> {
|
|
|
127
143
|
private getAudioInfo;
|
|
128
144
|
}
|
|
129
145
|
|
|
130
|
-
declare let speaker: Speaker;
|
|
131
|
-
declare class Speaker {
|
|
132
|
-
private audioElement?;
|
|
133
|
-
private player?;
|
|
134
|
-
private streamingEnabled;
|
|
135
|
-
analyser: AudioAnalyser;
|
|
136
|
-
constructor();
|
|
137
|
-
private setupSpeakerPlayer;
|
|
138
|
-
get isStreamingEnabled(): boolean;
|
|
139
|
-
enableStreaming(): Promise<void>;
|
|
140
|
-
disableStreaming(): Promise<void>;
|
|
141
|
-
canChangeDevice(): boolean;
|
|
142
|
-
private setSinkId;
|
|
143
|
-
changeDevice(speakerId: string): Promise<void>;
|
|
144
|
-
pauseAudio(): void;
|
|
145
|
-
resumeAudio(): void;
|
|
146
|
-
playAudio(blob: Blob): Promise<void>;
|
|
147
|
-
stopAudio(): void;
|
|
148
|
-
}
|
|
149
|
-
declare global {
|
|
150
|
-
interface Window {
|
|
151
|
-
micdropSpeaker: Speaker;
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
|
|
155
146
|
declare enum LocalStorageKeys {
|
|
156
147
|
MicDevice = "micdrop.micDevice",
|
|
157
148
|
SpeakerDevice = "micdrop.speakerDevice",
|
|
@@ -219,108 +210,213 @@ declare class VolumeVAD extends VAD {
|
|
|
219
210
|
resetOptions(): void;
|
|
220
211
|
}
|
|
221
212
|
|
|
222
|
-
declare
|
|
213
|
+
declare const Mic: Mic$1;
|
|
214
|
+
declare const Speaker: Speaker$1;
|
|
215
|
+
|
|
216
|
+
declare enum MicdropClientErrorCode {
|
|
217
|
+
MissingUrl = "MissingUrl",
|
|
223
218
|
Mic = "Mic",
|
|
219
|
+
Connection = "Connection",
|
|
220
|
+
InternalServer = "InternalServer",
|
|
221
|
+
BadRequest = "BadRequest",
|
|
224
222
|
Unauthorized = "Unauthorized",
|
|
225
|
-
|
|
223
|
+
NotFound = "NotFound",
|
|
224
|
+
Unknown = "Unknown"
|
|
226
225
|
}
|
|
227
|
-
declare class
|
|
228
|
-
code:
|
|
229
|
-
constructor(code?:
|
|
226
|
+
declare class MicdropClientError extends Error {
|
|
227
|
+
code: MicdropClientErrorCode;
|
|
228
|
+
constructor(code?: MicdropClientErrorCode, message?: string);
|
|
230
229
|
}
|
|
230
|
+
declare function getClientErrorFromWSCloseEvent(event: CloseEvent): MicdropClientError | undefined;
|
|
231
|
+
declare function getClientErrorFromWSCloseEventCode(code: number): MicdropClientErrorCode | undefined;
|
|
231
232
|
|
|
232
|
-
interface
|
|
233
|
+
interface MicdropEvents {
|
|
233
234
|
EndCall: [];
|
|
234
|
-
Error: [
|
|
235
|
-
StateChange:
|
|
235
|
+
Error: [MicdropClientError];
|
|
236
|
+
StateChange: [MicdropState];
|
|
236
237
|
}
|
|
237
|
-
interface
|
|
238
|
+
interface MicdropOptions {
|
|
239
|
+
url?: string;
|
|
240
|
+
params?: Record<string, any>;
|
|
238
241
|
vad?: VADConfig;
|
|
242
|
+
disableInterruption?: boolean;
|
|
243
|
+
debugLog?: boolean;
|
|
239
244
|
}
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
245
|
+
interface MicdropState {
|
|
246
|
+
isStarting: boolean;
|
|
247
|
+
isStarted: boolean;
|
|
248
|
+
isPaused: boolean;
|
|
249
|
+
isListening: boolean;
|
|
250
|
+
isProcessing: boolean;
|
|
251
|
+
isUserSpeaking: boolean;
|
|
252
|
+
isAssistantSpeaking: boolean;
|
|
253
|
+
isMicStarted: boolean;
|
|
254
|
+
isMicMuted: boolean;
|
|
255
|
+
micDeviceId: string | undefined;
|
|
256
|
+
speakerDeviceId: string | undefined;
|
|
257
|
+
micDevices: MediaDeviceInfo[];
|
|
258
|
+
speakerDevices: MediaDeviceInfo[];
|
|
259
|
+
conversation: MicdropConversation$1;
|
|
260
|
+
error: MicdropClientError | undefined;
|
|
244
261
|
}
|
|
245
|
-
declare class
|
|
246
|
-
|
|
247
|
-
static getInstance<P extends {}, O extends CallClientOptions = CallClientOptions>(options?: O): CallClient<P, O>;
|
|
248
|
-
url?: string;
|
|
249
|
-
params?: Params;
|
|
262
|
+
declare class MicdropClient extends EventEmitter<MicdropEvents> implements MicdropState {
|
|
263
|
+
options: MicdropOptions;
|
|
250
264
|
micRecorder?: MicRecorder;
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
265
|
+
conversation: MicdropConversation$1;
|
|
266
|
+
error: MicdropClientError | undefined;
|
|
267
|
+
speakerDevices: MediaDeviceInfo[];
|
|
268
|
+
micDevices: MediaDeviceInfo[];
|
|
254
269
|
private ws?;
|
|
255
270
|
private micStream?;
|
|
256
271
|
private startTime;
|
|
257
|
-
private lastAudioBlob?;
|
|
258
272
|
private _isProcessing;
|
|
259
|
-
private
|
|
273
|
+
private _isPaused;
|
|
274
|
+
constructor(options?: MicdropOptions);
|
|
275
|
+
get vad(): VAD$1 | undefined;
|
|
260
276
|
get isStarted(): boolean;
|
|
261
277
|
get isStarting(): boolean;
|
|
278
|
+
get isPaused(): boolean;
|
|
279
|
+
get isProcessing(): boolean;
|
|
280
|
+
get isListening(): boolean;
|
|
262
281
|
get isWSStarted(): boolean;
|
|
263
282
|
get isWSStarting(): boolean;
|
|
264
283
|
get isMicStarted(): boolean;
|
|
265
284
|
get isMicMuted(): boolean;
|
|
266
|
-
get
|
|
267
|
-
get
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
285
|
+
get isUserSpeaking(): boolean;
|
|
286
|
+
get isAssistantSpeaking(): boolean;
|
|
287
|
+
get micDeviceId(): string | undefined;
|
|
288
|
+
get speakerDeviceId(): string | undefined;
|
|
289
|
+
get state(): MicdropState;
|
|
290
|
+
start: (options?: MicdropOptions) => Promise<void>;
|
|
291
|
+
stop: () => Promise<void>;
|
|
292
|
+
pause: () => void;
|
|
293
|
+
resume: () => void;
|
|
294
|
+
startMic: ({ vad, deviceId, record, }: {
|
|
295
|
+
vad?: VADConfig;
|
|
296
|
+
deviceId?: string;
|
|
297
|
+
record?: boolean;
|
|
298
|
+
}) => Promise<void>;
|
|
299
|
+
changeMicDevice: (deviceId: string) => Promise<void>;
|
|
300
|
+
changeSpeakerDevice: (deviceId: string) => Promise<void>;
|
|
273
301
|
private stopMic;
|
|
302
|
+
private updateDevices;
|
|
274
303
|
private startWS;
|
|
304
|
+
private onWSOpen;
|
|
305
|
+
private onWSMessage;
|
|
306
|
+
private onWSClose;
|
|
307
|
+
private onWSError;
|
|
275
308
|
private stopWS;
|
|
309
|
+
private onSpeakerStartPlaying;
|
|
310
|
+
private onSpeakerStopPlaying;
|
|
276
311
|
private addMessage;
|
|
312
|
+
private setError;
|
|
277
313
|
private notifyStateChange;
|
|
278
314
|
private log;
|
|
279
315
|
}
|
|
280
316
|
|
|
281
|
-
declare
|
|
317
|
+
declare const Micdrop: MicdropClient;
|
|
318
|
+
|
|
319
|
+
declare class Logger {
|
|
320
|
+
private readonly name;
|
|
321
|
+
constructor(name: string);
|
|
322
|
+
log(...message: any[]): void;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
interface AgentOptions {
|
|
326
|
+
systemPrompt: string;
|
|
327
|
+
}
|
|
328
|
+
interface AgentAnswerReturn {
|
|
329
|
+
message: Promise<string>;
|
|
330
|
+
stream: Readable;
|
|
331
|
+
}
|
|
332
|
+
interface TextPromise {
|
|
333
|
+
promise: Promise<string>;
|
|
334
|
+
resolve: (value: string) => void;
|
|
335
|
+
reject: (reason?: any) => void;
|
|
336
|
+
}
|
|
337
|
+
declare abstract class Agent<Options extends AgentOptions = AgentOptions> extends EventEmitter {
|
|
338
|
+
protected options: Options;
|
|
339
|
+
logger?: Logger;
|
|
340
|
+
conversation: MicdropConversation;
|
|
341
|
+
constructor(options: Options);
|
|
342
|
+
abstract answer(): AgentAnswerReturn;
|
|
343
|
+
abstract cancel(): void;
|
|
344
|
+
addUserMessage(text: string): void;
|
|
345
|
+
addAssistantMessage(text: string): void;
|
|
346
|
+
protected addMessage(role: 'user' | 'assistant' | 'system', text: string): void;
|
|
347
|
+
protected endCall(): void;
|
|
348
|
+
protected cancelLastUserMessage(): void;
|
|
349
|
+
protected cancelLastAssistantMessage(): void;
|
|
350
|
+
protected skipAnswer(): void;
|
|
351
|
+
protected createTextPromise(): TextPromise;
|
|
352
|
+
protected log(...message: any[]): void;
|
|
353
|
+
destroy(): void;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
declare const MIME_TYPE_TO_EXTENSION: {
|
|
357
|
+
readonly 'audio/wav': "wav";
|
|
358
|
+
readonly 'audio/ogg': "ogg";
|
|
359
|
+
readonly 'audio/mpeg': "mp3";
|
|
360
|
+
readonly 'audio/webm': "webm";
|
|
361
|
+
readonly 'audio/mp4': "mp4";
|
|
362
|
+
readonly 'audio/flac': "flac";
|
|
363
|
+
};
|
|
364
|
+
interface STTEvents {
|
|
365
|
+
Transcript: [string];
|
|
366
|
+
}
|
|
367
|
+
declare abstract class STT extends EventEmitter<STTEvents> {
|
|
368
|
+
protected mimeType?: keyof typeof MIME_TYPE_TO_EXTENSION;
|
|
369
|
+
logger?: Logger;
|
|
370
|
+
transcribe(audioStream: Readable): void;
|
|
371
|
+
protected log(...message: any[]): void;
|
|
372
|
+
destroy(): void;
|
|
373
|
+
protected get extension(): string;
|
|
374
|
+
private detectMimeType;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
declare abstract class TTS {
|
|
378
|
+
logger?: Logger;
|
|
379
|
+
abstract speak(textStream: Readable): Readable;
|
|
380
|
+
abstract cancel(): void;
|
|
381
|
+
protected log(...message: any[]): void;
|
|
382
|
+
destroy(): void;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
declare enum MicdropClientCommands {
|
|
282
386
|
StartSpeaking = "StartSpeaking",
|
|
283
387
|
StopSpeaking = "StopSpeaking",
|
|
284
388
|
Mute = "Mute"
|
|
285
389
|
}
|
|
286
|
-
declare enum
|
|
390
|
+
declare enum MicdropServerCommands {
|
|
287
391
|
Message = "Message",
|
|
288
392
|
CancelLastAssistantMessage = "CancelLastAssistantMessage",
|
|
289
393
|
CancelLastUserMessage = "CancelLastUserMessage",
|
|
290
394
|
SkipAnswer = "SkipAnswer",
|
|
291
|
-
EnableSpeakerStreaming = "EnableSpeakerStreaming",
|
|
292
395
|
EndCall = "EndCall"
|
|
293
396
|
}
|
|
294
|
-
interface
|
|
295
|
-
systemPrompt: string;
|
|
397
|
+
interface MicdropConfig {
|
|
296
398
|
firstMessage?: string;
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
}
|
|
306
|
-
interface CallSummary {
|
|
307
|
-
conversation: Conversation;
|
|
399
|
+
generateFirstMessage?: boolean;
|
|
400
|
+
agent: Agent;
|
|
401
|
+
stt: STT;
|
|
402
|
+
tts: TTS;
|
|
403
|
+
onEnd?(call: MicdropCallSummary): void;
|
|
404
|
+
}
|
|
405
|
+
interface MicdropCallSummary {
|
|
406
|
+
conversation: MicdropConversation;
|
|
308
407
|
duration: number;
|
|
309
408
|
}
|
|
310
|
-
type
|
|
311
|
-
type
|
|
312
|
-
endCall?: boolean;
|
|
313
|
-
cancelLastUserMessage?: boolean;
|
|
314
|
-
skipAnswer?: boolean;
|
|
315
|
-
};
|
|
316
|
-
type AnswerMetadata = {
|
|
409
|
+
type MicdropConversation = MicdropConversationMessage[];
|
|
410
|
+
type MicdropAnswerMetadata = {
|
|
317
411
|
[key: string]: any;
|
|
318
412
|
};
|
|
319
|
-
interface
|
|
413
|
+
interface MicdropConversationMessage<Data extends MicdropAnswerMetadata = MicdropAnswerMetadata> {
|
|
320
414
|
role: 'system' | 'user' | 'assistant';
|
|
321
415
|
content: string;
|
|
322
|
-
commands?: AnswerCommands;
|
|
323
416
|
metadata?: Data;
|
|
324
417
|
}
|
|
418
|
+
type DeepPartial<T> = T extends object ? {
|
|
419
|
+
[P in keyof T]?: DeepPartial<T[P]>;
|
|
420
|
+
} : T;
|
|
325
421
|
|
|
326
|
-
export { type
|
|
422
|
+
export { type DeepPartial, LocalStorageKeys, Mic, MicRecorder, type MicRecorderEvents, type MicRecorderState, Micdrop, type MicdropAnswerMetadata, type MicdropCallSummary, MicdropClient, MicdropClientCommands, MicdropClientError, MicdropClientErrorCode, type MicdropConfig, type MicdropConversation, type MicdropConversationMessage, type MicdropEvents, type MicdropOptions, MicdropServerCommands, type MicdropState, MultipleVAD, SileroVAD, type SileroVADOptions, Speaker, VAD, type VADEvents, VADStatus, VolumeVAD, type VolumeVADOptions, getClientErrorFromWSCloseEvent, getClientErrorFromWSCloseEventCode };
|