@micdrop/client 1.6.0 → 1.7.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 +48 -33
- package/dist/index.d.ts +48 -33
- package/dist/index.js +159 -69
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +158 -69
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -17,7 +17,6 @@ declare class AudioAnalyser extends EventEmitter<AudioAnalyserEvents> {
|
|
|
17
17
|
|
|
18
18
|
declare let mic: Mic;
|
|
19
19
|
declare class Mic {
|
|
20
|
-
defaultThreshold: number;
|
|
21
20
|
private currentDeviceId;
|
|
22
21
|
private audioStream;
|
|
23
22
|
private sourceNode;
|
|
@@ -53,12 +52,6 @@ interface VADEvents {
|
|
|
53
52
|
*/
|
|
54
53
|
declare abstract class VAD extends EventEmitter<VADEvents> {
|
|
55
54
|
delay: number;
|
|
56
|
-
protected threshold: number;
|
|
57
|
-
/**
|
|
58
|
-
* Constructor for the VAD class
|
|
59
|
-
* @param threshold - The threshold to use for the VAD
|
|
60
|
-
*/
|
|
61
|
-
constructor(threshold?: number);
|
|
62
55
|
/**
|
|
63
56
|
* Checks if the VAD is started
|
|
64
57
|
* @returns True if the VAD is started, false otherwise
|
|
@@ -67,27 +60,22 @@ declare abstract class VAD extends EventEmitter<VADEvents> {
|
|
|
67
60
|
/**
|
|
68
61
|
* Starts the VAD
|
|
69
62
|
* @param stream - The stream to start the VAD on
|
|
70
|
-
* @param threshold - The threshold to use for the VAD
|
|
71
63
|
*/
|
|
72
|
-
abstract start(stream: MediaStream
|
|
64
|
+
abstract start(stream: MediaStream): Promise<void>;
|
|
73
65
|
/**
|
|
74
66
|
* Stops the VAD
|
|
75
67
|
*/
|
|
76
68
|
abstract stop(): Promise<void>;
|
|
77
|
-
/**
|
|
78
|
-
* Sets the threshold for the VAD
|
|
79
|
-
* @param threshold - The threshold to use for the VAD
|
|
80
|
-
*/
|
|
81
|
-
abstract setThreshold(threshold: number): Promise<void>;
|
|
82
69
|
}
|
|
83
70
|
|
|
84
|
-
type
|
|
71
|
+
type VADConfigName = 'volume' | 'silero';
|
|
72
|
+
type VADConfig = VAD | VADConfigName | Array<VAD | VADConfigName>;
|
|
73
|
+
|
|
85
74
|
interface MicRecorderState {
|
|
86
75
|
isStarting: boolean;
|
|
87
76
|
isStarted: boolean;
|
|
88
77
|
isMuted: boolean;
|
|
89
78
|
isSpeaking: boolean;
|
|
90
|
-
threshold: number;
|
|
91
79
|
}
|
|
92
80
|
interface MicRecorderEvents {
|
|
93
81
|
Chunk: [Blob];
|
|
@@ -96,21 +84,18 @@ interface MicRecorderEvents {
|
|
|
96
84
|
StateChange: [MicRecorderState];
|
|
97
85
|
}
|
|
98
86
|
declare class MicRecorder extends EventEmitter<MicRecorderEvents> {
|
|
99
|
-
private vadConfig?;
|
|
100
87
|
state: MicRecorderState;
|
|
101
88
|
private audioInfo;
|
|
102
|
-
private vad
|
|
89
|
+
private vad;
|
|
103
90
|
private recorder;
|
|
104
91
|
private delayedStream;
|
|
105
92
|
private speakingConfirmed;
|
|
106
93
|
private queuedChunks;
|
|
107
|
-
constructor(vadConfig?:
|
|
94
|
+
constructor(vadConfig?: VADConfig);
|
|
108
95
|
start(stream: MediaStream): Promise<void>;
|
|
109
96
|
mute(): void;
|
|
110
97
|
unmute(): void;
|
|
111
98
|
stop(): void;
|
|
112
|
-
setThreshold(threshold: number): void;
|
|
113
|
-
private initVAD;
|
|
114
99
|
private startSpeakingDetection;
|
|
115
100
|
private stopSpeakingDetection;
|
|
116
101
|
private onStartSpeaking;
|
|
@@ -150,41 +135,71 @@ declare global {
|
|
|
150
135
|
declare enum LocalStorageKeys {
|
|
151
136
|
MicDevice = "micdrop.micDevice",
|
|
152
137
|
SpeakerDevice = "micdrop.speakerDevice",
|
|
153
|
-
|
|
138
|
+
VolumeVADOptions = "micdrop.VolumeVADOptions",
|
|
139
|
+
SileroVADOptions = "micdrop.SileroVADOptions"
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Combine an array of VADs
|
|
144
|
+
*/
|
|
145
|
+
declare class MultipleVAD extends VAD {
|
|
146
|
+
vads: VAD[];
|
|
147
|
+
private startSpeakingCount;
|
|
148
|
+
private confirmSpeakingCount;
|
|
149
|
+
private lastEventName;
|
|
150
|
+
constructor(vads: Array<VAD | VADConfigName>);
|
|
151
|
+
emit(eventName: keyof VADEvents, ..._: any[]): boolean;
|
|
152
|
+
get isStarted(): boolean;
|
|
153
|
+
start(stream: MediaStream, threshold?: number): Promise<void>;
|
|
154
|
+
stop(): Promise<void>;
|
|
154
155
|
}
|
|
155
156
|
|
|
157
|
+
type SileroVADOptions = {
|
|
158
|
+
positiveSpeechThreshold: number;
|
|
159
|
+
negativeSpeechThreshold: number;
|
|
160
|
+
minSpeechFrames: number;
|
|
161
|
+
redemptionFrames: number;
|
|
162
|
+
};
|
|
156
163
|
/**
|
|
157
164
|
* Silero VAD
|
|
158
165
|
* @see https://github.com/ricky0123/vad
|
|
159
166
|
*/
|
|
160
167
|
declare class SileroVAD extends VAD {
|
|
168
|
+
options: SileroVADOptions;
|
|
161
169
|
private vad;
|
|
170
|
+
constructor(options?: Partial<SileroVADOptions>);
|
|
162
171
|
get isStarted(): boolean;
|
|
163
|
-
start(stream: MediaStream
|
|
172
|
+
start(stream: MediaStream): Promise<void>;
|
|
164
173
|
stop(): Promise<void>;
|
|
165
|
-
|
|
174
|
+
setOptions(options: Partial<SileroVADOptions>): void;
|
|
175
|
+
resetOptions(): void;
|
|
166
176
|
}
|
|
167
177
|
|
|
178
|
+
type VolumeVADOptions = {
|
|
179
|
+
history: number;
|
|
180
|
+
threshold: number;
|
|
181
|
+
};
|
|
168
182
|
/**
|
|
169
183
|
* Volume-based Voice Activity Detection
|
|
170
184
|
* Based on the hark library implementation
|
|
171
185
|
*/
|
|
172
186
|
declare class VolumeVAD extends VAD {
|
|
187
|
+
options: VolumeVADOptions;
|
|
173
188
|
private analyser;
|
|
174
189
|
private sourceNode;
|
|
175
190
|
private fftBins;
|
|
176
191
|
private running;
|
|
177
192
|
private speaking;
|
|
178
193
|
private attemptSpeaking;
|
|
179
|
-
private history;
|
|
180
194
|
private speakingHistory;
|
|
181
|
-
constructor();
|
|
195
|
+
constructor(options?: Partial<VolumeVADOptions>);
|
|
182
196
|
private getMaxVolume;
|
|
183
197
|
get isStarted(): boolean;
|
|
184
|
-
start(stream: MediaStream
|
|
198
|
+
start(stream: MediaStream): Promise<void>;
|
|
185
199
|
private startLoop;
|
|
186
200
|
stop(): Promise<void>;
|
|
187
|
-
|
|
201
|
+
setOptions(options: Partial<VolumeVADOptions>): void;
|
|
202
|
+
resetOptions(): void;
|
|
188
203
|
}
|
|
189
204
|
|
|
190
205
|
declare enum CallHandlerErrorCode {
|
|
@@ -203,19 +218,20 @@ interface CallHandlerEvents {
|
|
|
203
218
|
StateChange: void;
|
|
204
219
|
}
|
|
205
220
|
interface CallHandlerOptions {
|
|
206
|
-
vad?:
|
|
221
|
+
vad?: VADConfig;
|
|
207
222
|
}
|
|
208
223
|
declare global {
|
|
209
224
|
interface Window {
|
|
210
|
-
micdropCallHandler:
|
|
225
|
+
micdropCallHandler: any;
|
|
211
226
|
}
|
|
212
227
|
}
|
|
213
228
|
declare class CallHandler<Params extends {}, Options extends CallHandlerOptions = CallHandlerOptions> extends EventEmitter<CallHandlerEvents> {
|
|
214
229
|
private options?;
|
|
215
|
-
static getInstance<
|
|
230
|
+
static getInstance<P extends {}, O extends CallHandlerOptions = CallHandlerOptions>(options?: O): CallHandler<P, O>;
|
|
216
231
|
url?: string;
|
|
217
232
|
params?: Params;
|
|
218
233
|
micRecorder?: MicRecorder;
|
|
234
|
+
vad: VAD;
|
|
219
235
|
conversation: Conversation;
|
|
220
236
|
debug: boolean;
|
|
221
237
|
private ws?;
|
|
@@ -231,7 +247,6 @@ declare class CallHandler<Params extends {}, Options extends CallHandlerOptions
|
|
|
231
247
|
get isMicStarted(): boolean;
|
|
232
248
|
get isMicMuted(): boolean;
|
|
233
249
|
get isMicSpeaking(): boolean;
|
|
234
|
-
get micThreshold(): number;
|
|
235
250
|
get isProcessing(): boolean;
|
|
236
251
|
start(): Promise<void>;
|
|
237
252
|
stop(): Promise<void>;
|
|
@@ -290,4 +305,4 @@ interface ConversationMessage<Data extends CallMetadata = CallMetadata> {
|
|
|
290
305
|
metadata?: Data;
|
|
291
306
|
}
|
|
292
307
|
|
|
293
|
-
export { CallClientCommands, type CallConfig, CallHandler, CallHandlerError, CallHandlerErrorCode, type CallHandlerEvents, type CallHandlerOptions, type CallMetadata, CallServerCommands, type CallSummary, type Conversation, type ConversationMessage, LocalStorageKeys, mic as Mic, MicRecorder, type MicRecorderEvents, type MicRecorderState,
|
|
308
|
+
export { CallClientCommands, type CallConfig, CallHandler, CallHandlerError, CallHandlerErrorCode, type CallHandlerEvents, type CallHandlerOptions, type CallMetadata, CallServerCommands, type CallSummary, type Conversation, type ConversationMessage, LocalStorageKeys, mic as Mic, MicRecorder, type MicRecorderEvents, type MicRecorderState, MultipleVAD, SileroVAD, type SileroVADOptions, speaker as Speaker, VAD, type VADEvents, VolumeVAD, type VolumeVADOptions };
|
package/dist/index.d.ts
CHANGED
|
@@ -17,7 +17,6 @@ declare class AudioAnalyser extends EventEmitter<AudioAnalyserEvents> {
|
|
|
17
17
|
|
|
18
18
|
declare let mic: Mic;
|
|
19
19
|
declare class Mic {
|
|
20
|
-
defaultThreshold: number;
|
|
21
20
|
private currentDeviceId;
|
|
22
21
|
private audioStream;
|
|
23
22
|
private sourceNode;
|
|
@@ -53,12 +52,6 @@ interface VADEvents {
|
|
|
53
52
|
*/
|
|
54
53
|
declare abstract class VAD extends EventEmitter<VADEvents> {
|
|
55
54
|
delay: number;
|
|
56
|
-
protected threshold: number;
|
|
57
|
-
/**
|
|
58
|
-
* Constructor for the VAD class
|
|
59
|
-
* @param threshold - The threshold to use for the VAD
|
|
60
|
-
*/
|
|
61
|
-
constructor(threshold?: number);
|
|
62
55
|
/**
|
|
63
56
|
* Checks if the VAD is started
|
|
64
57
|
* @returns True if the VAD is started, false otherwise
|
|
@@ -67,27 +60,22 @@ declare abstract class VAD extends EventEmitter<VADEvents> {
|
|
|
67
60
|
/**
|
|
68
61
|
* Starts the VAD
|
|
69
62
|
* @param stream - The stream to start the VAD on
|
|
70
|
-
* @param threshold - The threshold to use for the VAD
|
|
71
63
|
*/
|
|
72
|
-
abstract start(stream: MediaStream
|
|
64
|
+
abstract start(stream: MediaStream): Promise<void>;
|
|
73
65
|
/**
|
|
74
66
|
* Stops the VAD
|
|
75
67
|
*/
|
|
76
68
|
abstract stop(): Promise<void>;
|
|
77
|
-
/**
|
|
78
|
-
* Sets the threshold for the VAD
|
|
79
|
-
* @param threshold - The threshold to use for the VAD
|
|
80
|
-
*/
|
|
81
|
-
abstract setThreshold(threshold: number): Promise<void>;
|
|
82
69
|
}
|
|
83
70
|
|
|
84
|
-
type
|
|
71
|
+
type VADConfigName = 'volume' | 'silero';
|
|
72
|
+
type VADConfig = VAD | VADConfigName | Array<VAD | VADConfigName>;
|
|
73
|
+
|
|
85
74
|
interface MicRecorderState {
|
|
86
75
|
isStarting: boolean;
|
|
87
76
|
isStarted: boolean;
|
|
88
77
|
isMuted: boolean;
|
|
89
78
|
isSpeaking: boolean;
|
|
90
|
-
threshold: number;
|
|
91
79
|
}
|
|
92
80
|
interface MicRecorderEvents {
|
|
93
81
|
Chunk: [Blob];
|
|
@@ -96,21 +84,18 @@ interface MicRecorderEvents {
|
|
|
96
84
|
StateChange: [MicRecorderState];
|
|
97
85
|
}
|
|
98
86
|
declare class MicRecorder extends EventEmitter<MicRecorderEvents> {
|
|
99
|
-
private vadConfig?;
|
|
100
87
|
state: MicRecorderState;
|
|
101
88
|
private audioInfo;
|
|
102
|
-
private vad
|
|
89
|
+
private vad;
|
|
103
90
|
private recorder;
|
|
104
91
|
private delayedStream;
|
|
105
92
|
private speakingConfirmed;
|
|
106
93
|
private queuedChunks;
|
|
107
|
-
constructor(vadConfig?:
|
|
94
|
+
constructor(vadConfig?: VADConfig);
|
|
108
95
|
start(stream: MediaStream): Promise<void>;
|
|
109
96
|
mute(): void;
|
|
110
97
|
unmute(): void;
|
|
111
98
|
stop(): void;
|
|
112
|
-
setThreshold(threshold: number): void;
|
|
113
|
-
private initVAD;
|
|
114
99
|
private startSpeakingDetection;
|
|
115
100
|
private stopSpeakingDetection;
|
|
116
101
|
private onStartSpeaking;
|
|
@@ -150,41 +135,71 @@ declare global {
|
|
|
150
135
|
declare enum LocalStorageKeys {
|
|
151
136
|
MicDevice = "micdrop.micDevice",
|
|
152
137
|
SpeakerDevice = "micdrop.speakerDevice",
|
|
153
|
-
|
|
138
|
+
VolumeVADOptions = "micdrop.VolumeVADOptions",
|
|
139
|
+
SileroVADOptions = "micdrop.SileroVADOptions"
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Combine an array of VADs
|
|
144
|
+
*/
|
|
145
|
+
declare class MultipleVAD extends VAD {
|
|
146
|
+
vads: VAD[];
|
|
147
|
+
private startSpeakingCount;
|
|
148
|
+
private confirmSpeakingCount;
|
|
149
|
+
private lastEventName;
|
|
150
|
+
constructor(vads: Array<VAD | VADConfigName>);
|
|
151
|
+
emit(eventName: keyof VADEvents, ..._: any[]): boolean;
|
|
152
|
+
get isStarted(): boolean;
|
|
153
|
+
start(stream: MediaStream, threshold?: number): Promise<void>;
|
|
154
|
+
stop(): Promise<void>;
|
|
154
155
|
}
|
|
155
156
|
|
|
157
|
+
type SileroVADOptions = {
|
|
158
|
+
positiveSpeechThreshold: number;
|
|
159
|
+
negativeSpeechThreshold: number;
|
|
160
|
+
minSpeechFrames: number;
|
|
161
|
+
redemptionFrames: number;
|
|
162
|
+
};
|
|
156
163
|
/**
|
|
157
164
|
* Silero VAD
|
|
158
165
|
* @see https://github.com/ricky0123/vad
|
|
159
166
|
*/
|
|
160
167
|
declare class SileroVAD extends VAD {
|
|
168
|
+
options: SileroVADOptions;
|
|
161
169
|
private vad;
|
|
170
|
+
constructor(options?: Partial<SileroVADOptions>);
|
|
162
171
|
get isStarted(): boolean;
|
|
163
|
-
start(stream: MediaStream
|
|
172
|
+
start(stream: MediaStream): Promise<void>;
|
|
164
173
|
stop(): Promise<void>;
|
|
165
|
-
|
|
174
|
+
setOptions(options: Partial<SileroVADOptions>): void;
|
|
175
|
+
resetOptions(): void;
|
|
166
176
|
}
|
|
167
177
|
|
|
178
|
+
type VolumeVADOptions = {
|
|
179
|
+
history: number;
|
|
180
|
+
threshold: number;
|
|
181
|
+
};
|
|
168
182
|
/**
|
|
169
183
|
* Volume-based Voice Activity Detection
|
|
170
184
|
* Based on the hark library implementation
|
|
171
185
|
*/
|
|
172
186
|
declare class VolumeVAD extends VAD {
|
|
187
|
+
options: VolumeVADOptions;
|
|
173
188
|
private analyser;
|
|
174
189
|
private sourceNode;
|
|
175
190
|
private fftBins;
|
|
176
191
|
private running;
|
|
177
192
|
private speaking;
|
|
178
193
|
private attemptSpeaking;
|
|
179
|
-
private history;
|
|
180
194
|
private speakingHistory;
|
|
181
|
-
constructor();
|
|
195
|
+
constructor(options?: Partial<VolumeVADOptions>);
|
|
182
196
|
private getMaxVolume;
|
|
183
197
|
get isStarted(): boolean;
|
|
184
|
-
start(stream: MediaStream
|
|
198
|
+
start(stream: MediaStream): Promise<void>;
|
|
185
199
|
private startLoop;
|
|
186
200
|
stop(): Promise<void>;
|
|
187
|
-
|
|
201
|
+
setOptions(options: Partial<VolumeVADOptions>): void;
|
|
202
|
+
resetOptions(): void;
|
|
188
203
|
}
|
|
189
204
|
|
|
190
205
|
declare enum CallHandlerErrorCode {
|
|
@@ -203,19 +218,20 @@ interface CallHandlerEvents {
|
|
|
203
218
|
StateChange: void;
|
|
204
219
|
}
|
|
205
220
|
interface CallHandlerOptions {
|
|
206
|
-
vad?:
|
|
221
|
+
vad?: VADConfig;
|
|
207
222
|
}
|
|
208
223
|
declare global {
|
|
209
224
|
interface Window {
|
|
210
|
-
micdropCallHandler:
|
|
225
|
+
micdropCallHandler: any;
|
|
211
226
|
}
|
|
212
227
|
}
|
|
213
228
|
declare class CallHandler<Params extends {}, Options extends CallHandlerOptions = CallHandlerOptions> extends EventEmitter<CallHandlerEvents> {
|
|
214
229
|
private options?;
|
|
215
|
-
static getInstance<
|
|
230
|
+
static getInstance<P extends {}, O extends CallHandlerOptions = CallHandlerOptions>(options?: O): CallHandler<P, O>;
|
|
216
231
|
url?: string;
|
|
217
232
|
params?: Params;
|
|
218
233
|
micRecorder?: MicRecorder;
|
|
234
|
+
vad: VAD;
|
|
219
235
|
conversation: Conversation;
|
|
220
236
|
debug: boolean;
|
|
221
237
|
private ws?;
|
|
@@ -231,7 +247,6 @@ declare class CallHandler<Params extends {}, Options extends CallHandlerOptions
|
|
|
231
247
|
get isMicStarted(): boolean;
|
|
232
248
|
get isMicMuted(): boolean;
|
|
233
249
|
get isMicSpeaking(): boolean;
|
|
234
|
-
get micThreshold(): number;
|
|
235
250
|
get isProcessing(): boolean;
|
|
236
251
|
start(): Promise<void>;
|
|
237
252
|
stop(): Promise<void>;
|
|
@@ -290,4 +305,4 @@ interface ConversationMessage<Data extends CallMetadata = CallMetadata> {
|
|
|
290
305
|
metadata?: Data;
|
|
291
306
|
}
|
|
292
307
|
|
|
293
|
-
export { CallClientCommands, type CallConfig, CallHandler, CallHandlerError, CallHandlerErrorCode, type CallHandlerEvents, type CallHandlerOptions, type CallMetadata, CallServerCommands, type CallSummary, type Conversation, type ConversationMessage, LocalStorageKeys, mic as Mic, MicRecorder, type MicRecorderEvents, type MicRecorderState,
|
|
308
|
+
export { CallClientCommands, type CallConfig, CallHandler, CallHandlerError, CallHandlerErrorCode, type CallHandlerEvents, type CallHandlerOptions, type CallMetadata, CallServerCommands, type CallSummary, type Conversation, type ConversationMessage, LocalStorageKeys, mic as Mic, MicRecorder, type MicRecorderEvents, type MicRecorderState, MultipleVAD, SileroVAD, type SileroVADOptions, speaker as Speaker, VAD, type VADEvents, VolumeVAD, type VolumeVADOptions };
|