@livekit/agents-plugin-krisp 1.4.9

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.
Files changed (48) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +144 -0
  3. package/dist/_krisp.cjs +267 -0
  4. package/dist/_krisp.cjs.map +1 -0
  5. package/dist/_krisp.d.cts +43 -0
  6. package/dist/_krisp.d.ts +43 -0
  7. package/dist/_krisp.d.ts.map +1 -0
  8. package/dist/_krisp.js +241 -0
  9. package/dist/_krisp.js.map +1 -0
  10. package/dist/_krisp_sdk.d.cjs +2 -0
  11. package/dist/_krisp_sdk.d.cjs.map +1 -0
  12. package/dist/_krisp_sdk.d.js +1 -0
  13. package/dist/_krisp_sdk.d.js.map +1 -0
  14. package/dist/auth.cjs +69 -0
  15. package/dist/auth.cjs.map +1 -0
  16. package/dist/auth.d.cts +57 -0
  17. package/dist/auth.d.ts +57 -0
  18. package/dist/auth.d.ts.map +1 -0
  19. package/dist/auth.js +41 -0
  20. package/dist/auth.js.map +1 -0
  21. package/dist/index.cjs +55 -0
  22. package/dist/index.cjs.map +1 -0
  23. package/dist/index.d.cts +24 -0
  24. package/dist/index.d.ts +24 -0
  25. package/dist/index.d.ts.map +1 -0
  26. package/dist/index.js +31 -0
  27. package/dist/index.js.map +1 -0
  28. package/dist/log.cjs +30 -0
  29. package/dist/log.cjs.map +1 -0
  30. package/dist/log.d.cts +3 -0
  31. package/dist/log.d.ts +3 -0
  32. package/dist/log.d.ts.map +1 -0
  33. package/dist/log.js +6 -0
  34. package/dist/log.js.map +1 -0
  35. package/dist/viva_filter.cjs +103 -0
  36. package/dist/viva_filter.cjs.map +1 -0
  37. package/dist/viva_filter.d.cts +75 -0
  38. package/dist/viva_filter.d.ts +75 -0
  39. package/dist/viva_filter.d.ts.map +1 -0
  40. package/dist/viva_filter.js +81 -0
  41. package/dist/viva_filter.js.map +1 -0
  42. package/package.json +54 -0
  43. package/src/_krisp.ts +366 -0
  44. package/src/_krisp_sdk.d.ts +57 -0
  45. package/src/auth.ts +109 -0
  46. package/src/index.ts +78 -0
  47. package/src/log.ts +7 -0
  48. package/src/viva_filter.ts +191 -0
package/dist/index.cjs ADDED
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var index_exports = {};
20
+ __export(index_exports, {
21
+ KrispLicenseAuthProvider: () => import_auth.KrispLicenseAuthProvider,
22
+ LiveKitCloudAuthProvider: () => import_auth.LiveKitCloudAuthProvider,
23
+ auth: () => import_auth.auth,
24
+ voiceIsolation: () => voiceIsolation,
25
+ voiceIsolationTelephony: () => voiceIsolationTelephony
26
+ });
27
+ module.exports = __toCommonJS(index_exports);
28
+ var import_agents = require("@livekit/agents");
29
+ var import_viva_filter = require("./viva_filter.cjs");
30
+ var import_auth = require("./auth.cjs");
31
+ function voiceIsolation(options) {
32
+ return new import_viva_filter.KrispVivaFilter(options, "voiceIsolation");
33
+ }
34
+ function voiceIsolationTelephony(options) {
35
+ return new import_viva_filter.KrispVivaFilter(options, "voiceIsolationTelephony");
36
+ }
37
+ class KrispPlugin extends import_agents.Plugin {
38
+ constructor() {
39
+ super({
40
+ title: "krisp",
41
+ version: "1.4.9",
42
+ package: "@livekit/agents-plugin-krisp"
43
+ });
44
+ }
45
+ }
46
+ import_agents.Plugin.registerPlugin(new KrispPlugin());
47
+ // Annotate the CommonJS export names for ESM import in node:
48
+ 0 && (module.exports = {
49
+ KrispLicenseAuthProvider,
50
+ LiveKitCloudAuthProvider,
51
+ auth,
52
+ voiceIsolation,
53
+ voiceIsolationTelephony
54
+ });
55
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2026 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\n\n/**\n * Krisp VIVA plugin for LiveKit Agents.\n *\n * Real-time noise reduction as a `FrameProcessor`. Two authentication backends\n * are supported, exposed under the {@link auth} namespace:\n *\n * - `auth.livekitCloud()` (default): LiveKit Cloud-managed auth + bundled model.\n * No Krisp keys or model files required.\n * - `auth.krispLicense(...)`: Krisp-direct auth using a license key and a `.kef`\n * model file (requires the proprietary `@krisp/viva-node-sdk`).\n *\n * Two voice isolation modes are available: {@link voiceIsolation} for general\n * use and {@link voiceIsolationTelephony} tuned for telephony audio.\n *\n * @example\n * ```ts\n * import * as krisp from '@livekit/agents-plugin-krisp';\n *\n * const processor = krisp.voiceIsolation();\n * ```\n *\n * @packageDocumentation\n */\nimport { Plugin } from '@livekit/agents';\nimport { KrispVivaFilter, type KrispVivaFilterOptions } from './viva_filter.js';\n\nexport { type KrispVivaFilter, type KrispVivaFilterOptions };\n\nexport {\n type AuthProvider,\n auth,\n KrispLicenseAuthProvider,\n LiveKitCloudAuthProvider,\n} from './auth.js';\n\n/**\n * Create a Krisp VIVA voice isolation `FrameProcessor`.\n *\n * Pass the result as `noiseCancellation` in the session's input options. Uses\n * LiveKit Cloud auth by default; pass `authProvider: auth.krispLicense(...)` to\n * run the proprietary Krisp SDK with your own license + `.kef` model.\n *\n * @public\n */\nexport function voiceIsolation(options?: Partial<KrispVivaFilterOptions>): KrispVivaFilter {\n return new KrispVivaFilter(options, 'voiceIsolation');\n}\n\n/**\n * Create a Krisp VIVA voice isolation `FrameProcessor` for telephony use cases.\n *\n * Pass the result as `noiseCancellation` in the session's input options. Uses\n * LiveKit Cloud auth by default; pass `authProvider: auth.krispLicense(...)` to\n * run the proprietary Krisp SDK with your own license + `.kef` model.\n *\n * @public\n */\nexport function voiceIsolationTelephony(\n options?: Partial<KrispVivaFilterOptions>,\n): KrispVivaFilter {\n return new KrispVivaFilter(options, 'voiceIsolationTelephony');\n}\n\nclass KrispPlugin extends Plugin {\n constructor() {\n super({\n title: 'krisp',\n version: __PACKAGE_VERSION__,\n package: __PACKAGE_NAME__,\n });\n }\n}\n\nPlugin.registerPlugin(new KrispPlugin());\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA2BA,oBAAuB;AACvB,yBAA6D;AAI7D,kBAKO;AAWA,SAAS,eAAe,SAA4D;AACzF,SAAO,IAAI,mCAAgB,SAAS,gBAAgB;AACtD;AAWO,SAAS,wBACd,SACiB;AACjB,SAAO,IAAI,mCAAgB,SAAS,yBAAyB;AAC/D;AAEA,MAAM,oBAAoB,qBAAO;AAAA,EAC/B,cAAc;AACZ,UAAM;AAAA,MACJ,OAAO;AAAA,MACP,SAAS;AAAA,MACT,SAAS;AAAA,IACX,CAAC;AAAA,EACH;AACF;AAEA,qBAAO,eAAe,IAAI,YAAY,CAAC;","names":[]}
@@ -0,0 +1,24 @@
1
+ import { KrispVivaFilter, type KrispVivaFilterOptions } from './viva_filter.js';
2
+ export { type KrispVivaFilter, type KrispVivaFilterOptions };
3
+ export { type AuthProvider, auth, KrispLicenseAuthProvider, LiveKitCloudAuthProvider, } from './auth.js';
4
+ /**
5
+ * Create a Krisp VIVA voice isolation `FrameProcessor`.
6
+ *
7
+ * Pass the result as `noiseCancellation` in the session's input options. Uses
8
+ * LiveKit Cloud auth by default; pass `authProvider: auth.krispLicense(...)` to
9
+ * run the proprietary Krisp SDK with your own license + `.kef` model.
10
+ *
11
+ * @public
12
+ */
13
+ export declare function voiceIsolation(options?: Partial<KrispVivaFilterOptions>): KrispVivaFilter;
14
+ /**
15
+ * Create a Krisp VIVA voice isolation `FrameProcessor` for telephony use cases.
16
+ *
17
+ * Pass the result as `noiseCancellation` in the session's input options. Uses
18
+ * LiveKit Cloud auth by default; pass `authProvider: auth.krispLicense(...)` to
19
+ * run the proprietary Krisp SDK with your own license + `.kef` model.
20
+ *
21
+ * @public
22
+ */
23
+ export declare function voiceIsolationTelephony(options?: Partial<KrispVivaFilterOptions>): KrispVivaFilter;
24
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,24 @@
1
+ import { KrispVivaFilter, type KrispVivaFilterOptions } from './viva_filter.js';
2
+ export { type KrispVivaFilter, type KrispVivaFilterOptions };
3
+ export { type AuthProvider, auth, KrispLicenseAuthProvider, LiveKitCloudAuthProvider, } from './auth.js';
4
+ /**
5
+ * Create a Krisp VIVA voice isolation `FrameProcessor`.
6
+ *
7
+ * Pass the result as `noiseCancellation` in the session's input options. Uses
8
+ * LiveKit Cloud auth by default; pass `authProvider: auth.krispLicense(...)` to
9
+ * run the proprietary Krisp SDK with your own license + `.kef` model.
10
+ *
11
+ * @public
12
+ */
13
+ export declare function voiceIsolation(options?: Partial<KrispVivaFilterOptions>): KrispVivaFilter;
14
+ /**
15
+ * Create a Krisp VIVA voice isolation `FrameProcessor` for telephony use cases.
16
+ *
17
+ * Pass the result as `noiseCancellation` in the session's input options. Uses
18
+ * LiveKit Cloud auth by default; pass `authProvider: auth.krispLicense(...)` to
19
+ * run the proprietary Krisp SDK with your own license + `.kef` model.
20
+ *
21
+ * @public
22
+ */
23
+ export declare function voiceIsolationTelephony(options?: Partial<KrispVivaFilterOptions>): KrispVivaFilter;
24
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AA4BA,OAAO,EAAE,eAAe,EAAE,KAAK,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAEhF,OAAO,EAAE,KAAK,eAAe,EAAE,KAAK,sBAAsB,EAAE,CAAC;AAE7D,OAAO,EACL,KAAK,YAAY,EACjB,IAAI,EACJ,wBAAwB,EACxB,wBAAwB,GACzB,MAAM,WAAW,CAAC;AAEnB;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,sBAAsB,CAAC,GAAG,eAAe,CAEzF;AAED;;;;;;;;GAQG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,CAAC,EAAE,OAAO,CAAC,sBAAsB,CAAC,GACxC,eAAe,CAEjB"}
package/dist/index.js ADDED
@@ -0,0 +1,31 @@
1
+ import { Plugin } from "@livekit/agents";
2
+ import { KrispVivaFilter } from "./viva_filter.js";
3
+ import {
4
+ auth,
5
+ KrispLicenseAuthProvider,
6
+ LiveKitCloudAuthProvider
7
+ } from "./auth.js";
8
+ function voiceIsolation(options) {
9
+ return new KrispVivaFilter(options, "voiceIsolation");
10
+ }
11
+ function voiceIsolationTelephony(options) {
12
+ return new KrispVivaFilter(options, "voiceIsolationTelephony");
13
+ }
14
+ class KrispPlugin extends Plugin {
15
+ constructor() {
16
+ super({
17
+ title: "krisp",
18
+ version: "1.4.9",
19
+ package: "@livekit/agents-plugin-krisp"
20
+ });
21
+ }
22
+ }
23
+ Plugin.registerPlugin(new KrispPlugin());
24
+ export {
25
+ KrispLicenseAuthProvider,
26
+ LiveKitCloudAuthProvider,
27
+ auth,
28
+ voiceIsolation,
29
+ voiceIsolationTelephony
30
+ };
31
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2026 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\n\n/**\n * Krisp VIVA plugin for LiveKit Agents.\n *\n * Real-time noise reduction as a `FrameProcessor`. Two authentication backends\n * are supported, exposed under the {@link auth} namespace:\n *\n * - `auth.livekitCloud()` (default): LiveKit Cloud-managed auth + bundled model.\n * No Krisp keys or model files required.\n * - `auth.krispLicense(...)`: Krisp-direct auth using a license key and a `.kef`\n * model file (requires the proprietary `@krisp/viva-node-sdk`).\n *\n * Two voice isolation modes are available: {@link voiceIsolation} for general\n * use and {@link voiceIsolationTelephony} tuned for telephony audio.\n *\n * @example\n * ```ts\n * import * as krisp from '@livekit/agents-plugin-krisp';\n *\n * const processor = krisp.voiceIsolation();\n * ```\n *\n * @packageDocumentation\n */\nimport { Plugin } from '@livekit/agents';\nimport { KrispVivaFilter, type KrispVivaFilterOptions } from './viva_filter.js';\n\nexport { type KrispVivaFilter, type KrispVivaFilterOptions };\n\nexport {\n type AuthProvider,\n auth,\n KrispLicenseAuthProvider,\n LiveKitCloudAuthProvider,\n} from './auth.js';\n\n/**\n * Create a Krisp VIVA voice isolation `FrameProcessor`.\n *\n * Pass the result as `noiseCancellation` in the session's input options. Uses\n * LiveKit Cloud auth by default; pass `authProvider: auth.krispLicense(...)` to\n * run the proprietary Krisp SDK with your own license + `.kef` model.\n *\n * @public\n */\nexport function voiceIsolation(options?: Partial<KrispVivaFilterOptions>): KrispVivaFilter {\n return new KrispVivaFilter(options, 'voiceIsolation');\n}\n\n/**\n * Create a Krisp VIVA voice isolation `FrameProcessor` for telephony use cases.\n *\n * Pass the result as `noiseCancellation` in the session's input options. Uses\n * LiveKit Cloud auth by default; pass `authProvider: auth.krispLicense(...)` to\n * run the proprietary Krisp SDK with your own license + `.kef` model.\n *\n * @public\n */\nexport function voiceIsolationTelephony(\n options?: Partial<KrispVivaFilterOptions>,\n): KrispVivaFilter {\n return new KrispVivaFilter(options, 'voiceIsolationTelephony');\n}\n\nclass KrispPlugin extends Plugin {\n constructor() {\n super({\n title: 'krisp',\n version: __PACKAGE_VERSION__,\n package: __PACKAGE_NAME__,\n });\n }\n}\n\nPlugin.registerPlugin(new KrispPlugin());\n"],"mappings":"AA2BA,SAAS,cAAc;AACvB,SAAS,uBAAoD;AAI7D;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAWA,SAAS,eAAe,SAA4D;AACzF,SAAO,IAAI,gBAAgB,SAAS,gBAAgB;AACtD;AAWO,SAAS,wBACd,SACiB;AACjB,SAAO,IAAI,gBAAgB,SAAS,yBAAyB;AAC/D;AAEA,MAAM,oBAAoB,OAAO;AAAA,EAC/B,cAAc;AACZ,UAAM;AAAA,MACJ,OAAO;AAAA,MACP,SAAS;AAAA,MACT,SAAS;AAAA,IACX,CAAC;AAAA,EACH;AACF;AAEA,OAAO,eAAe,IAAI,YAAY,CAAC;","names":[]}
package/dist/log.cjs ADDED
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var log_exports = {};
20
+ __export(log_exports, {
21
+ log: () => log
22
+ });
23
+ module.exports = __toCommonJS(log_exports);
24
+ var import_agents = require("@livekit/agents");
25
+ const log = () => (0, import_agents.log)().child({ plugin: "krisp" });
26
+ // Annotate the CommonJS export names for ESM import in node:
27
+ 0 && (module.exports = {
28
+ log
29
+ });
30
+ //# sourceMappingURL=log.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/log.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2026 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport { log as agentsLog } from '@livekit/agents';\nimport type { Logger } from 'pino';\n\nexport const log = (): Logger => agentsLog().child({ plugin: 'krisp' });\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,oBAAiC;AAG1B,MAAM,MAAM,UAAc,cAAAA,KAAU,EAAE,MAAM,EAAE,QAAQ,QAAQ,CAAC;","names":["agentsLog"]}
package/dist/log.d.cts ADDED
@@ -0,0 +1,3 @@
1
+ import type { Logger } from 'pino';
2
+ export declare const log: () => Logger;
3
+ //# sourceMappingURL=log.d.ts.map
package/dist/log.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ import type { Logger } from 'pino';
2
+ export declare const log: () => Logger;
3
+ //# sourceMappingURL=log.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../src/log.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAEnC,eAAO,MAAM,GAAG,QAAO,MAAgD,CAAC"}
package/dist/log.js ADDED
@@ -0,0 +1,6 @@
1
+ import { log as agentsLog } from "@livekit/agents";
2
+ const log = () => agentsLog().child({ plugin: "krisp" });
3
+ export {
4
+ log
5
+ };
6
+ //# sourceMappingURL=log.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/log.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2026 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport { log as agentsLog } from '@livekit/agents';\nimport type { Logger } from 'pino';\n\nexport const log = (): Logger => agentsLog().child({ plugin: 'krisp' });\n"],"mappings":"AAGA,SAAS,OAAO,iBAAiB;AAG1B,MAAM,MAAM,MAAc,UAAU,EAAE,MAAM,EAAE,QAAQ,QAAQ,CAAC;","names":[]}
@@ -0,0 +1,103 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var viva_filter_exports = {};
20
+ __export(viva_filter_exports, {
21
+ KrispVivaFilter: () => KrispVivaFilter
22
+ });
23
+ module.exports = __toCommonJS(viva_filter_exports);
24
+ var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href;
25
+ var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
26
+ var import_rtc_node = require("@livekit/rtc-node");
27
+ var import_node_module = require("node:module");
28
+ var import_krisp = require("./_krisp.cjs");
29
+ var import_auth = require("./auth.cjs");
30
+ var import_log = require("./log.cjs");
31
+ const require2 = (0, import_node_module.createRequire)(importMetaUrl);
32
+ const DEFAULT_FRAME_DURATION_MS = 10;
33
+ function resolveAuthProvider(explicit) {
34
+ if (explicit) {
35
+ return explicit;
36
+ }
37
+ if (process.env.KRISP_VIVA_SDK_LICENSE_KEY && process.env.KRISP_VIVA_FILTER_MODEL_PATH) {
38
+ (0, import_log.log)().debug("Krisp: using license auth (env vars set)");
39
+ return new import_auth.KrispLicenseAuthProvider();
40
+ }
41
+ (0, import_log.log)().debug("Krisp: using LiveKit Cloud auth");
42
+ return new import_auth.LiveKitCloudAuthProvider();
43
+ }
44
+ function buildBackend(mode, provider, noiseSuppressionLevel) {
45
+ if (provider.kind === import_auth.LIVEKIT_CLOUD_KIND) {
46
+ let mod;
47
+ try {
48
+ mod = require2("@livekit/plugins-krisp-viva-internal");
49
+ } catch {
50
+ throw new Error(
51
+ "@livekit/plugins-krisp-viva-internal is missing \u2014 this package is bundled with @livekit/agents-plugin-krisp, so this likely means a broken install. Reinstall the plugin, or pass a KrispLicenseAuthProvider if you have a Krisp license key + .kef model."
52
+ );
53
+ }
54
+ return new mod.KrispVivaFilterFrameProcessor({
55
+ mode,
56
+ noiseSuppressionLevel,
57
+ frameDurationMs: DEFAULT_FRAME_DURATION_MS
58
+ });
59
+ }
60
+ return new import_krisp.KrispLicenseFrameProcessor({
61
+ modelPath: provider.modelPath,
62
+ noiseSuppressionLevel,
63
+ frameDurationMs: DEFAULT_FRAME_DURATION_MS
64
+ });
65
+ }
66
+ class KrispVivaFilter extends import_rtc_node.FrameProcessor {
67
+ inner;
68
+ constructor(opts = {}, mode = "voiceIsolation") {
69
+ super();
70
+ const provider = resolveAuthProvider(opts.authProvider);
71
+ this.inner = buildBackend(mode, provider, opts.noiseSuppressionLevel ?? 100);
72
+ }
73
+ isEnabled() {
74
+ return this.inner.isEnabled();
75
+ }
76
+ setEnabled(enabled) {
77
+ this.inner.setEnabled(enabled);
78
+ }
79
+ get noiseSuppressionLevel() {
80
+ return this.inner.noiseSuppressionLevel;
81
+ }
82
+ /** Adjust the noise suppression level (0-100) at runtime. */
83
+ setNoiseSuppressionLevel(value) {
84
+ this.inner.setNoiseSuppressionLevel(value);
85
+ }
86
+ onStreamInfoUpdated(info) {
87
+ this.inner.onStreamInfoUpdated(info);
88
+ }
89
+ onCredentialsUpdated(credentials) {
90
+ this.inner.onCredentialsUpdated(credentials);
91
+ }
92
+ process(frame) {
93
+ return this.inner.process(frame);
94
+ }
95
+ close() {
96
+ this.inner.close();
97
+ }
98
+ }
99
+ // Annotate the CommonJS export names for ESM import in node:
100
+ 0 && (module.exports = {
101
+ KrispVivaFilter
102
+ });
103
+ //# sourceMappingURL=viva_filter.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/viva_filter.ts","../../../node_modules/.pnpm/tsup@8.4.0_@microsoft+api-extractor@7.43.7_@types+node@25.6.0__postcss@8.5.17_tsx@4.21.0_typescript@5.9.3/node_modules/tsup/assets/cjs_shims.js"],"sourcesContent":["// SPDX-FileCopyrightText: 2026 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\n\n/**\n * Krisp VIVA noise reduction audio filter for LiveKit Agents.\n *\n * Exposes {@link KrispVivaFilter}, a thin facade that forwards to\n * one of two underlying FrameProcessor implementations:\n *\n * - The closed-source `@livekit/plugins-krisp-viva-internal` backend (default;\n * authenticates via the LiveKit Cloud-managed JWT the agent framework hands to\n * FrameProcessors through `onCredentialsUpdated`).\n * - A local license-mode wrapper around `@krisp/viva-node-sdk` (selected when the\n * user passes a {@link KrispLicenseAuthProvider}).\n */\nimport type * as KrispInternal from '@livekit/plugins-krisp-viva-internal';\nimport type {\n AudioFrame,\n FrameProcessorCredentials,\n FrameProcessorStreamInfo,\n} from '@livekit/rtc-node';\nimport { FrameProcessor } from '@livekit/rtc-node';\nimport { createRequire } from 'node:module';\nimport { KrispLicenseFrameProcessor } from './_krisp.js';\nimport {\n type AuthProvider,\n KrispLicenseAuthProvider,\n LIVEKIT_CLOUD_KIND,\n LiveKitCloudAuthProvider,\n} from './auth.js';\nimport { log } from './log.js';\n\nconst require = createRequire(import.meta.url);\n\n/**\n * Structural type for the backend FrameProcessors the facade forwards to.\n *\n * Both backends are `FrameProcessor<AudioFrame>` implementations that additionally\n * expose a runtime-settable noise suppression level (not part of the base\n * FrameProcessor interface).\n */\ninterface KrispBackend extends FrameProcessor<AudioFrame> {\n readonly noiseSuppressionLevel: number;\n setNoiseSuppressionLevel(value: number): void;\n}\n\n/**\n * Options for {@link KrispVivaFilter}.\n * @public\n */\nexport interface KrispVivaFilterOptions {\n /**\n * Authentication backend. When omitted, it is resolved from the environment:\n * the Krisp license path ({@link KrispLicenseAuthProvider}) is used when both\n * `KRISP_VIVA_SDK_LICENSE_KEY` and `KRISP_VIVA_FILTER_MODEL_PATH` are set;\n * otherwise it falls back to LiveKit Cloud auth ({@link LiveKitCloudAuthProvider}).\n */\n authProvider: AuthProvider;\n /** Noise suppression strength, 0..=100 where 100 is maximum suppression. Default 100. */\n noiseSuppressionLevel: number;\n}\n\nconst DEFAULT_FRAME_DURATION_MS = 10;\n\n/**\n * Pick the auth backend when the caller did not pass one explicitly. Uses the\n * Krisp license path when both `KRISP_VIVA_SDK_LICENSE_KEY` and\n * `KRISP_VIVA_FILTER_MODEL_PATH` are set (the user is responsible for having the\n * proprietary `@krisp/viva-node-sdk` installed); otherwise falls back to LiveKit\n * Cloud auth.\n */\nfunction resolveAuthProvider(explicit?: AuthProvider): AuthProvider {\n if (explicit) {\n return explicit;\n }\n if (process.env.KRISP_VIVA_SDK_LICENSE_KEY && process.env.KRISP_VIVA_FILTER_MODEL_PATH) {\n log().debug('Krisp: using license auth (env vars set)');\n return new KrispLicenseAuthProvider();\n }\n log().debug('Krisp: using LiveKit Cloud auth');\n return new LiveKitCloudAuthProvider();\n}\n\nfunction buildBackend(\n mode: KrispInternal.VivaMode,\n provider: AuthProvider,\n noiseSuppressionLevel: number,\n): KrispBackend {\n if (provider.kind === LIVEKIT_CLOUD_KIND) {\n let mod: typeof KrispInternal;\n try {\n mod = require('@livekit/plugins-krisp-viva-internal');\n } catch {\n throw new Error(\n '@livekit/plugins-krisp-viva-internal is missing — this package is bundled ' +\n 'with @livekit/agents-plugin-krisp, so this likely means a broken install. ' +\n 'Reinstall the plugin, or pass a KrispLicenseAuthProvider if you have a Krisp ' +\n 'license key + .kef model.',\n );\n }\n return new mod.KrispVivaFilterFrameProcessor({\n mode,\n noiseSuppressionLevel,\n frameDurationMs: DEFAULT_FRAME_DURATION_MS,\n });\n }\n\n // KrispLicenseAuthProvider\n return new KrispLicenseFrameProcessor({\n modelPath: provider.modelPath,\n noiseSuppressionLevel,\n frameDurationMs: DEFAULT_FRAME_DURATION_MS,\n });\n}\n\n/**\n * FrameProcessor for Krisp noise reduction.\n *\n * Thin facade over two backend FrameProcessor implementations: the LiveKit\n * Cloud-bundled package and a local wrapper around the public\n * `@krisp/viva-node-sdk`. When no `authProvider` is given, the backend is\n * resolved from the environment (see {@link KrispVivaFilterOptions.authProvider}).\n *\n * @example\n * ```ts\n * import * as krisp from '@livekit/agents-plugin-krisp';\n *\n * // Auto-resolves: Krisp license path if both KRISP_VIVA_SDK_LICENSE_KEY and\n * // KRISP_VIVA_FILTER_MODEL_PATH are set, else LiveKit Cloud auth.\n * const processor = krisp.voiceIsolation();\n *\n * // Or pin a backend explicitly.\n * const processor = krisp.voiceIsolation({\n * authProvider: krisp.auth.krispLicense(),\n * });\n *\n * await session.start({\n * agent,\n * room: ctx.room,\n * inputOptions: { noiseCancellation: processor },\n * });\n * ```\n *\n * @public\n */\nexport class KrispVivaFilter extends FrameProcessor<AudioFrame> {\n private readonly inner: KrispBackend;\n\n constructor(\n opts: Partial<KrispVivaFilterOptions> = {},\n mode: KrispInternal.VivaMode = 'voiceIsolation',\n ) {\n super();\n const provider = resolveAuthProvider(opts.authProvider);\n this.inner = buildBackend(mode, provider, opts.noiseSuppressionLevel ?? 100);\n }\n\n isEnabled(): boolean {\n return this.inner.isEnabled();\n }\n\n setEnabled(enabled: boolean): void {\n this.inner.setEnabled(enabled);\n }\n\n get noiseSuppressionLevel(): number {\n return this.inner.noiseSuppressionLevel;\n }\n\n /** Adjust the noise suppression level (0-100) at runtime. */\n setNoiseSuppressionLevel(value: number): void {\n this.inner.setNoiseSuppressionLevel(value);\n }\n\n override onStreamInfoUpdated(info: FrameProcessorStreamInfo): void {\n this.inner.onStreamInfoUpdated(info);\n }\n\n override onCredentialsUpdated(credentials: FrameProcessorCredentials): void {\n this.inner.onCredentialsUpdated(credentials);\n }\n\n process(frame: AudioFrame): AudioFrame {\n return this.inner.process(frame);\n }\n\n close(): void {\n this.inner.close();\n }\n}\n","// Shim globals in cjs bundle\n// There's a weird bug that esbuild will always inject importMetaUrl\n// if we export it as `const importMetaUrl = ... __filename ...`\n// But using a function will not cause this issue\n\nconst getImportMetaUrl = () =>\n typeof document === 'undefined'\n ? new URL(`file:${__filename}`).href\n : (document.currentScript && document.currentScript.src) ||\n new URL('main.js', document.baseURI).href\n\nexport const importMetaUrl = /* @__PURE__ */ getImportMetaUrl()\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACKA,IAAM,mBAAmB,MACvB,OAAO,aAAa,cAChB,IAAI,IAAI,QAAQ,UAAU,EAAE,EAAE,OAC7B,SAAS,iBAAiB,SAAS,cAAc,OAClD,IAAI,IAAI,WAAW,SAAS,OAAO,EAAE;AAEpC,IAAM,gBAAgC,iCAAiB;ADW9D,sBAA+B;AAC/B,yBAA8B;AAC9B,mBAA2C;AAC3C,kBAKO;AACP,iBAAoB;AAEpB,MAAMA,eAAU,kCAAc,aAAe;AA8B7C,MAAM,4BAA4B;AASlC,SAAS,oBAAoB,UAAuC;AAClE,MAAI,UAAU;AACZ,WAAO;AAAA,EACT;AACA,MAAI,QAAQ,IAAI,8BAA8B,QAAQ,IAAI,8BAA8B;AACtF,wBAAI,EAAE,MAAM,0CAA0C;AACtD,WAAO,IAAI,qCAAyB;AAAA,EACtC;AACA,sBAAI,EAAE,MAAM,iCAAiC;AAC7C,SAAO,IAAI,qCAAyB;AACtC;AAEA,SAAS,aACP,MACA,UACA,uBACc;AACd,MAAI,SAAS,SAAS,gCAAoB;AACxC,QAAI;AACJ,QAAI;AACF,YAAMA,SAAQ,sCAAsC;AAAA,IACtD,QAAQ;AACN,YAAM,IAAI;AAAA,QACR;AAAA,MAIF;AAAA,IACF;AACA,WAAO,IAAI,IAAI,8BAA8B;AAAA,MAC3C;AAAA,MACA;AAAA,MACA,iBAAiB;AAAA,IACnB,CAAC;AAAA,EACH;AAGA,SAAO,IAAI,wCAA2B;AAAA,IACpC,WAAW,SAAS;AAAA,IACpB;AAAA,IACA,iBAAiB;AAAA,EACnB,CAAC;AACH;AAgCO,MAAM,wBAAwB,+BAA2B;AAAA,EAC7C;AAAA,EAEjB,YACE,OAAwC,CAAC,GACzC,OAA+B,kBAC/B;AACA,UAAM;AACN,UAAM,WAAW,oBAAoB,KAAK,YAAY;AACtD,SAAK,QAAQ,aAAa,MAAM,UAAU,KAAK,yBAAyB,GAAG;AAAA,EAC7E;AAAA,EAEA,YAAqB;AACnB,WAAO,KAAK,MAAM,UAAU;AAAA,EAC9B;AAAA,EAEA,WAAW,SAAwB;AACjC,SAAK,MAAM,WAAW,OAAO;AAAA,EAC/B;AAAA,EAEA,IAAI,wBAAgC;AAClC,WAAO,KAAK,MAAM;AAAA,EACpB;AAAA;AAAA,EAGA,yBAAyB,OAAqB;AAC5C,SAAK,MAAM,yBAAyB,KAAK;AAAA,EAC3C;AAAA,EAES,oBAAoB,MAAsC;AACjE,SAAK,MAAM,oBAAoB,IAAI;AAAA,EACrC;AAAA,EAES,qBAAqB,aAA8C;AAC1E,SAAK,MAAM,qBAAqB,WAAW;AAAA,EAC7C;AAAA,EAEA,QAAQ,OAA+B;AACrC,WAAO,KAAK,MAAM,QAAQ,KAAK;AAAA,EACjC;AAAA,EAEA,QAAc;AACZ,SAAK,MAAM,MAAM;AAAA,EACnB;AACF;","names":["require"]}
@@ -0,0 +1,75 @@
1
+ /**
2
+ * Krisp VIVA noise reduction audio filter for LiveKit Agents.
3
+ *
4
+ * Exposes {@link KrispVivaFilter}, a thin facade that forwards to
5
+ * one of two underlying FrameProcessor implementations:
6
+ *
7
+ * - The closed-source `@livekit/plugins-krisp-viva-internal` backend (default;
8
+ * authenticates via the LiveKit Cloud-managed JWT the agent framework hands to
9
+ * FrameProcessors through `onCredentialsUpdated`).
10
+ * - A local license-mode wrapper around `@krisp/viva-node-sdk` (selected when the
11
+ * user passes a {@link KrispLicenseAuthProvider}).
12
+ */
13
+ import type * as KrispInternal from '@livekit/plugins-krisp-viva-internal';
14
+ import type { AudioFrame, FrameProcessorCredentials, FrameProcessorStreamInfo } from '@livekit/rtc-node';
15
+ import { FrameProcessor } from '@livekit/rtc-node';
16
+ import { type AuthProvider } from './auth.js';
17
+ /**
18
+ * Options for {@link KrispVivaFilter}.
19
+ * @public
20
+ */
21
+ export interface KrispVivaFilterOptions {
22
+ /**
23
+ * Authentication backend. When omitted, it is resolved from the environment:
24
+ * the Krisp license path ({@link KrispLicenseAuthProvider}) is used when both
25
+ * `KRISP_VIVA_SDK_LICENSE_KEY` and `KRISP_VIVA_FILTER_MODEL_PATH` are set;
26
+ * otherwise it falls back to LiveKit Cloud auth ({@link LiveKitCloudAuthProvider}).
27
+ */
28
+ authProvider: AuthProvider;
29
+ /** Noise suppression strength, 0..=100 where 100 is maximum suppression. Default 100. */
30
+ noiseSuppressionLevel: number;
31
+ }
32
+ /**
33
+ * FrameProcessor for Krisp noise reduction.
34
+ *
35
+ * Thin facade over two backend FrameProcessor implementations: the LiveKit
36
+ * Cloud-bundled package and a local wrapper around the public
37
+ * `@krisp/viva-node-sdk`. When no `authProvider` is given, the backend is
38
+ * resolved from the environment (see {@link KrispVivaFilterOptions.authProvider}).
39
+ *
40
+ * @example
41
+ * ```ts
42
+ * import * as krisp from '@livekit/agents-plugin-krisp';
43
+ *
44
+ * // Auto-resolves: Krisp license path if both KRISP_VIVA_SDK_LICENSE_KEY and
45
+ * // KRISP_VIVA_FILTER_MODEL_PATH are set, else LiveKit Cloud auth.
46
+ * const processor = krisp.voiceIsolation();
47
+ *
48
+ * // Or pin a backend explicitly.
49
+ * const processor = krisp.voiceIsolation({
50
+ * authProvider: krisp.auth.krispLicense(),
51
+ * });
52
+ *
53
+ * await session.start({
54
+ * agent,
55
+ * room: ctx.room,
56
+ * inputOptions: { noiseCancellation: processor },
57
+ * });
58
+ * ```
59
+ *
60
+ * @public
61
+ */
62
+ export declare class KrispVivaFilter extends FrameProcessor<AudioFrame> {
63
+ private readonly inner;
64
+ constructor(opts?: Partial<KrispVivaFilterOptions>, mode?: KrispInternal.VivaMode);
65
+ isEnabled(): boolean;
66
+ setEnabled(enabled: boolean): void;
67
+ get noiseSuppressionLevel(): number;
68
+ /** Adjust the noise suppression level (0-100) at runtime. */
69
+ setNoiseSuppressionLevel(value: number): void;
70
+ onStreamInfoUpdated(info: FrameProcessorStreamInfo): void;
71
+ onCredentialsUpdated(credentials: FrameProcessorCredentials): void;
72
+ process(frame: AudioFrame): AudioFrame;
73
+ close(): void;
74
+ }
75
+ //# sourceMappingURL=viva_filter.d.ts.map
@@ -0,0 +1,75 @@
1
+ /**
2
+ * Krisp VIVA noise reduction audio filter for LiveKit Agents.
3
+ *
4
+ * Exposes {@link KrispVivaFilter}, a thin facade that forwards to
5
+ * one of two underlying FrameProcessor implementations:
6
+ *
7
+ * - The closed-source `@livekit/plugins-krisp-viva-internal` backend (default;
8
+ * authenticates via the LiveKit Cloud-managed JWT the agent framework hands to
9
+ * FrameProcessors through `onCredentialsUpdated`).
10
+ * - A local license-mode wrapper around `@krisp/viva-node-sdk` (selected when the
11
+ * user passes a {@link KrispLicenseAuthProvider}).
12
+ */
13
+ import type * as KrispInternal from '@livekit/plugins-krisp-viva-internal';
14
+ import type { AudioFrame, FrameProcessorCredentials, FrameProcessorStreamInfo } from '@livekit/rtc-node';
15
+ import { FrameProcessor } from '@livekit/rtc-node';
16
+ import { type AuthProvider } from './auth.js';
17
+ /**
18
+ * Options for {@link KrispVivaFilter}.
19
+ * @public
20
+ */
21
+ export interface KrispVivaFilterOptions {
22
+ /**
23
+ * Authentication backend. When omitted, it is resolved from the environment:
24
+ * the Krisp license path ({@link KrispLicenseAuthProvider}) is used when both
25
+ * `KRISP_VIVA_SDK_LICENSE_KEY` and `KRISP_VIVA_FILTER_MODEL_PATH` are set;
26
+ * otherwise it falls back to LiveKit Cloud auth ({@link LiveKitCloudAuthProvider}).
27
+ */
28
+ authProvider: AuthProvider;
29
+ /** Noise suppression strength, 0..=100 where 100 is maximum suppression. Default 100. */
30
+ noiseSuppressionLevel: number;
31
+ }
32
+ /**
33
+ * FrameProcessor for Krisp noise reduction.
34
+ *
35
+ * Thin facade over two backend FrameProcessor implementations: the LiveKit
36
+ * Cloud-bundled package and a local wrapper around the public
37
+ * `@krisp/viva-node-sdk`. When no `authProvider` is given, the backend is
38
+ * resolved from the environment (see {@link KrispVivaFilterOptions.authProvider}).
39
+ *
40
+ * @example
41
+ * ```ts
42
+ * import * as krisp from '@livekit/agents-plugin-krisp';
43
+ *
44
+ * // Auto-resolves: Krisp license path if both KRISP_VIVA_SDK_LICENSE_KEY and
45
+ * // KRISP_VIVA_FILTER_MODEL_PATH are set, else LiveKit Cloud auth.
46
+ * const processor = krisp.voiceIsolation();
47
+ *
48
+ * // Or pin a backend explicitly.
49
+ * const processor = krisp.voiceIsolation({
50
+ * authProvider: krisp.auth.krispLicense(),
51
+ * });
52
+ *
53
+ * await session.start({
54
+ * agent,
55
+ * room: ctx.room,
56
+ * inputOptions: { noiseCancellation: processor },
57
+ * });
58
+ * ```
59
+ *
60
+ * @public
61
+ */
62
+ export declare class KrispVivaFilter extends FrameProcessor<AudioFrame> {
63
+ private readonly inner;
64
+ constructor(opts?: Partial<KrispVivaFilterOptions>, mode?: KrispInternal.VivaMode);
65
+ isEnabled(): boolean;
66
+ setEnabled(enabled: boolean): void;
67
+ get noiseSuppressionLevel(): number;
68
+ /** Adjust the noise suppression level (0-100) at runtime. */
69
+ setNoiseSuppressionLevel(value: number): void;
70
+ onStreamInfoUpdated(info: FrameProcessorStreamInfo): void;
71
+ onCredentialsUpdated(credentials: FrameProcessorCredentials): void;
72
+ process(frame: AudioFrame): AudioFrame;
73
+ close(): void;
74
+ }
75
+ //# sourceMappingURL=viva_filter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"viva_filter.d.ts","sourceRoot":"","sources":["../src/viva_filter.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;GAWG;AACH,OAAO,KAAK,KAAK,aAAa,MAAM,sCAAsC,CAAC;AAC3E,OAAO,KAAK,EACV,UAAU,EACV,yBAAyB,EACzB,wBAAwB,EACzB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAGnD,OAAO,EACL,KAAK,YAAY,EAIlB,MAAM,WAAW,CAAC;AAiBnB;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACrC;;;;;OAKG;IACH,YAAY,EAAE,YAAY,CAAC;IAC3B,yFAAyF;IACzF,qBAAqB,EAAE,MAAM,CAAC;CAC/B;AAuDD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,qBAAa,eAAgB,SAAQ,cAAc,CAAC,UAAU,CAAC;IAC7D,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAe;gBAGnC,IAAI,GAAE,OAAO,CAAC,sBAAsB,CAAM,EAC1C,IAAI,GAAE,aAAa,CAAC,QAA2B;IAOjD,SAAS,IAAI,OAAO;IAIpB,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IAIlC,IAAI,qBAAqB,IAAI,MAAM,CAElC;IAED,6DAA6D;IAC7D,wBAAwB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAIpC,mBAAmB,CAAC,IAAI,EAAE,wBAAwB,GAAG,IAAI;IAIzD,oBAAoB,CAAC,WAAW,EAAE,yBAAyB,GAAG,IAAI;IAI3E,OAAO,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU;IAItC,KAAK,IAAI,IAAI;CAGd"}
@@ -0,0 +1,81 @@
1
+ import { FrameProcessor } from "@livekit/rtc-node";
2
+ import { createRequire } from "node:module";
3
+ import { KrispLicenseFrameProcessor } from "./_krisp.js";
4
+ import {
5
+ KrispLicenseAuthProvider,
6
+ LIVEKIT_CLOUD_KIND,
7
+ LiveKitCloudAuthProvider
8
+ } from "./auth.js";
9
+ import { log } from "./log.js";
10
+ const require2 = createRequire(import.meta.url);
11
+ const DEFAULT_FRAME_DURATION_MS = 10;
12
+ function resolveAuthProvider(explicit) {
13
+ if (explicit) {
14
+ return explicit;
15
+ }
16
+ if (process.env.KRISP_VIVA_SDK_LICENSE_KEY && process.env.KRISP_VIVA_FILTER_MODEL_PATH) {
17
+ log().debug("Krisp: using license auth (env vars set)");
18
+ return new KrispLicenseAuthProvider();
19
+ }
20
+ log().debug("Krisp: using LiveKit Cloud auth");
21
+ return new LiveKitCloudAuthProvider();
22
+ }
23
+ function buildBackend(mode, provider, noiseSuppressionLevel) {
24
+ if (provider.kind === LIVEKIT_CLOUD_KIND) {
25
+ let mod;
26
+ try {
27
+ mod = require2("@livekit/plugins-krisp-viva-internal");
28
+ } catch {
29
+ throw new Error(
30
+ "@livekit/plugins-krisp-viva-internal is missing \u2014 this package is bundled with @livekit/agents-plugin-krisp, so this likely means a broken install. Reinstall the plugin, or pass a KrispLicenseAuthProvider if you have a Krisp license key + .kef model."
31
+ );
32
+ }
33
+ return new mod.KrispVivaFilterFrameProcessor({
34
+ mode,
35
+ noiseSuppressionLevel,
36
+ frameDurationMs: DEFAULT_FRAME_DURATION_MS
37
+ });
38
+ }
39
+ return new KrispLicenseFrameProcessor({
40
+ modelPath: provider.modelPath,
41
+ noiseSuppressionLevel,
42
+ frameDurationMs: DEFAULT_FRAME_DURATION_MS
43
+ });
44
+ }
45
+ class KrispVivaFilter extends FrameProcessor {
46
+ inner;
47
+ constructor(opts = {}, mode = "voiceIsolation") {
48
+ super();
49
+ const provider = resolveAuthProvider(opts.authProvider);
50
+ this.inner = buildBackend(mode, provider, opts.noiseSuppressionLevel ?? 100);
51
+ }
52
+ isEnabled() {
53
+ return this.inner.isEnabled();
54
+ }
55
+ setEnabled(enabled) {
56
+ this.inner.setEnabled(enabled);
57
+ }
58
+ get noiseSuppressionLevel() {
59
+ return this.inner.noiseSuppressionLevel;
60
+ }
61
+ /** Adjust the noise suppression level (0-100) at runtime. */
62
+ setNoiseSuppressionLevel(value) {
63
+ this.inner.setNoiseSuppressionLevel(value);
64
+ }
65
+ onStreamInfoUpdated(info) {
66
+ this.inner.onStreamInfoUpdated(info);
67
+ }
68
+ onCredentialsUpdated(credentials) {
69
+ this.inner.onCredentialsUpdated(credentials);
70
+ }
71
+ process(frame) {
72
+ return this.inner.process(frame);
73
+ }
74
+ close() {
75
+ this.inner.close();
76
+ }
77
+ }
78
+ export {
79
+ KrispVivaFilter
80
+ };
81
+ //# sourceMappingURL=viva_filter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/viva_filter.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2026 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\n\n/**\n * Krisp VIVA noise reduction audio filter for LiveKit Agents.\n *\n * Exposes {@link KrispVivaFilter}, a thin facade that forwards to\n * one of two underlying FrameProcessor implementations:\n *\n * - The closed-source `@livekit/plugins-krisp-viva-internal` backend (default;\n * authenticates via the LiveKit Cloud-managed JWT the agent framework hands to\n * FrameProcessors through `onCredentialsUpdated`).\n * - A local license-mode wrapper around `@krisp/viva-node-sdk` (selected when the\n * user passes a {@link KrispLicenseAuthProvider}).\n */\nimport type * as KrispInternal from '@livekit/plugins-krisp-viva-internal';\nimport type {\n AudioFrame,\n FrameProcessorCredentials,\n FrameProcessorStreamInfo,\n} from '@livekit/rtc-node';\nimport { FrameProcessor } from '@livekit/rtc-node';\nimport { createRequire } from 'node:module';\nimport { KrispLicenseFrameProcessor } from './_krisp.js';\nimport {\n type AuthProvider,\n KrispLicenseAuthProvider,\n LIVEKIT_CLOUD_KIND,\n LiveKitCloudAuthProvider,\n} from './auth.js';\nimport { log } from './log.js';\n\nconst require = createRequire(import.meta.url);\n\n/**\n * Structural type for the backend FrameProcessors the facade forwards to.\n *\n * Both backends are `FrameProcessor<AudioFrame>` implementations that additionally\n * expose a runtime-settable noise suppression level (not part of the base\n * FrameProcessor interface).\n */\ninterface KrispBackend extends FrameProcessor<AudioFrame> {\n readonly noiseSuppressionLevel: number;\n setNoiseSuppressionLevel(value: number): void;\n}\n\n/**\n * Options for {@link KrispVivaFilter}.\n * @public\n */\nexport interface KrispVivaFilterOptions {\n /**\n * Authentication backend. When omitted, it is resolved from the environment:\n * the Krisp license path ({@link KrispLicenseAuthProvider}) is used when both\n * `KRISP_VIVA_SDK_LICENSE_KEY` and `KRISP_VIVA_FILTER_MODEL_PATH` are set;\n * otherwise it falls back to LiveKit Cloud auth ({@link LiveKitCloudAuthProvider}).\n */\n authProvider: AuthProvider;\n /** Noise suppression strength, 0..=100 where 100 is maximum suppression. Default 100. */\n noiseSuppressionLevel: number;\n}\n\nconst DEFAULT_FRAME_DURATION_MS = 10;\n\n/**\n * Pick the auth backend when the caller did not pass one explicitly. Uses the\n * Krisp license path when both `KRISP_VIVA_SDK_LICENSE_KEY` and\n * `KRISP_VIVA_FILTER_MODEL_PATH` are set (the user is responsible for having the\n * proprietary `@krisp/viva-node-sdk` installed); otherwise falls back to LiveKit\n * Cloud auth.\n */\nfunction resolveAuthProvider(explicit?: AuthProvider): AuthProvider {\n if (explicit) {\n return explicit;\n }\n if (process.env.KRISP_VIVA_SDK_LICENSE_KEY && process.env.KRISP_VIVA_FILTER_MODEL_PATH) {\n log().debug('Krisp: using license auth (env vars set)');\n return new KrispLicenseAuthProvider();\n }\n log().debug('Krisp: using LiveKit Cloud auth');\n return new LiveKitCloudAuthProvider();\n}\n\nfunction buildBackend(\n mode: KrispInternal.VivaMode,\n provider: AuthProvider,\n noiseSuppressionLevel: number,\n): KrispBackend {\n if (provider.kind === LIVEKIT_CLOUD_KIND) {\n let mod: typeof KrispInternal;\n try {\n mod = require('@livekit/plugins-krisp-viva-internal');\n } catch {\n throw new Error(\n '@livekit/plugins-krisp-viva-internal is missing — this package is bundled ' +\n 'with @livekit/agents-plugin-krisp, so this likely means a broken install. ' +\n 'Reinstall the plugin, or pass a KrispLicenseAuthProvider if you have a Krisp ' +\n 'license key + .kef model.',\n );\n }\n return new mod.KrispVivaFilterFrameProcessor({\n mode,\n noiseSuppressionLevel,\n frameDurationMs: DEFAULT_FRAME_DURATION_MS,\n });\n }\n\n // KrispLicenseAuthProvider\n return new KrispLicenseFrameProcessor({\n modelPath: provider.modelPath,\n noiseSuppressionLevel,\n frameDurationMs: DEFAULT_FRAME_DURATION_MS,\n });\n}\n\n/**\n * FrameProcessor for Krisp noise reduction.\n *\n * Thin facade over two backend FrameProcessor implementations: the LiveKit\n * Cloud-bundled package and a local wrapper around the public\n * `@krisp/viva-node-sdk`. When no `authProvider` is given, the backend is\n * resolved from the environment (see {@link KrispVivaFilterOptions.authProvider}).\n *\n * @example\n * ```ts\n * import * as krisp from '@livekit/agents-plugin-krisp';\n *\n * // Auto-resolves: Krisp license path if both KRISP_VIVA_SDK_LICENSE_KEY and\n * // KRISP_VIVA_FILTER_MODEL_PATH are set, else LiveKit Cloud auth.\n * const processor = krisp.voiceIsolation();\n *\n * // Or pin a backend explicitly.\n * const processor = krisp.voiceIsolation({\n * authProvider: krisp.auth.krispLicense(),\n * });\n *\n * await session.start({\n * agent,\n * room: ctx.room,\n * inputOptions: { noiseCancellation: processor },\n * });\n * ```\n *\n * @public\n */\nexport class KrispVivaFilter extends FrameProcessor<AudioFrame> {\n private readonly inner: KrispBackend;\n\n constructor(\n opts: Partial<KrispVivaFilterOptions> = {},\n mode: KrispInternal.VivaMode = 'voiceIsolation',\n ) {\n super();\n const provider = resolveAuthProvider(opts.authProvider);\n this.inner = buildBackend(mode, provider, opts.noiseSuppressionLevel ?? 100);\n }\n\n isEnabled(): boolean {\n return this.inner.isEnabled();\n }\n\n setEnabled(enabled: boolean): void {\n this.inner.setEnabled(enabled);\n }\n\n get noiseSuppressionLevel(): number {\n return this.inner.noiseSuppressionLevel;\n }\n\n /** Adjust the noise suppression level (0-100) at runtime. */\n setNoiseSuppressionLevel(value: number): void {\n this.inner.setNoiseSuppressionLevel(value);\n }\n\n override onStreamInfoUpdated(info: FrameProcessorStreamInfo): void {\n this.inner.onStreamInfoUpdated(info);\n }\n\n override onCredentialsUpdated(credentials: FrameProcessorCredentials): void {\n this.inner.onCredentialsUpdated(credentials);\n }\n\n process(frame: AudioFrame): AudioFrame {\n return this.inner.process(frame);\n }\n\n close(): void {\n this.inner.close();\n }\n}\n"],"mappings":"AAsBA,SAAS,sBAAsB;AAC/B,SAAS,qBAAqB;AAC9B,SAAS,kCAAkC;AAC3C;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,WAAW;AAEpB,MAAMA,WAAU,cAAc,YAAY,GAAG;AA8B7C,MAAM,4BAA4B;AASlC,SAAS,oBAAoB,UAAuC;AAClE,MAAI,UAAU;AACZ,WAAO;AAAA,EACT;AACA,MAAI,QAAQ,IAAI,8BAA8B,QAAQ,IAAI,8BAA8B;AACtF,QAAI,EAAE,MAAM,0CAA0C;AACtD,WAAO,IAAI,yBAAyB;AAAA,EACtC;AACA,MAAI,EAAE,MAAM,iCAAiC;AAC7C,SAAO,IAAI,yBAAyB;AACtC;AAEA,SAAS,aACP,MACA,UACA,uBACc;AACd,MAAI,SAAS,SAAS,oBAAoB;AACxC,QAAI;AACJ,QAAI;AACF,YAAMA,SAAQ,sCAAsC;AAAA,IACtD,QAAQ;AACN,YAAM,IAAI;AAAA,QACR;AAAA,MAIF;AAAA,IACF;AACA,WAAO,IAAI,IAAI,8BAA8B;AAAA,MAC3C;AAAA,MACA;AAAA,MACA,iBAAiB;AAAA,IACnB,CAAC;AAAA,EACH;AAGA,SAAO,IAAI,2BAA2B;AAAA,IACpC,WAAW,SAAS;AAAA,IACpB;AAAA,IACA,iBAAiB;AAAA,EACnB,CAAC;AACH;AAgCO,MAAM,wBAAwB,eAA2B;AAAA,EAC7C;AAAA,EAEjB,YACE,OAAwC,CAAC,GACzC,OAA+B,kBAC/B;AACA,UAAM;AACN,UAAM,WAAW,oBAAoB,KAAK,YAAY;AACtD,SAAK,QAAQ,aAAa,MAAM,UAAU,KAAK,yBAAyB,GAAG;AAAA,EAC7E;AAAA,EAEA,YAAqB;AACnB,WAAO,KAAK,MAAM,UAAU;AAAA,EAC9B;AAAA,EAEA,WAAW,SAAwB;AACjC,SAAK,MAAM,WAAW,OAAO;AAAA,EAC/B;AAAA,EAEA,IAAI,wBAAgC;AAClC,WAAO,KAAK,MAAM;AAAA,EACpB;AAAA;AAAA,EAGA,yBAAyB,OAAqB;AAC5C,SAAK,MAAM,yBAAyB,KAAK;AAAA,EAC3C;AAAA,EAES,oBAAoB,MAAsC;AACjE,SAAK,MAAM,oBAAoB,IAAI;AAAA,EACrC;AAAA,EAES,qBAAqB,aAA8C;AAC1E,SAAK,MAAM,qBAAqB,WAAW;AAAA,EAC7C;AAAA,EAEA,QAAQ,OAA+B;AACrC,WAAO,KAAK,MAAM,QAAQ,KAAK;AAAA,EACjC;AAAA,EAEA,QAAc;AACZ,SAAK,MAAM,MAAM;AAAA,EACnB;AACF;","names":["require"]}