@livekit/agents-plugin-silero 0.5.5 → 0.5.7
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.cts +2 -0
- package/dist/onnx_model.d.cts +13 -0
- package/dist/vad.d.cts +76 -0
- package/package.json +12 -8
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/// <reference path="../src/onnxruntime.d.ts" />
|
|
2
|
+
import { InferenceSession } from 'onnxruntime-node';
|
|
3
|
+
export type SampleRate = 8000 | 16000;
|
|
4
|
+
export declare const newInferenceSession: (forceCPU: boolean) => Promise<InferenceSession>;
|
|
5
|
+
export declare class OnnxModel {
|
|
6
|
+
#private;
|
|
7
|
+
constructor(session: InferenceSession, sampleRate: SampleRate);
|
|
8
|
+
get sampleRate(): number;
|
|
9
|
+
get windowSizeSamples(): number;
|
|
10
|
+
get contextSize(): number;
|
|
11
|
+
run(x: Float32Array): Promise<number>;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=onnx_model.d.ts.map
|
package/dist/vad.d.cts
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/// <reference path="../src/onnxruntime.d.ts" />
|
|
2
|
+
import { VADStream as baseStream, VAD as baseVAD } from '@livekit/agents';
|
|
3
|
+
import type { InferenceSession } from 'onnxruntime-node';
|
|
4
|
+
import type { SampleRate } from './onnx_model.js';
|
|
5
|
+
import { OnnxModel } from './onnx_model.js';
|
|
6
|
+
export interface VADOptions {
|
|
7
|
+
/** Minimum duration of speech to start a new speech chunk */
|
|
8
|
+
minSpeechDuration: number;
|
|
9
|
+
/** At the end of each speech, wait this duration before ending the speech */
|
|
10
|
+
minSilenceDuration: number;
|
|
11
|
+
/** Duration of padding to add to the beginning of each speech chunk */
|
|
12
|
+
prefixPaddingDuration: number;
|
|
13
|
+
/** Maximum duration of speech to keep in the buffer */
|
|
14
|
+
maxBufferedSpeech: number;
|
|
15
|
+
/** Maximum duration of speech to keep in the buffer*/
|
|
16
|
+
activationThreshold: number;
|
|
17
|
+
/** Sample rate for the inference (only 8KHz and 16KHz are supported) */
|
|
18
|
+
sampleRate: SampleRate;
|
|
19
|
+
/** Force the use of CPU for inference */
|
|
20
|
+
forceCPU: boolean;
|
|
21
|
+
}
|
|
22
|
+
export declare class VAD extends baseVAD {
|
|
23
|
+
#private;
|
|
24
|
+
label: string;
|
|
25
|
+
constructor(session: InferenceSession, opts: VADOptions);
|
|
26
|
+
/**
|
|
27
|
+
* Updates the VAD options with new values.
|
|
28
|
+
*
|
|
29
|
+
* @param opts - Partial options object containing the values to update
|
|
30
|
+
* @remarks
|
|
31
|
+
* This method will merge the provided options with existing options and update all active streams.
|
|
32
|
+
* Only the properties specified in opts will be updated, other properties retain their current values.
|
|
33
|
+
*/
|
|
34
|
+
updateOptions(opts: Partial<VADOptions>): void;
|
|
35
|
+
/**
|
|
36
|
+
* Load and initialize the Silero VAD model.
|
|
37
|
+
*
|
|
38
|
+
* This method loads the ONNX model and prepares it for inference. When options are not provided,
|
|
39
|
+
* sane defaults are used.
|
|
40
|
+
*
|
|
41
|
+
* @remarks
|
|
42
|
+
* This method may take time to load the model into memory.
|
|
43
|
+
* It is recommended to call this method inside your prewarm mechanism.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```ts
|
|
47
|
+
* export default defineAgent({
|
|
48
|
+
* prewarm: async (proc: JobProcess) => {
|
|
49
|
+
* proc.userData.vad = await VAD.load();
|
|
50
|
+
* },
|
|
51
|
+
* entry: async (ctx: JobContext) => {
|
|
52
|
+
* const vad = ctx.proc.userData.vad! as VAD;
|
|
53
|
+
* // the rest of your agent logic
|
|
54
|
+
* },
|
|
55
|
+
* });
|
|
56
|
+
* ```
|
|
57
|
+
*
|
|
58
|
+
* @param options -
|
|
59
|
+
* @returns Promise\<{@link VAD}\>: An instance of the VAD class ready for streaming.
|
|
60
|
+
*/
|
|
61
|
+
static load(opts?: Partial<VADOptions>): Promise<VAD>;
|
|
62
|
+
stream(): VADStream;
|
|
63
|
+
}
|
|
64
|
+
export declare class VADStream extends baseStream {
|
|
65
|
+
#private;
|
|
66
|
+
constructor(vad: VAD, opts: VADOptions, model: OnnxModel);
|
|
67
|
+
/**
|
|
68
|
+
* Update the VAD options
|
|
69
|
+
*
|
|
70
|
+
* @param opts - Partial options object containing the values to update
|
|
71
|
+
* @remarks
|
|
72
|
+
* This method allows you to update the VAD options after the VAD object has been created
|
|
73
|
+
*/
|
|
74
|
+
updateOptions(opts: Partial<VADOptions>): void;
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=vad.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@livekit/agents-plugin-silero",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.7",
|
|
4
4
|
"description": "Silero voice activity detection LiveKit Node Agents",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"require": "dist/index.cjs",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
8
|
"exports": {
|
|
9
|
-
"
|
|
9
|
+
"import": {
|
|
10
10
|
"types": "./dist/index.d.ts",
|
|
11
|
-
"
|
|
12
|
-
|
|
11
|
+
"default": "./dist/index.js"
|
|
12
|
+
},
|
|
13
|
+
"require": {
|
|
14
|
+
"types": "./dist/index.d.cts",
|
|
15
|
+
"default": "./dist/index.cjs"
|
|
13
16
|
}
|
|
14
17
|
},
|
|
15
18
|
"author": "LiveKit",
|
|
@@ -23,7 +26,7 @@
|
|
|
23
26
|
],
|
|
24
27
|
"devDependencies": {
|
|
25
28
|
"@livekit/agents": "^x",
|
|
26
|
-
"@livekit/rtc-node": "^0.13.
|
|
29
|
+
"@livekit/rtc-node": "^0.13.11",
|
|
27
30
|
"@microsoft/api-extractor": "^7.35.0",
|
|
28
31
|
"@types/ws": "^8.5.10",
|
|
29
32
|
"onnxruntime-common": "^1.19.2",
|
|
@@ -35,11 +38,12 @@
|
|
|
35
38
|
"ws": "^8.16.0"
|
|
36
39
|
},
|
|
37
40
|
"peerDependencies": {
|
|
38
|
-
"@livekit/rtc-node": "^0.13.
|
|
39
|
-
"@livekit/agents": "^0.7.
|
|
41
|
+
"@livekit/rtc-node": "^0.13.11",
|
|
42
|
+
"@livekit/agents": "^0.7.7x"
|
|
40
43
|
},
|
|
41
44
|
"scripts": {
|
|
42
|
-
"build": "tsup --onSuccess \"
|
|
45
|
+
"build": "tsup --onSuccess \"pnpm build:types\" && cp src/silero_vad.onnx dist/",
|
|
46
|
+
"build:types": "tsc --declaration --emitDeclarationOnly && node ../../scripts/copyDeclarationOutput.js",
|
|
43
47
|
"clean": "rm -rf dist",
|
|
44
48
|
"clean:build": "pnpm clean && pnpm build",
|
|
45
49
|
"lint": "eslint -f unix \"src/**/*.{ts,js}\"",
|