@livekit/agents-plugin-sarvam 1.0.45

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 (51) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +110 -0
  3. package/dist/index.cjs +52 -0
  4. package/dist/index.cjs.map +1 -0
  5. package/dist/index.d.cts +4 -0
  6. package/dist/index.d.ts +4 -0
  7. package/dist/index.d.ts.map +1 -0
  8. package/dist/index.js +29 -0
  9. package/dist/index.js.map +1 -0
  10. package/dist/models.cjs +17 -0
  11. package/dist/models.cjs.map +1 -0
  12. package/dist/models.d.cts +36 -0
  13. package/dist/models.d.ts +36 -0
  14. package/dist/models.d.ts.map +1 -0
  15. package/dist/models.js +1 -0
  16. package/dist/models.js.map +1 -0
  17. package/dist/stt.cjs +499 -0
  18. package/dist/stt.cjs.map +1 -0
  19. package/dist/stt.d.cts +104 -0
  20. package/dist/stt.d.ts +104 -0
  21. package/dist/stt.d.ts.map +1 -0
  22. package/dist/stt.js +483 -0
  23. package/dist/stt.js.map +1 -0
  24. package/dist/stt.test.cjs +18 -0
  25. package/dist/stt.test.cjs.map +1 -0
  26. package/dist/stt.test.d.cts +2 -0
  27. package/dist/stt.test.d.ts +2 -0
  28. package/dist/stt.test.d.ts.map +1 -0
  29. package/dist/stt.test.js +17 -0
  30. package/dist/stt.test.js.map +1 -0
  31. package/dist/tts.cjs +405 -0
  32. package/dist/tts.cjs.map +1 -0
  33. package/dist/tts.d.cts +111 -0
  34. package/dist/tts.d.ts +111 -0
  35. package/dist/tts.d.ts.map +1 -0
  36. package/dist/tts.js +385 -0
  37. package/dist/tts.js.map +1 -0
  38. package/dist/tts.test.cjs +17 -0
  39. package/dist/tts.test.cjs.map +1 -0
  40. package/dist/tts.test.d.cts +2 -0
  41. package/dist/tts.test.d.ts +2 -0
  42. package/dist/tts.test.d.ts.map +1 -0
  43. package/dist/tts.test.js +16 -0
  44. package/dist/tts.test.js.map +1 -0
  45. package/package.json +54 -0
  46. package/src/index.ts +34 -0
  47. package/src/models.ts +135 -0
  48. package/src/stt.test.ts +23 -0
  49. package/src/stt.ts +770 -0
  50. package/src/tts.test.ts +22 -0
  51. package/src/tts.ts +571 -0
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var import_agents_plugin_openai = require("@livekit/agents-plugin-openai");
3
+ var import_agents_plugins_test = require("@livekit/agents-plugins-test");
4
+ var import_vitest = require("vitest");
5
+ var import_tts = require("./tts.cjs");
6
+ const hasSarvamApiKey = Boolean(process.env.SARVAM_API_KEY);
7
+ (0, import_vitest.describe)("Sarvam TTS", () => {
8
+ import_vitest.it.skipIf(!hasSarvamApiKey)("runs integration suite with real API key", async () => {
9
+ await (0, import_agents_plugins_test.tts)(new import_tts.TTS({ apiKey: process.env.SARVAM_API_KEY }), new import_agents_plugin_openai.STT(), { streaming: false });
10
+ });
11
+ (0, import_vitest.it)("supports opting into non-streaming mode", () => {
12
+ const nonStreamingTts = new import_tts.TTS({ apiKey: "dummy-api-key", streaming: false });
13
+ (0, import_vitest.expect)(nonStreamingTts.capabilities.streaming).toBe(false);
14
+ (0, import_vitest.expect)(() => nonStreamingTts.stream()).toThrow(/streaming is disabled/i);
15
+ });
16
+ });
17
+ //# sourceMappingURL=tts.test.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/tts.test.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2025 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport { STT } from '@livekit/agents-plugin-openai';\nimport { tts } from '@livekit/agents-plugins-test';\nimport { describe, expect, it } from 'vitest';\nimport { TTS } from './tts.js';\n\nconst hasSarvamApiKey = Boolean(process.env.SARVAM_API_KEY);\n\ndescribe('Sarvam TTS', () => {\n it.skipIf(!hasSarvamApiKey)('runs integration suite with real API key', async () => {\n await tts(new TTS({ apiKey: process.env.SARVAM_API_KEY }), new STT(), { streaming: false });\n });\n\n it('supports opting into non-streaming mode', () => {\n const nonStreamingTts = new TTS({ apiKey: 'dummy-api-key', streaming: false });\n\n expect(nonStreamingTts.capabilities.streaming).toBe(false);\n expect(() => nonStreamingTts.stream()).toThrow(/streaming is disabled/i);\n });\n});\n"],"mappings":";AAGA,kCAAoB;AACpB,iCAAoB;AACpB,oBAAqC;AACrC,iBAAoB;AAEpB,MAAM,kBAAkB,QAAQ,QAAQ,IAAI,cAAc;AAAA,IAE1D,wBAAS,cAAc,MAAM;AAC3B,mBAAG,OAAO,CAAC,eAAe,EAAE,4CAA4C,YAAY;AAClF,cAAM,gCAAI,IAAI,eAAI,EAAE,QAAQ,QAAQ,IAAI,eAAe,CAAC,GAAG,IAAI,gCAAI,GAAG,EAAE,WAAW,MAAM,CAAC;AAAA,EAC5F,CAAC;AAED,wBAAG,2CAA2C,MAAM;AAClD,UAAM,kBAAkB,IAAI,eAAI,EAAE,QAAQ,iBAAiB,WAAW,MAAM,CAAC;AAE7E,8BAAO,gBAAgB,aAAa,SAAS,EAAE,KAAK,KAAK;AACzD,8BAAO,MAAM,gBAAgB,OAAO,CAAC,EAAE,QAAQ,wBAAwB;AAAA,EACzE,CAAC;AACH,CAAC;","names":[]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=tts.test.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=tts.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tts.test.d.ts","sourceRoot":"","sources":["../src/tts.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,16 @@
1
+ import { STT } from "@livekit/agents-plugin-openai";
2
+ import { tts } from "@livekit/agents-plugins-test";
3
+ import { describe, expect, it } from "vitest";
4
+ import { TTS } from "./tts.js";
5
+ const hasSarvamApiKey = Boolean(process.env.SARVAM_API_KEY);
6
+ describe("Sarvam TTS", () => {
7
+ it.skipIf(!hasSarvamApiKey)("runs integration suite with real API key", async () => {
8
+ await tts(new TTS({ apiKey: process.env.SARVAM_API_KEY }), new STT(), { streaming: false });
9
+ });
10
+ it("supports opting into non-streaming mode", () => {
11
+ const nonStreamingTts = new TTS({ apiKey: "dummy-api-key", streaming: false });
12
+ expect(nonStreamingTts.capabilities.streaming).toBe(false);
13
+ expect(() => nonStreamingTts.stream()).toThrow(/streaming is disabled/i);
14
+ });
15
+ });
16
+ //# sourceMappingURL=tts.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/tts.test.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2025 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport { STT } from '@livekit/agents-plugin-openai';\nimport { tts } from '@livekit/agents-plugins-test';\nimport { describe, expect, it } from 'vitest';\nimport { TTS } from './tts.js';\n\nconst hasSarvamApiKey = Boolean(process.env.SARVAM_API_KEY);\n\ndescribe('Sarvam TTS', () => {\n it.skipIf(!hasSarvamApiKey)('runs integration suite with real API key', async () => {\n await tts(new TTS({ apiKey: process.env.SARVAM_API_KEY }), new STT(), { streaming: false });\n });\n\n it('supports opting into non-streaming mode', () => {\n const nonStreamingTts = new TTS({ apiKey: 'dummy-api-key', streaming: false });\n\n expect(nonStreamingTts.capabilities.streaming).toBe(false);\n expect(() => nonStreamingTts.stream()).toThrow(/streaming is disabled/i);\n });\n});\n"],"mappings":"AAGA,SAAS,WAAW;AACpB,SAAS,WAAW;AACpB,SAAS,UAAU,QAAQ,UAAU;AACrC,SAAS,WAAW;AAEpB,MAAM,kBAAkB,QAAQ,QAAQ,IAAI,cAAc;AAE1D,SAAS,cAAc,MAAM;AAC3B,KAAG,OAAO,CAAC,eAAe,EAAE,4CAA4C,YAAY;AAClF,UAAM,IAAI,IAAI,IAAI,EAAE,QAAQ,QAAQ,IAAI,eAAe,CAAC,GAAG,IAAI,IAAI,GAAG,EAAE,WAAW,MAAM,CAAC;AAAA,EAC5F,CAAC;AAED,KAAG,2CAA2C,MAAM;AAClD,UAAM,kBAAkB,IAAI,IAAI,EAAE,QAAQ,iBAAiB,WAAW,MAAM,CAAC;AAE7E,WAAO,gBAAgB,aAAa,SAAS,EAAE,KAAK,KAAK;AACzD,WAAO,MAAM,gBAAgB,OAAO,CAAC,EAAE,QAAQ,wBAAwB;AAAA,EACzE,CAAC;AACH,CAAC;","names":[]}
package/package.json ADDED
@@ -0,0 +1,54 @@
1
+ {
2
+ "name": "@livekit/agents-plugin-sarvam",
3
+ "version": "1.0.45",
4
+ "description": "Sarvam AI plugin for LiveKit Node Agents",
5
+ "main": "dist/index.js",
6
+ "require": "dist/index.cjs",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ "import": {
10
+ "types": "./dist/index.d.ts",
11
+ "default": "./dist/index.js"
12
+ },
13
+ "require": {
14
+ "types": "./dist/index.d.cts",
15
+ "default": "./dist/index.cjs"
16
+ }
17
+ },
18
+ "author": "LiveKit",
19
+ "type": "module",
20
+ "repository": "git@github.com:livekit/agents-js.git",
21
+ "license": "Apache-2.0",
22
+ "files": [
23
+ "dist",
24
+ "src",
25
+ "README.md"
26
+ ],
27
+ "devDependencies": {
28
+ "@livekit/rtc-node": "^0.13.24",
29
+ "@types/ws": "^8.5.10",
30
+ "@microsoft/api-extractor": "^7.35.0",
31
+ "tsup": "^8.3.5",
32
+ "typescript": "^5.0.0",
33
+ "@livekit/agents-plugin-silero": "1.0.45",
34
+ "@livekit/agents-plugins-test": "1.0.45",
35
+ "@livekit/agents": "1.0.45",
36
+ "@livekit/agents-plugin-openai": "1.0.45"
37
+ },
38
+ "dependencies": {
39
+ "ws": "^8.16.0"
40
+ },
41
+ "peerDependencies": {
42
+ "@livekit/rtc-node": "^0.13.24",
43
+ "@livekit/agents": "1.0.45"
44
+ },
45
+ "scripts": {
46
+ "build": "tsup --onSuccess \"pnpm build:types\"",
47
+ "build:types": "tsc --declaration --emitDeclarationOnly && node ../../scripts/copyDeclarationOutput.js",
48
+ "clean": "rm -rf dist",
49
+ "clean:build": "pnpm clean && pnpm build",
50
+ "lint": "eslint -f unix \"src/**/*.{ts,js}\"",
51
+ "api:check": "api-extractor run --typescript-compiler-folder ../../node_modules/typescript",
52
+ "api:update": "api-extractor run --local --typescript-compiler-folder ../../node_modules/typescript --verbose"
53
+ }
54
+ }
package/src/index.ts ADDED
@@ -0,0 +1,34 @@
1
+ // SPDX-FileCopyrightText: 2025 LiveKit, Inc.
2
+ //
3
+ // SPDX-License-Identifier: Apache-2.0
4
+ import { Plugin } from '@livekit/agents';
5
+
6
+ export * from './models.js';
7
+ export {
8
+ STT,
9
+ SpeechStream,
10
+ type STTOptions,
11
+ type STTV2Options,
12
+ type STTTranslateOptions,
13
+ type STTV3Options,
14
+ } from './stt.js';
15
+ export {
16
+ ChunkedStream,
17
+ SynthesizeStream,
18
+ TTS,
19
+ type TTSOptions,
20
+ type TTSV2Options,
21
+ type TTSV3Options,
22
+ } from './tts.js';
23
+
24
+ class SarvamPlugin extends Plugin {
25
+ constructor() {
26
+ super({
27
+ title: 'sarvam',
28
+ version: '0.1.0',
29
+ package: '@livekit/agents-plugin-sarvam',
30
+ });
31
+ }
32
+ }
33
+
34
+ Plugin.registerPlugin(new SarvamPlugin());
package/src/models.ts ADDED
@@ -0,0 +1,135 @@
1
+ // SPDX-FileCopyrightText: 2025 LiveKit, Inc.
2
+ //
3
+ // SPDX-License-Identifier: Apache-2.0
4
+
5
+ /** Supported Sarvam AI TTS models */
6
+ export type TTSModels = 'bulbul:v2' | 'bulbul:v3';
7
+
8
+ /** Speakers available on bulbul:v3 (30+ voices) */
9
+ export type TTSV3Speakers =
10
+ | 'shubh'
11
+ | 'aditya'
12
+ | 'ritu'
13
+ | 'priya'
14
+ | 'neha'
15
+ | 'rahul'
16
+ | 'pooja'
17
+ | 'rohan'
18
+ | 'simran'
19
+ | 'kavya'
20
+ | 'amit'
21
+ | 'dev'
22
+ | 'ishita'
23
+ | 'shreya'
24
+ | 'ratan'
25
+ | 'varun'
26
+ | 'manan'
27
+ | 'sumit'
28
+ | 'roopa'
29
+ | 'kabir'
30
+ | 'aayan'
31
+ | 'ashutosh'
32
+ | 'advait'
33
+ | 'amelia'
34
+ | 'sophia'
35
+ | 'anand'
36
+ | 'tanya'
37
+ | 'tarun'
38
+ | 'sunny'
39
+ | 'mani'
40
+ | 'gokul'
41
+ | 'vijay'
42
+ | 'shruti'
43
+ | 'suhani'
44
+ | 'mohit'
45
+ | 'kavitha'
46
+ | 'rehan'
47
+ | 'soham'
48
+ | 'rupali';
49
+
50
+ /** Speakers available on bulbul:v2 */
51
+ export type TTSV2Speakers =
52
+ | 'anushka'
53
+ | 'manisha'
54
+ | 'vidya'
55
+ | 'arya'
56
+ | 'abhilash'
57
+ | 'karun'
58
+ | 'hitesh';
59
+
60
+ /** All supported speakers across both models */
61
+ export type TTSSpeakers = TTSV2Speakers | TTSV3Speakers;
62
+
63
+ /** Supported language codes for Sarvam AI TTS (BCP-47) */
64
+ export type TTSLanguages =
65
+ | 'bn-IN'
66
+ | 'en-IN'
67
+ | 'gu-IN'
68
+ | 'hi-IN'
69
+ | 'kn-IN'
70
+ | 'ml-IN'
71
+ | 'mr-IN'
72
+ | 'od-IN'
73
+ | 'pa-IN'
74
+ | 'ta-IN'
75
+ | 'te-IN';
76
+
77
+ /** Supported output sample rates in Hz */
78
+ export type TTSSampleRates = 8000 | 16000 | 22050 | 24000 | 32000 | 44100 | 48000;
79
+
80
+ // ---------------------------------------------------------------------------
81
+ // STT model types
82
+ // ---------------------------------------------------------------------------
83
+
84
+ /**
85
+ * Supported Sarvam AI STT models.
86
+ *
87
+ * @remarks
88
+ * - `saaras:v3` — recommended for new integrations. Supports all 22 languages, modes, and prompts.
89
+ * - `saaras:v2.5` — dedicated Indic-to-English translation via `/speech-to-text-translate`.
90
+ * Auto-detects the source language; supports prompts but not language codes or modes.
91
+ * - `saarika:v2.5` — will be deprecated soon. All its languages are available in `saaras:v3`.
92
+ *
93
+ * @see {@link https://docs.sarvam.ai/api-reference-docs/getting-started/models/saaras | Saaras model docs}
94
+ */
95
+ export type STTModels = 'saaras:v3' | 'saaras:v2.5' | 'saarika:v2.5';
96
+
97
+ /** Transcription modes available on saaras:v3 */
98
+ export type STTModes = 'transcribe' | 'translate' | 'verbatim' | 'translit' | 'codemix';
99
+
100
+ /**
101
+ * Languages supported by saarika:v2.5 (11 Indian languages).
102
+ * All of these are also available in {@link STTV3Languages}.
103
+ */
104
+ export type STTV2Languages =
105
+ | 'unknown'
106
+ | 'hi-IN'
107
+ | 'bn-IN'
108
+ | 'kn-IN'
109
+ | 'ml-IN'
110
+ | 'mr-IN'
111
+ | 'od-IN'
112
+ | 'pa-IN'
113
+ | 'ta-IN'
114
+ | 'te-IN'
115
+ | 'en-IN'
116
+ | 'gu-IN';
117
+
118
+ /** saaras:v3 supports all v2 languages plus 12 additional ones (22 Indian + English) */
119
+ export type STTV3Languages =
120
+ | STTV2Languages
121
+ | 'as-IN'
122
+ | 'ur-IN'
123
+ | 'ne-IN'
124
+ | 'kok-IN'
125
+ | 'ks-IN'
126
+ | 'sd-IN'
127
+ | 'sa-IN'
128
+ | 'sat-IN'
129
+ | 'mni-IN'
130
+ | 'brx-IN'
131
+ | 'mai-IN'
132
+ | 'doi-IN';
133
+
134
+ /** All supported STT language codes */
135
+ export type STTLanguages = STTV2Languages | STTV3Languages;
@@ -0,0 +1,23 @@
1
+ // SPDX-FileCopyrightText: 2025 LiveKit, Inc.
2
+ //
3
+ // SPDX-License-Identifier: Apache-2.0
4
+ import { VAD } from '@livekit/agents-plugin-silero';
5
+ import { stt } from '@livekit/agents-plugins-test';
6
+ import { describe, expect, it } from 'vitest';
7
+ import { STT } from './stt.js';
8
+
9
+ const hasSarvamApiKey = Boolean(process.env.SARVAM_API_KEY);
10
+
11
+ describe('Sarvam STT', () => {
12
+ it.skipIf(!hasSarvamApiKey)('runs integration suite with real API key', async () => {
13
+ const vad = await VAD.load();
14
+ await stt(new STT({ apiKey: process.env.SARVAM_API_KEY }), vad, { streaming: false });
15
+ });
16
+
17
+ it('supports opting into non-streaming mode', () => {
18
+ const nonStreamingStt = new STT({ apiKey: 'dummy-api-key', streaming: false });
19
+
20
+ expect(nonStreamingStt.capabilities.streaming).toBe(false);
21
+ expect(() => nonStreamingStt.stream()).toThrow(/streaming is disabled/i);
22
+ });
23
+ });