@micdrop/client 2.0.14 → 2.1.1

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/dist/index.d.mts CHANGED
@@ -79,6 +79,11 @@ declare abstract class VAD extends EventEmitter<VADEvents> {
79
79
  * @returns True if the VAD is started, false otherwise
80
80
  */
81
81
  abstract get isStarted(): boolean;
82
+ /**
83
+ * Checks if the VAD is paused
84
+ * @returns True if the VAD is paused, false otherwise
85
+ */
86
+ abstract get isPaused(): boolean;
82
87
  /**
83
88
  * Starts the VAD
84
89
  * @param stream - The stream to start the VAD on
@@ -88,6 +93,14 @@ declare abstract class VAD extends EventEmitter<VADEvents> {
88
93
  * Stops the VAD
89
94
  */
90
95
  abstract stop(): Promise<void>;
96
+ /**
97
+ * Pauses the VAD
98
+ */
99
+ abstract pause(): Promise<void>;
100
+ /**
101
+ * Resumes the VAD
102
+ */
103
+ abstract resume(): Promise<void>;
91
104
  /**
92
105
  * Emits an event (overrides the default implementation)
93
106
  * @param event - The event to emit
@@ -105,11 +118,11 @@ declare abstract class VAD extends EventEmitter<VADEvents> {
105
118
  type VADConfigName = 'volume' | 'silero';
106
119
  type VADConfig = VAD | VADConfigName | Array<VAD | VADConfigName>;
107
120
  declare function getVAD(vad?: VADConfig): VAD;
121
+ declare function equalVADConfig(a?: VADConfig, b?: VADConfig): boolean;
108
122
 
109
123
  interface MicRecorderState {
110
124
  isStarting: boolean;
111
125
  isStarted: boolean;
112
- isMuted: boolean;
113
126
  isSpeaking: boolean;
114
127
  }
115
128
  interface MicRecorderEvents {
@@ -119,30 +132,24 @@ interface MicRecorderEvents {
119
132
  StateChange: [MicRecorderState];
120
133
  }
121
134
  declare class MicRecorder extends EventEmitter<MicRecorderEvents> {
135
+ private vadConfig?;
122
136
  state: MicRecorderState;
123
137
  vad: VAD;
124
- private audioContext;
138
+ private stream;
125
139
  private source;
126
- private processor;
140
+ private workletNode;
127
141
  private delayedStream;
128
142
  private speakingConfirmed;
129
143
  private queuedChunks;
130
- private audioBuffer;
131
- private chunkTimer;
132
- constructor(vadConfig?: VADConfig);
144
+ constructor(vadConfig?: VADConfig | undefined);
133
145
  start: (stream: MediaStream) => Promise<void>;
134
- mute: () => void;
135
- unmute: () => void;
136
146
  stop: () => void;
147
+ changeVad: (vadConfig: VADConfig) => void;
137
148
  private onStartSpeaking;
138
149
  private onConfirmSpeaking;
139
150
  private onCancelSpeaking;
140
151
  private onStopSpeaking;
141
- private onAudioProcess;
142
- private startChunking;
143
- private stopChunking;
144
- private processAudioChunk;
145
- private floatToPCM16;
152
+ private onWorkletMessage;
146
153
  private changeState;
147
154
  }
148
155
 
@@ -160,9 +167,12 @@ declare class MultipleVAD extends VAD {
160
167
  vads: VAD[];
161
168
  constructor(vads: Array<VAD | VADConfigName>);
162
169
  get isStarted(): boolean;
163
- start(stream: MediaStream, threshold?: number): Promise<void>;
170
+ get isPaused(): boolean;
171
+ start(stream: MediaStream): Promise<void>;
164
172
  private onStatusChange;
165
173
  stop(): Promise<void>;
174
+ pause(): Promise<void>;
175
+ resume(): Promise<void>;
166
176
  }
167
177
 
168
178
  type SileroVADOptions = {
@@ -178,10 +188,14 @@ type SileroVADOptions = {
178
188
  declare class SileroVAD extends VAD {
179
189
  options: SileroVADOptions;
180
190
  private vad;
191
+ private _isPaused;
181
192
  constructor(options?: Partial<SileroVADOptions>);
182
193
  get isStarted(): boolean;
194
+ get isPaused(): boolean;
183
195
  start(stream: MediaStream): Promise<void>;
184
196
  stop(): Promise<void>;
197
+ pause(): Promise<void>;
198
+ resume(): Promise<void>;
185
199
  setOptions(options: Partial<SileroVADOptions>): void;
186
200
  resetOptions(): void;
187
201
  }
@@ -196,6 +210,7 @@ type VolumeVADOptions = {
196
210
  */
197
211
  declare class VolumeVAD extends VAD {
198
212
  options: VolumeVADOptions;
213
+ private _isPaused;
199
214
  private analyser;
200
215
  private sourceNode;
201
216
  private fftBins;
@@ -206,9 +221,13 @@ declare class VolumeVAD extends VAD {
206
221
  constructor(options?: Partial<VolumeVADOptions>);
207
222
  private getMaxVolume;
208
223
  get isStarted(): boolean;
224
+ get isPaused(): boolean;
209
225
  start(stream: MediaStream): Promise<void>;
210
226
  private startLoop;
227
+ private resetHistory;
211
228
  stop(): Promise<void>;
229
+ pause(): Promise<void>;
230
+ resume(): Promise<void>;
212
231
  setOptions(options: Partial<VolumeVADOptions>): void;
213
232
  resetOptions(): void;
214
233
  }
@@ -351,7 +370,6 @@ declare class MicdropClient extends EventEmitter<MicdropEvents> implements Micdr
351
370
  startMic: (options?: {
352
371
  vad?: VADConfig;
353
372
  deviceId?: string;
354
- record?: boolean;
355
373
  }) => Promise<void>;
356
374
  changeMicDevice: (deviceId: string) => Promise<void>;
357
375
  changeSpeakerDevice: (deviceId: string) => Promise<void>;
@@ -373,4 +391,4 @@ declare class MicdropClient extends EventEmitter<MicdropEvents> implements Micdr
373
391
 
374
392
  declare const Micdrop: MicdropClient;
375
393
 
376
- export { type DeepPartial, LocalStorageKeys, Mic, MicRecorder, type MicRecorderEvents, type MicRecorderState, Micdrop, type MicdropAnswerMetadata, type MicdropCallSummary, MicdropClient, MicdropClientCommands, MicdropClientError, MicdropClientErrorCode, type MicdropConversation, type MicdropConversationItem, type MicdropConversationMessage, type MicdropConversationToolCall, type MicdropConversationToolResult, type MicdropEvents, type MicdropOptions, MicdropServerCommands, type MicdropState, type MicdropToolCall, MultipleVAD, SileroVAD, type SileroVADOptions, Speaker, VAD, type VADConfig, type VADConfigName, type VADEvents, VADStatus, VolumeVAD, type VolumeVADOptions, getClientErrorFromWSCloseEvent, getClientErrorFromWSCloseEventCode, getVAD };
394
+ export { type DeepPartial, LocalStorageKeys, Mic, MicRecorder, type MicRecorderEvents, type MicRecorderState, Micdrop, type MicdropAnswerMetadata, type MicdropCallSummary, MicdropClient, MicdropClientCommands, MicdropClientError, MicdropClientErrorCode, type MicdropConversation, type MicdropConversationItem, type MicdropConversationMessage, type MicdropConversationToolCall, type MicdropConversationToolResult, type MicdropEvents, type MicdropOptions, MicdropServerCommands, type MicdropState, type MicdropToolCall, MultipleVAD, SileroVAD, type SileroVADOptions, Speaker, VAD, type VADConfig, type VADConfigName, type VADEvents, VADStatus, VolumeVAD, type VolumeVADOptions, equalVADConfig, getClientErrorFromWSCloseEvent, getClientErrorFromWSCloseEventCode, getVAD };
package/dist/index.d.ts CHANGED
@@ -79,6 +79,11 @@ declare abstract class VAD extends EventEmitter<VADEvents> {
79
79
  * @returns True if the VAD is started, false otherwise
80
80
  */
81
81
  abstract get isStarted(): boolean;
82
+ /**
83
+ * Checks if the VAD is paused
84
+ * @returns True if the VAD is paused, false otherwise
85
+ */
86
+ abstract get isPaused(): boolean;
82
87
  /**
83
88
  * Starts the VAD
84
89
  * @param stream - The stream to start the VAD on
@@ -88,6 +93,14 @@ declare abstract class VAD extends EventEmitter<VADEvents> {
88
93
  * Stops the VAD
89
94
  */
90
95
  abstract stop(): Promise<void>;
96
+ /**
97
+ * Pauses the VAD
98
+ */
99
+ abstract pause(): Promise<void>;
100
+ /**
101
+ * Resumes the VAD
102
+ */
103
+ abstract resume(): Promise<void>;
91
104
  /**
92
105
  * Emits an event (overrides the default implementation)
93
106
  * @param event - The event to emit
@@ -105,11 +118,11 @@ declare abstract class VAD extends EventEmitter<VADEvents> {
105
118
  type VADConfigName = 'volume' | 'silero';
106
119
  type VADConfig = VAD | VADConfigName | Array<VAD | VADConfigName>;
107
120
  declare function getVAD(vad?: VADConfig): VAD;
121
+ declare function equalVADConfig(a?: VADConfig, b?: VADConfig): boolean;
108
122
 
109
123
  interface MicRecorderState {
110
124
  isStarting: boolean;
111
125
  isStarted: boolean;
112
- isMuted: boolean;
113
126
  isSpeaking: boolean;
114
127
  }
115
128
  interface MicRecorderEvents {
@@ -119,30 +132,24 @@ interface MicRecorderEvents {
119
132
  StateChange: [MicRecorderState];
120
133
  }
121
134
  declare class MicRecorder extends EventEmitter<MicRecorderEvents> {
135
+ private vadConfig?;
122
136
  state: MicRecorderState;
123
137
  vad: VAD;
124
- private audioContext;
138
+ private stream;
125
139
  private source;
126
- private processor;
140
+ private workletNode;
127
141
  private delayedStream;
128
142
  private speakingConfirmed;
129
143
  private queuedChunks;
130
- private audioBuffer;
131
- private chunkTimer;
132
- constructor(vadConfig?: VADConfig);
144
+ constructor(vadConfig?: VADConfig | undefined);
133
145
  start: (stream: MediaStream) => Promise<void>;
134
- mute: () => void;
135
- unmute: () => void;
136
146
  stop: () => void;
147
+ changeVad: (vadConfig: VADConfig) => void;
137
148
  private onStartSpeaking;
138
149
  private onConfirmSpeaking;
139
150
  private onCancelSpeaking;
140
151
  private onStopSpeaking;
141
- private onAudioProcess;
142
- private startChunking;
143
- private stopChunking;
144
- private processAudioChunk;
145
- private floatToPCM16;
152
+ private onWorkletMessage;
146
153
  private changeState;
147
154
  }
148
155
 
@@ -160,9 +167,12 @@ declare class MultipleVAD extends VAD {
160
167
  vads: VAD[];
161
168
  constructor(vads: Array<VAD | VADConfigName>);
162
169
  get isStarted(): boolean;
163
- start(stream: MediaStream, threshold?: number): Promise<void>;
170
+ get isPaused(): boolean;
171
+ start(stream: MediaStream): Promise<void>;
164
172
  private onStatusChange;
165
173
  stop(): Promise<void>;
174
+ pause(): Promise<void>;
175
+ resume(): Promise<void>;
166
176
  }
167
177
 
168
178
  type SileroVADOptions = {
@@ -178,10 +188,14 @@ type SileroVADOptions = {
178
188
  declare class SileroVAD extends VAD {
179
189
  options: SileroVADOptions;
180
190
  private vad;
191
+ private _isPaused;
181
192
  constructor(options?: Partial<SileroVADOptions>);
182
193
  get isStarted(): boolean;
194
+ get isPaused(): boolean;
183
195
  start(stream: MediaStream): Promise<void>;
184
196
  stop(): Promise<void>;
197
+ pause(): Promise<void>;
198
+ resume(): Promise<void>;
185
199
  setOptions(options: Partial<SileroVADOptions>): void;
186
200
  resetOptions(): void;
187
201
  }
@@ -196,6 +210,7 @@ type VolumeVADOptions = {
196
210
  */
197
211
  declare class VolumeVAD extends VAD {
198
212
  options: VolumeVADOptions;
213
+ private _isPaused;
199
214
  private analyser;
200
215
  private sourceNode;
201
216
  private fftBins;
@@ -206,9 +221,13 @@ declare class VolumeVAD extends VAD {
206
221
  constructor(options?: Partial<VolumeVADOptions>);
207
222
  private getMaxVolume;
208
223
  get isStarted(): boolean;
224
+ get isPaused(): boolean;
209
225
  start(stream: MediaStream): Promise<void>;
210
226
  private startLoop;
227
+ private resetHistory;
211
228
  stop(): Promise<void>;
229
+ pause(): Promise<void>;
230
+ resume(): Promise<void>;
212
231
  setOptions(options: Partial<VolumeVADOptions>): void;
213
232
  resetOptions(): void;
214
233
  }
@@ -351,7 +370,6 @@ declare class MicdropClient extends EventEmitter<MicdropEvents> implements Micdr
351
370
  startMic: (options?: {
352
371
  vad?: VADConfig;
353
372
  deviceId?: string;
354
- record?: boolean;
355
373
  }) => Promise<void>;
356
374
  changeMicDevice: (deviceId: string) => Promise<void>;
357
375
  changeSpeakerDevice: (deviceId: string) => Promise<void>;
@@ -373,4 +391,4 @@ declare class MicdropClient extends EventEmitter<MicdropEvents> implements Micdr
373
391
 
374
392
  declare const Micdrop: MicdropClient;
375
393
 
376
- export { type DeepPartial, LocalStorageKeys, Mic, MicRecorder, type MicRecorderEvents, type MicRecorderState, Micdrop, type MicdropAnswerMetadata, type MicdropCallSummary, MicdropClient, MicdropClientCommands, MicdropClientError, MicdropClientErrorCode, type MicdropConversation, type MicdropConversationItem, type MicdropConversationMessage, type MicdropConversationToolCall, type MicdropConversationToolResult, type MicdropEvents, type MicdropOptions, MicdropServerCommands, type MicdropState, type MicdropToolCall, MultipleVAD, SileroVAD, type SileroVADOptions, Speaker, VAD, type VADConfig, type VADConfigName, type VADEvents, VADStatus, VolumeVAD, type VolumeVADOptions, getClientErrorFromWSCloseEvent, getClientErrorFromWSCloseEventCode, getVAD };
394
+ export { type DeepPartial, LocalStorageKeys, Mic, MicRecorder, type MicRecorderEvents, type MicRecorderState, Micdrop, type MicdropAnswerMetadata, type MicdropCallSummary, MicdropClient, MicdropClientCommands, MicdropClientError, MicdropClientErrorCode, type MicdropConversation, type MicdropConversationItem, type MicdropConversationMessage, type MicdropConversationToolCall, type MicdropConversationToolResult, type MicdropEvents, type MicdropOptions, MicdropServerCommands, type MicdropState, type MicdropToolCall, MultipleVAD, SileroVAD, type SileroVADOptions, Speaker, VAD, type VADConfig, type VADConfigName, type VADEvents, VADStatus, VolumeVAD, type VolumeVADOptions, equalVADConfig, getClientErrorFromWSCloseEvent, getClientErrorFromWSCloseEventCode, getVAD };