@lokutor/sdk 1.1.9 → 1.1.11
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 -51
- package/dist/index.d.ts +48 -51
- package/dist/index.js +446 -445
- package/dist/index.mjs +446 -444
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -119,14 +119,19 @@ declare class VoiceAgentClient {
|
|
|
119
119
|
private messages;
|
|
120
120
|
private visemeListeners;
|
|
121
121
|
private wantVisemes;
|
|
122
|
-
private
|
|
122
|
+
private audioManager;
|
|
123
|
+
private enableAudio;
|
|
124
|
+
private isUserDisconnect;
|
|
125
|
+
private reconnecting;
|
|
126
|
+
private reconnectAttempts;
|
|
127
|
+
private maxReconnectAttempts;
|
|
123
128
|
constructor(config: LokutorConfig & {
|
|
124
129
|
prompt: string;
|
|
125
130
|
voice?: VoiceStyle;
|
|
126
131
|
language?: Language;
|
|
127
132
|
visemes?: boolean;
|
|
128
|
-
serverUrl?: string;
|
|
129
133
|
onVisemes?: (visemes: Viseme[]) => void;
|
|
134
|
+
enableAudio?: boolean;
|
|
130
135
|
});
|
|
131
136
|
/**
|
|
132
137
|
* Connect to the Lokutor Voice Agent server
|
|
@@ -157,6 +162,15 @@ declare class VoiceAgentClient {
|
|
|
157
162
|
* Disconnect from the server
|
|
158
163
|
*/
|
|
159
164
|
disconnect(): void;
|
|
165
|
+
/**
|
|
166
|
+
* Toggles the microphone mute state (if managed by client)
|
|
167
|
+
* returns the new mute state
|
|
168
|
+
*/
|
|
169
|
+
toggleMute(): boolean;
|
|
170
|
+
/**
|
|
171
|
+
* Gets the microphone volume amplitude 0-1 (if managed by client)
|
|
172
|
+
*/
|
|
173
|
+
getAmplitude(): number;
|
|
160
174
|
/**
|
|
161
175
|
* Update the system prompt mid-conversation
|
|
162
176
|
*/
|
|
@@ -326,9 +340,10 @@ declare class BrowserAudioManager {
|
|
|
326
340
|
private scriptProcessor;
|
|
327
341
|
private analyserNode;
|
|
328
342
|
private mediaStream;
|
|
343
|
+
private resampler;
|
|
329
344
|
private nextPlaybackTime;
|
|
330
345
|
private activeSources;
|
|
331
|
-
private
|
|
346
|
+
private playbackQueue;
|
|
332
347
|
private inputSampleRate;
|
|
333
348
|
private outputSampleRate;
|
|
334
349
|
private autoGainControl;
|
|
@@ -338,7 +353,6 @@ declare class BrowserAudioManager {
|
|
|
338
353
|
private onInputError?;
|
|
339
354
|
private isMuted;
|
|
340
355
|
private isListening;
|
|
341
|
-
private resampler;
|
|
342
356
|
constructor(config?: BrowserAudioConfig);
|
|
343
357
|
/**
|
|
344
358
|
* Initialize the AudioContext and analyser
|
|
@@ -348,77 +362,60 @@ declare class BrowserAudioManager {
|
|
|
348
362
|
* Start capturing audio from the microphone
|
|
349
363
|
*/
|
|
350
364
|
startMicrophone(onAudioInput: (pcm16Data: Uint8Array) => void): Promise<void>;
|
|
365
|
+
/**
|
|
366
|
+
* Internal method to process microphone audio data
|
|
367
|
+
*/
|
|
351
368
|
private _processAudioInput;
|
|
369
|
+
/**
|
|
370
|
+
* Stop capturing microphone input
|
|
371
|
+
*/
|
|
352
372
|
stopMicrophone(): void;
|
|
353
373
|
/**
|
|
354
374
|
* Play back audio received from the server
|
|
375
|
+
* @param pcm16Data Int16 PCM audio data at SPEAKER_SAMPLE_RATE
|
|
355
376
|
*/
|
|
356
377
|
playAudio(pcm16Data: Uint8Array): void;
|
|
357
|
-
private _schedulePlayback;
|
|
358
378
|
/**
|
|
359
|
-
*
|
|
360
|
-
* Total stream time (in ms) = (audioContext.currentTime - audioClockOffset) * 1000
|
|
379
|
+
* Internal method to schedule and play audio with sample-accurate timing
|
|
361
380
|
*/
|
|
362
|
-
|
|
381
|
+
private _schedulePlayback;
|
|
363
382
|
/**
|
|
364
|
-
*
|
|
383
|
+
* Stop all currently playing audio and clear the queue
|
|
365
384
|
*/
|
|
366
|
-
resetAudioClock(): void;
|
|
367
385
|
stopPlayback(): void;
|
|
386
|
+
/**
|
|
387
|
+
* Toggle mute state
|
|
388
|
+
*/
|
|
368
389
|
setMuted(muted: boolean): void;
|
|
369
|
-
isMicMuted(): boolean;
|
|
370
|
-
getAmplitude(): number;
|
|
371
|
-
getFrequencyData(): Uint8Array;
|
|
372
|
-
getWaveformData(): Uint8Array;
|
|
373
|
-
cleanup(): void;
|
|
374
|
-
getAudioContext(): AudioContext | null;
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
/**
|
|
378
|
-
* High-level AI Voice Agent for browser-based conversations.
|
|
379
|
-
*
|
|
380
|
-
* This class orchestrates microphone input, AI processing, and
|
|
381
|
-
* speaker output, providing a simple interface for building
|
|
382
|
-
* voice assistants with lip-sync support.
|
|
383
|
-
*/
|
|
384
|
-
declare class VoiceAgent {
|
|
385
|
-
private client;
|
|
386
|
-
private audioManager;
|
|
387
|
-
private options;
|
|
388
|
-
private isConnected;
|
|
389
|
-
private visemeQueue;
|
|
390
|
-
constructor(options: VoiceAgentOptions & {
|
|
391
|
-
apiKey: string;
|
|
392
|
-
});
|
|
393
390
|
/**
|
|
394
|
-
*
|
|
395
|
-
* This must be called in response to a user guesture (like a click)
|
|
396
|
-
* to satisfy browser AudioContext requirements.
|
|
391
|
+
* Get current mute state
|
|
397
392
|
*/
|
|
398
|
-
|
|
393
|
+
isMicMuted(): boolean;
|
|
399
394
|
/**
|
|
400
|
-
* Get
|
|
401
|
-
*
|
|
402
|
-
* @returns value between 0 and 1
|
|
395
|
+
* Get current amplitude from analyser (for visualization)
|
|
396
|
+
* Returns value between 0 and 1
|
|
403
397
|
*/
|
|
404
398
|
getAmplitude(): number;
|
|
405
399
|
/**
|
|
406
|
-
*
|
|
400
|
+
* Get frequency data from analyser for visualization
|
|
407
401
|
*/
|
|
408
|
-
|
|
402
|
+
getFrequencyData(): Uint8Array;
|
|
403
|
+
/**
|
|
404
|
+
* Get time-domain data from analyser for waveform visualization
|
|
405
|
+
*/
|
|
406
|
+
getWaveformData(): Uint8Array;
|
|
409
407
|
/**
|
|
410
|
-
*
|
|
411
|
-
* at the current playback frame. Use this in a requestAnimationFrame loop.
|
|
408
|
+
* Cleanup and close AudioContext
|
|
412
409
|
*/
|
|
413
|
-
|
|
410
|
+
cleanup(): void;
|
|
414
411
|
/**
|
|
415
|
-
*
|
|
412
|
+
* Get current audio context state
|
|
416
413
|
*/
|
|
417
|
-
|
|
414
|
+
getState(): 'running' | 'suspended' | 'closed' | 'interrupted' | null;
|
|
418
415
|
/**
|
|
419
|
-
*
|
|
416
|
+
* Check if microphone is currently listening
|
|
420
417
|
*/
|
|
421
|
-
|
|
418
|
+
isRecording(): boolean;
|
|
422
419
|
}
|
|
423
420
|
|
|
424
|
-
export { AUDIO_CONFIG, type AnalyserConfig, type BrowserAudioConfig, BrowserAudioManager, type BrowserAudioOptions, DEFAULT_URLS, Language, type LokutorConfig, StreamResampler, type SynthesizeOptions, TTSClient, type Viseme,
|
|
421
|
+
export { AUDIO_CONFIG, type AnalyserConfig, type BrowserAudioConfig, BrowserAudioManager, type BrowserAudioOptions, DEFAULT_URLS, Language, type LokutorConfig, StreamResampler, type SynthesizeOptions, TTSClient, type Viseme, VoiceAgentClient, type VoiceAgentOptions, VoiceStyle, applyLowPassFilter, bytesToPcm16, calculateRMS, float32ToPcm16, normalizeAudio, pcm16ToBytes, pcm16ToFloat32, resample, resampleWithAntiAliasing, simpleConversation, simpleTTS };
|
package/dist/index.d.ts
CHANGED
|
@@ -119,14 +119,19 @@ declare class VoiceAgentClient {
|
|
|
119
119
|
private messages;
|
|
120
120
|
private visemeListeners;
|
|
121
121
|
private wantVisemes;
|
|
122
|
-
private
|
|
122
|
+
private audioManager;
|
|
123
|
+
private enableAudio;
|
|
124
|
+
private isUserDisconnect;
|
|
125
|
+
private reconnecting;
|
|
126
|
+
private reconnectAttempts;
|
|
127
|
+
private maxReconnectAttempts;
|
|
123
128
|
constructor(config: LokutorConfig & {
|
|
124
129
|
prompt: string;
|
|
125
130
|
voice?: VoiceStyle;
|
|
126
131
|
language?: Language;
|
|
127
132
|
visemes?: boolean;
|
|
128
|
-
serverUrl?: string;
|
|
129
133
|
onVisemes?: (visemes: Viseme[]) => void;
|
|
134
|
+
enableAudio?: boolean;
|
|
130
135
|
});
|
|
131
136
|
/**
|
|
132
137
|
* Connect to the Lokutor Voice Agent server
|
|
@@ -157,6 +162,15 @@ declare class VoiceAgentClient {
|
|
|
157
162
|
* Disconnect from the server
|
|
158
163
|
*/
|
|
159
164
|
disconnect(): void;
|
|
165
|
+
/**
|
|
166
|
+
* Toggles the microphone mute state (if managed by client)
|
|
167
|
+
* returns the new mute state
|
|
168
|
+
*/
|
|
169
|
+
toggleMute(): boolean;
|
|
170
|
+
/**
|
|
171
|
+
* Gets the microphone volume amplitude 0-1 (if managed by client)
|
|
172
|
+
*/
|
|
173
|
+
getAmplitude(): number;
|
|
160
174
|
/**
|
|
161
175
|
* Update the system prompt mid-conversation
|
|
162
176
|
*/
|
|
@@ -326,9 +340,10 @@ declare class BrowserAudioManager {
|
|
|
326
340
|
private scriptProcessor;
|
|
327
341
|
private analyserNode;
|
|
328
342
|
private mediaStream;
|
|
343
|
+
private resampler;
|
|
329
344
|
private nextPlaybackTime;
|
|
330
345
|
private activeSources;
|
|
331
|
-
private
|
|
346
|
+
private playbackQueue;
|
|
332
347
|
private inputSampleRate;
|
|
333
348
|
private outputSampleRate;
|
|
334
349
|
private autoGainControl;
|
|
@@ -338,7 +353,6 @@ declare class BrowserAudioManager {
|
|
|
338
353
|
private onInputError?;
|
|
339
354
|
private isMuted;
|
|
340
355
|
private isListening;
|
|
341
|
-
private resampler;
|
|
342
356
|
constructor(config?: BrowserAudioConfig);
|
|
343
357
|
/**
|
|
344
358
|
* Initialize the AudioContext and analyser
|
|
@@ -348,77 +362,60 @@ declare class BrowserAudioManager {
|
|
|
348
362
|
* Start capturing audio from the microphone
|
|
349
363
|
*/
|
|
350
364
|
startMicrophone(onAudioInput: (pcm16Data: Uint8Array) => void): Promise<void>;
|
|
365
|
+
/**
|
|
366
|
+
* Internal method to process microphone audio data
|
|
367
|
+
*/
|
|
351
368
|
private _processAudioInput;
|
|
369
|
+
/**
|
|
370
|
+
* Stop capturing microphone input
|
|
371
|
+
*/
|
|
352
372
|
stopMicrophone(): void;
|
|
353
373
|
/**
|
|
354
374
|
* Play back audio received from the server
|
|
375
|
+
* @param pcm16Data Int16 PCM audio data at SPEAKER_SAMPLE_RATE
|
|
355
376
|
*/
|
|
356
377
|
playAudio(pcm16Data: Uint8Array): void;
|
|
357
|
-
private _schedulePlayback;
|
|
358
378
|
/**
|
|
359
|
-
*
|
|
360
|
-
* Total stream time (in ms) = (audioContext.currentTime - audioClockOffset) * 1000
|
|
379
|
+
* Internal method to schedule and play audio with sample-accurate timing
|
|
361
380
|
*/
|
|
362
|
-
|
|
381
|
+
private _schedulePlayback;
|
|
363
382
|
/**
|
|
364
|
-
*
|
|
383
|
+
* Stop all currently playing audio and clear the queue
|
|
365
384
|
*/
|
|
366
|
-
resetAudioClock(): void;
|
|
367
385
|
stopPlayback(): void;
|
|
386
|
+
/**
|
|
387
|
+
* Toggle mute state
|
|
388
|
+
*/
|
|
368
389
|
setMuted(muted: boolean): void;
|
|
369
|
-
isMicMuted(): boolean;
|
|
370
|
-
getAmplitude(): number;
|
|
371
|
-
getFrequencyData(): Uint8Array;
|
|
372
|
-
getWaveformData(): Uint8Array;
|
|
373
|
-
cleanup(): void;
|
|
374
|
-
getAudioContext(): AudioContext | null;
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
/**
|
|
378
|
-
* High-level AI Voice Agent for browser-based conversations.
|
|
379
|
-
*
|
|
380
|
-
* This class orchestrates microphone input, AI processing, and
|
|
381
|
-
* speaker output, providing a simple interface for building
|
|
382
|
-
* voice assistants with lip-sync support.
|
|
383
|
-
*/
|
|
384
|
-
declare class VoiceAgent {
|
|
385
|
-
private client;
|
|
386
|
-
private audioManager;
|
|
387
|
-
private options;
|
|
388
|
-
private isConnected;
|
|
389
|
-
private visemeQueue;
|
|
390
|
-
constructor(options: VoiceAgentOptions & {
|
|
391
|
-
apiKey: string;
|
|
392
|
-
});
|
|
393
390
|
/**
|
|
394
|
-
*
|
|
395
|
-
* This must be called in response to a user guesture (like a click)
|
|
396
|
-
* to satisfy browser AudioContext requirements.
|
|
391
|
+
* Get current mute state
|
|
397
392
|
*/
|
|
398
|
-
|
|
393
|
+
isMicMuted(): boolean;
|
|
399
394
|
/**
|
|
400
|
-
* Get
|
|
401
|
-
*
|
|
402
|
-
* @returns value between 0 and 1
|
|
395
|
+
* Get current amplitude from analyser (for visualization)
|
|
396
|
+
* Returns value between 0 and 1
|
|
403
397
|
*/
|
|
404
398
|
getAmplitude(): number;
|
|
405
399
|
/**
|
|
406
|
-
*
|
|
400
|
+
* Get frequency data from analyser for visualization
|
|
407
401
|
*/
|
|
408
|
-
|
|
402
|
+
getFrequencyData(): Uint8Array;
|
|
403
|
+
/**
|
|
404
|
+
* Get time-domain data from analyser for waveform visualization
|
|
405
|
+
*/
|
|
406
|
+
getWaveformData(): Uint8Array;
|
|
409
407
|
/**
|
|
410
|
-
*
|
|
411
|
-
* at the current playback frame. Use this in a requestAnimationFrame loop.
|
|
408
|
+
* Cleanup and close AudioContext
|
|
412
409
|
*/
|
|
413
|
-
|
|
410
|
+
cleanup(): void;
|
|
414
411
|
/**
|
|
415
|
-
*
|
|
412
|
+
* Get current audio context state
|
|
416
413
|
*/
|
|
417
|
-
|
|
414
|
+
getState(): 'running' | 'suspended' | 'closed' | 'interrupted' | null;
|
|
418
415
|
/**
|
|
419
|
-
*
|
|
416
|
+
* Check if microphone is currently listening
|
|
420
417
|
*/
|
|
421
|
-
|
|
418
|
+
isRecording(): boolean;
|
|
422
419
|
}
|
|
423
420
|
|
|
424
|
-
export { AUDIO_CONFIG, type AnalyserConfig, type BrowserAudioConfig, BrowserAudioManager, type BrowserAudioOptions, DEFAULT_URLS, Language, type LokutorConfig, StreamResampler, type SynthesizeOptions, TTSClient, type Viseme,
|
|
421
|
+
export { AUDIO_CONFIG, type AnalyserConfig, type BrowserAudioConfig, BrowserAudioManager, type BrowserAudioOptions, DEFAULT_URLS, Language, type LokutorConfig, StreamResampler, type SynthesizeOptions, TTSClient, type Viseme, VoiceAgentClient, type VoiceAgentOptions, VoiceStyle, applyLowPassFilter, bytesToPcm16, calculateRMS, float32ToPcm16, normalizeAudio, pcm16ToBytes, pcm16ToFloat32, resample, resampleWithAntiAliasing, simpleConversation, simpleTTS };
|