@trillet-ai/web-sdk 1.5.6 → 1.5.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/dist/TrilletWebSDK.d.ts +3 -0
- package/dist/TrilletWebSDK.js +42 -4
- package/package.json +2 -1
package/dist/TrilletWebSDK.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export interface TrilletCallConfig {
|
|
|
11
11
|
mode?: 'voice' | 'text';
|
|
12
12
|
features?: {
|
|
13
13
|
enableRawAudio?: boolean;
|
|
14
|
+
enableKrispNoiseFilter?: boolean;
|
|
14
15
|
};
|
|
15
16
|
}
|
|
16
17
|
export declare class TrilletWebSDK extends EventEmitter {
|
|
@@ -22,12 +23,14 @@ export declare class TrilletWebSDK extends EventEmitter {
|
|
|
22
23
|
analyser: AnalyserNode;
|
|
23
24
|
cleanup: () => Promise<void>;
|
|
24
25
|
};
|
|
26
|
+
private krispProcessor?;
|
|
25
27
|
private audioFrameCapture;
|
|
26
28
|
constructor();
|
|
27
29
|
initializeCall(config: TrilletCallConfig): Promise<void>;
|
|
28
30
|
enableAudioPlayback(): Promise<void>;
|
|
29
31
|
endCall(): void;
|
|
30
32
|
toggleMicrophone(enabled: boolean): void;
|
|
33
|
+
private setupKrispNoiseFilter;
|
|
31
34
|
private captureAudio;
|
|
32
35
|
private setupEventHandlers;
|
|
33
36
|
private handleDataEvent;
|
package/dist/TrilletWebSDK.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EventEmitter } from 'eventemitter3';
|
|
2
|
-
import { RemoteAudioTrack, Room, RoomEvent, Track, createAudioAnalyser } from 'livekit-client';
|
|
2
|
+
import { RemoteAudioTrack, Room, RoomEvent, Track, createAudioAnalyser, LocalAudioTrack } from 'livekit-client';
|
|
3
3
|
const decoder = new TextDecoder();
|
|
4
4
|
// Internal SDK class
|
|
5
5
|
export class TrilletWebSDK extends EventEmitter {
|
|
@@ -10,7 +10,7 @@ export class TrilletWebSDK extends EventEmitter {
|
|
|
10
10
|
this.isAssistantSpeaking = false;
|
|
11
11
|
}
|
|
12
12
|
async initializeCall(config) {
|
|
13
|
-
var _a, _b, _c;
|
|
13
|
+
var _a, _b, _c, _d;
|
|
14
14
|
try {
|
|
15
15
|
this.room = new Room({
|
|
16
16
|
audioCaptureDefaults: {
|
|
@@ -30,7 +30,11 @@ export class TrilletWebSDK extends EventEmitter {
|
|
|
30
30
|
await this.room.connect(config.wsUrl, config.token);
|
|
31
31
|
console.log('Connected to Trillet room:', this.room.name);
|
|
32
32
|
if (config.mode !== 'text') {
|
|
33
|
-
this.room.localParticipant.setMicrophoneEnabled(true);
|
|
33
|
+
await this.room.localParticipant.setMicrophoneEnabled(true);
|
|
34
|
+
// Apply Krisp noise filter if enabled
|
|
35
|
+
if ((_d = config.features) === null || _d === void 0 ? void 0 : _d.enableKrispNoiseFilter) {
|
|
36
|
+
await this.setupKrispNoiseFilter();
|
|
37
|
+
}
|
|
34
38
|
}
|
|
35
39
|
this.isConnected = true;
|
|
36
40
|
this.emit('connected');
|
|
@@ -63,6 +67,10 @@ export class TrilletWebSDK extends EventEmitter {
|
|
|
63
67
|
cancelAnimationFrame(this.audioFrameCapture);
|
|
64
68
|
this.audioFrameCapture = undefined;
|
|
65
69
|
}
|
|
70
|
+
// Cleanup Krisp processor
|
|
71
|
+
if (this.krispProcessor) {
|
|
72
|
+
this.krispProcessor = undefined;
|
|
73
|
+
}
|
|
66
74
|
this.room = undefined;
|
|
67
75
|
}
|
|
68
76
|
toggleMicrophone(enabled) {
|
|
@@ -70,6 +78,36 @@ export class TrilletWebSDK extends EventEmitter {
|
|
|
70
78
|
this.room.localParticipant.setMicrophoneEnabled(enabled);
|
|
71
79
|
}
|
|
72
80
|
}
|
|
81
|
+
async setupKrispNoiseFilter() {
|
|
82
|
+
var _a;
|
|
83
|
+
if (!this.room)
|
|
84
|
+
return;
|
|
85
|
+
try {
|
|
86
|
+
// Dynamically import Krisp noise filter
|
|
87
|
+
const { KrispNoiseFilter, isKrispNoiseFilterSupported } = await import('@livekit/krisp-noise-filter');
|
|
88
|
+
// Check browser compatibility
|
|
89
|
+
if (!isKrispNoiseFilterSupported()) {
|
|
90
|
+
console.warn('Krisp noise filter is not supported on this browser');
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
// Get the local microphone track
|
|
94
|
+
const microphoneTrack = (_a = this.room.localParticipant.getTrackPublication(Track.Source.Microphone)) === null || _a === void 0 ? void 0 : _a.track;
|
|
95
|
+
if (microphoneTrack && microphoneTrack instanceof LocalAudioTrack) {
|
|
96
|
+
// Initialize the Krisp processor
|
|
97
|
+
this.krispProcessor = KrispNoiseFilter();
|
|
98
|
+
await microphoneTrack.setProcessor(this.krispProcessor);
|
|
99
|
+
// Enable the noise filter
|
|
100
|
+
await this.krispProcessor.setEnabled(true);
|
|
101
|
+
console.log('Krisp noise filter enabled successfully');
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
console.warn('Could not find local microphone track to apply Krisp filter');
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
catch (error) {
|
|
108
|
+
console.error('Failed to setup Krisp noise filter:', error);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
73
111
|
captureAudio() {
|
|
74
112
|
if (!this.isConnected || !this.audioAnalyzer)
|
|
75
113
|
return;
|
|
@@ -97,7 +135,7 @@ export class TrilletWebSDK extends EventEmitter {
|
|
|
97
135
|
var _a, _b;
|
|
98
136
|
const text = await reader.readAll();
|
|
99
137
|
const attributes = ((_a = reader.info) === null || _a === void 0 ? void 0 : _a.attributes) || {};
|
|
100
|
-
const isFinal = attributes['lk.transcription_final'] === 'true'
|
|
138
|
+
const isFinal = attributes['lk.transcription_final'] === 'true';
|
|
101
139
|
if (!info)
|
|
102
140
|
return;
|
|
103
141
|
const participant = (_b = this.room) === null || _b === void 0 ? void 0 : _b.getParticipantByIdentity(info.identity);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trillet-ai/web-sdk",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.8",
|
|
4
4
|
"description": "Trillet Web SDK for real-time audio communication with AI agents",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
"author": "Trillet AI",
|
|
33
33
|
"license": "MIT",
|
|
34
34
|
"dependencies": {
|
|
35
|
+
"@livekit/krisp-noise-filter": "^0.3.4",
|
|
35
36
|
"eventemitter3": "^5.0.1",
|
|
36
37
|
"livekit-client": "^2.13.4"
|
|
37
38
|
},
|