@livekit/agents-plugin-deepgram 1.0.50 → 1.1.0

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/tts.test.cjs CHANGED
@@ -1,9 +1,17 @@
1
1
  "use strict";
2
- var import_agents_plugin_deepgram = require("@livekit/agents-plugin-deepgram");
2
+ var import_agents_plugin_openai = require("@livekit/agents-plugin-openai");
3
3
  var import_agents_plugins_test = require("@livekit/agents-plugins-test");
4
4
  var import_vitest = require("vitest");
5
5
  var import_tts = require("./tts.cjs");
6
- (0, import_vitest.describe)("Deepgram", async () => {
7
- await (0, import_agents_plugins_test.tts)(new import_tts.TTS(), new import_agents_plugin_deepgram.STT());
8
- });
6
+ const hasDeepgramTtsConfig = Boolean(process.env.DEEPGRAM_API_KEY && process.env.OPENAI_API_KEY);
7
+ if (hasDeepgramTtsConfig) {
8
+ (0, import_vitest.describe)("Deepgram", async () => {
9
+ await (0, import_agents_plugins_test.tts)(new import_tts.TTS(), new import_agents_plugin_openai.STT());
10
+ });
11
+ } else {
12
+ (0, import_vitest.describe)("Deepgram", () => {
13
+ import_vitest.it.skip("requires DEEPGRAM_API_KEY and OPENAI_API_KEY", () => {
14
+ });
15
+ });
16
+ }
9
17
  //# sourceMappingURL=tts.test.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/tts.test.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport { STT } from '@livekit/agents-plugin-deepgram';\nimport { tts } from '@livekit/agents-plugins-test';\nimport { describe } from 'vitest';\nimport { TTS } from './tts.js';\n\ndescribe('Deepgram', async () => {\n await tts(new TTS(), new STT());\n});\n"],"mappings":";AAGA,oCAAoB;AACpB,iCAAoB;AACpB,oBAAyB;AACzB,iBAAoB;AAAA,IAEpB,wBAAS,YAAY,YAAY;AAC/B,YAAM,gCAAI,IAAI,eAAI,GAAG,IAAI,kCAAI,CAAC;AAChC,CAAC;","names":[]}
1
+ {"version":3,"sources":["../src/tts.test.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 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, it } from 'vitest';\nimport { TTS } from './tts.js';\n\nconst hasDeepgramTtsConfig = Boolean(process.env.DEEPGRAM_API_KEY && process.env.OPENAI_API_KEY);\n\nif (hasDeepgramTtsConfig) {\n describe('Deepgram', async () => {\n await tts(new TTS(), new STT());\n });\n} else {\n describe('Deepgram', () => {\n it.skip('requires DEEPGRAM_API_KEY and OPENAI_API_KEY', () => {});\n });\n}\n"],"mappings":";AAGA,kCAAoB;AACpB,iCAAoB;AACpB,oBAA6B;AAC7B,iBAAoB;AAEpB,MAAM,uBAAuB,QAAQ,QAAQ,IAAI,oBAAoB,QAAQ,IAAI,cAAc;AAE/F,IAAI,sBAAsB;AACxB,8BAAS,YAAY,YAAY;AAC/B,cAAM,gCAAI,IAAI,eAAI,GAAG,IAAI,gCAAI,CAAC;AAAA,EAChC,CAAC;AACH,OAAO;AACL,8BAAS,YAAY,MAAM;AACzB,qBAAG,KAAK,gDAAgD,MAAM;AAAA,IAAC,CAAC;AAAA,EAClE,CAAC;AACH;","names":[]}
package/dist/tts.test.js CHANGED
@@ -1,8 +1,16 @@
1
- import { STT } from "@livekit/agents-plugin-deepgram";
1
+ import { STT } from "@livekit/agents-plugin-openai";
2
2
  import { tts } from "@livekit/agents-plugins-test";
3
- import { describe } from "vitest";
3
+ import { describe, it } from "vitest";
4
4
  import { TTS } from "./tts.js";
5
- describe("Deepgram", async () => {
6
- await tts(new TTS(), new STT());
7
- });
5
+ const hasDeepgramTtsConfig = Boolean(process.env.DEEPGRAM_API_KEY && process.env.OPENAI_API_KEY);
6
+ if (hasDeepgramTtsConfig) {
7
+ describe("Deepgram", async () => {
8
+ await tts(new TTS(), new STT());
9
+ });
10
+ } else {
11
+ describe("Deepgram", () => {
12
+ it.skip("requires DEEPGRAM_API_KEY and OPENAI_API_KEY", () => {
13
+ });
14
+ });
15
+ }
8
16
  //# sourceMappingURL=tts.test.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/tts.test.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport { STT } from '@livekit/agents-plugin-deepgram';\nimport { tts } from '@livekit/agents-plugins-test';\nimport { describe } from 'vitest';\nimport { TTS } from './tts.js';\n\ndescribe('Deepgram', async () => {\n await tts(new TTS(), new STT());\n});\n"],"mappings":"AAGA,SAAS,WAAW;AACpB,SAAS,WAAW;AACpB,SAAS,gBAAgB;AACzB,SAAS,WAAW;AAEpB,SAAS,YAAY,YAAY;AAC/B,QAAM,IAAI,IAAI,IAAI,GAAG,IAAI,IAAI,CAAC;AAChC,CAAC;","names":[]}
1
+ {"version":3,"sources":["../src/tts.test.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 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, it } from 'vitest';\nimport { TTS } from './tts.js';\n\nconst hasDeepgramTtsConfig = Boolean(process.env.DEEPGRAM_API_KEY && process.env.OPENAI_API_KEY);\n\nif (hasDeepgramTtsConfig) {\n describe('Deepgram', async () => {\n await tts(new TTS(), new STT());\n });\n} else {\n describe('Deepgram', () => {\n it.skip('requires DEEPGRAM_API_KEY and OPENAI_API_KEY', () => {});\n });\n}\n"],"mappings":"AAGA,SAAS,WAAW;AACpB,SAAS,WAAW;AACpB,SAAS,UAAU,UAAU;AAC7B,SAAS,WAAW;AAEpB,MAAM,uBAAuB,QAAQ,QAAQ,IAAI,oBAAoB,QAAQ,IAAI,cAAc;AAE/F,IAAI,sBAAsB;AACxB,WAAS,YAAY,YAAY;AAC/B,UAAM,IAAI,IAAI,IAAI,GAAG,IAAI,IAAI,CAAC;AAAA,EAChC,CAAC;AACH,OAAO;AACL,WAAS,YAAY,MAAM;AACzB,OAAG,KAAK,gDAAgD,MAAM;AAAA,IAAC,CAAC;AAAA,EAClE,CAAC;AACH;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@livekit/agents-plugin-deepgram",
3
- "version": "1.0.50",
3
+ "version": "1.1.0",
4
4
  "description": "Deepgram plugin for LiveKit Agents for Node.js",
5
5
  "main": "dist/index.js",
6
6
  "require": "dist/index.cjs",
@@ -30,16 +30,17 @@
30
30
  "@types/ws": "^8.5.10",
31
31
  "tsup": "^8.3.5",
32
32
  "typescript": "^5.0.0",
33
- "@livekit/agents": "1.0.50",
34
- "@livekit/agents-plugin-silero": "1.0.50",
35
- "@livekit/agents-plugins-test": "1.0.50"
33
+ "@livekit/agents": "1.1.0",
34
+ "@livekit/agents-plugin-openai": "^1.1.0",
35
+ "@livekit/agents-plugin-silero": "1.1.0",
36
+ "@livekit/agents-plugins-test": "1.1.0"
36
37
  },
37
38
  "dependencies": {
38
39
  "ws": "^8.16.0"
39
40
  },
40
41
  "peerDependencies": {
41
42
  "@livekit/rtc-node": "^0.13.24",
42
- "@livekit/agents": "1.0.50"
43
+ "@livekit/agents": "1.1.0"
43
44
  },
44
45
  "scripts": {
45
46
  "build": "tsup --onSuccess \"pnpm build:types\"",
package/src/stt.test.ts CHANGED
@@ -1,13 +1,19 @@
1
1
  // SPDX-FileCopyrightText: 2024 LiveKit, Inc.
2
2
  //
3
3
  // SPDX-License-Identifier: Apache-2.0
4
- import { initializeLogger } from '@livekit/agents';
5
4
  import { VAD } from '@livekit/agents-plugin-silero';
6
5
  import { stt } from '@livekit/agents-plugins-test';
7
- import { describe } from 'vitest';
6
+ import { describe, it } from 'vitest';
8
7
  import { STT } from './stt.js';
9
8
 
10
- describe('Deepgram', async () => {
11
- initializeLogger({ pretty: false });
12
- await stt(new STT(), await VAD.load(), { nonStreaming: false });
13
- });
9
+ const hasDeepgramApiKey = Boolean(process.env.DEEPGRAM_API_KEY);
10
+
11
+ if (hasDeepgramApiKey) {
12
+ describe('Deepgram', async () => {
13
+ await stt(new STT(), await VAD.load(), { nonStreaming: false });
14
+ });
15
+ } else {
16
+ describe('Deepgram', () => {
17
+ it.skip('requires DEEPGRAM_API_KEY', () => {});
18
+ });
19
+ }
package/src/stt.ts CHANGED
@@ -9,7 +9,9 @@ import {
9
9
  Future,
10
10
  Task,
11
11
  createTimedString,
12
+ getBaseLanguage,
12
13
  log,
14
+ normalizeLanguage,
13
15
  stt,
14
16
  waitForAbort,
15
17
  } from '@livekit/agents';
@@ -70,6 +72,14 @@ export class STT extends stt.STT {
70
72
  label = 'deepgram.STT';
71
73
  private abortController = new AbortController();
72
74
 
75
+ get model(): string {
76
+ return this.#opts.model;
77
+ }
78
+
79
+ get provider(): string {
80
+ return 'Deepgram';
81
+ }
82
+
73
83
  constructor(opts: Partial<STTOptions> = defaultSTTOptions) {
74
84
  super({
75
85
  streaming: true,
@@ -82,13 +92,17 @@ export class STT extends stt.STT {
82
92
  );
83
93
  }
84
94
 
85
- this.#opts = { ...defaultSTTOptions, ...opts };
95
+ this.#opts = {
96
+ ...defaultSTTOptions,
97
+ ...opts,
98
+ language: opts.language ? normalizeLanguage(opts.language) : defaultSTTOptions.language,
99
+ };
86
100
 
87
101
  if (this.#opts.detectLanguage) {
88
102
  this.#opts.language = undefined;
89
103
  } else if (
90
104
  this.#opts.language &&
91
- !['en-US', 'en'].includes(this.#opts.language) &&
105
+ getBaseLanguage(this.#opts.language) !== 'en' &&
92
106
  [
93
107
  'nova-2-meeting',
94
108
  'nova-2-phonecall',
@@ -115,7 +129,12 @@ export class STT extends stt.STT {
115
129
  }
116
130
 
117
131
  updateOptions(opts: Partial<STTOptions>) {
118
- this.#opts = { ...this.#opts, ...opts };
132
+ this.#opts = {
133
+ ...this.#opts,
134
+ ...opts,
135
+ language:
136
+ opts.language !== undefined ? normalizeLanguage(opts.language) : this.#opts.language,
137
+ };
119
138
  }
120
139
 
121
140
  stream(options?: { connOptions?: APIConnectOptions }): SpeechStream {
@@ -433,9 +452,11 @@ const liveTranscriptionToSpeechData = (
433
452
 
434
453
  return alts.map((alt) => {
435
454
  const wordsData: any[] = alt['words'] ?? [];
455
+ const detectedLanguage =
456
+ language === 'multi' ? alt['languages']?.[0] ?? language : alt['language'] ?? language;
436
457
 
437
458
  return {
438
- language,
459
+ language: normalizeLanguage(detectedLanguage),
439
460
  startTime: wordsData.length ? wordsData[0]['start'] + startTimeOffset : startTimeOffset,
440
461
  endTime: wordsData.length
441
462
  ? wordsData[wordsData.length - 1]['end'] + startTimeOffset
@@ -1,13 +1,19 @@
1
1
  // SPDX-FileCopyrightText: 2025 LiveKit, Inc.
2
2
  //
3
3
  // SPDX-License-Identifier: Apache-2.0
4
- import { initializeLogger } from '@livekit/agents';
5
4
  import { VAD } from '@livekit/agents-plugin-silero';
6
5
  import { stt } from '@livekit/agents-plugins-test';
7
- import { describe } from 'vitest';
6
+ import { describe, it } from 'vitest';
8
7
  import { STTv2 } from './stt_v2.js';
9
8
 
10
- describe('Deepgram STTv2 (Flux)', async () => {
11
- initializeLogger({ pretty: false });
12
- await stt(new STTv2(), await VAD.load(), { nonStreaming: false });
13
- });
9
+ const hasDeepgramApiKey = Boolean(process.env.DEEPGRAM_API_KEY);
10
+
11
+ if (hasDeepgramApiKey) {
12
+ describe('Deepgram STTv2 (Flux)', async () => {
13
+ await stt(new STTv2(), await VAD.load(), { nonStreaming: false });
14
+ });
15
+ } else {
16
+ describe('Deepgram STTv2 (Flux)', () => {
17
+ it.skip('requires DEEPGRAM_API_KEY', () => {});
18
+ });
19
+ }
package/src/stt_v2.ts CHANGED
@@ -8,6 +8,7 @@ import {
8
8
  calculateAudioDurationSeconds,
9
9
  createTimedString,
10
10
  log,
11
+ normalizeLanguage,
11
12
  stt,
12
13
  } from '@livekit/agents';
13
14
  import type { AudioFrame } from '@livekit/rtc-node';
@@ -113,7 +114,11 @@ export class STTv2 extends stt.STT {
113
114
  alignedTranscript: 'word',
114
115
  });
115
116
 
116
- this.#opts = { ...defaultSTTv2Options, ...opts };
117
+ this.#opts = {
118
+ ...defaultSTTv2Options,
119
+ ...opts,
120
+ language: opts.language ? normalizeLanguage(opts.language) : defaultSTTv2Options.language,
121
+ };
117
122
 
118
123
  const apiKey = opts.apiKey || process.env.DEEPGRAM_API_KEY;
119
124
  if (!apiKey) {
@@ -197,7 +202,12 @@ class SpeechStreamv2 extends stt.SpeechStream {
197
202
 
198
203
  updateOptions(opts: Partial<STTv2Options>) {
199
204
  this.#logger.debug('Stream received option update', opts);
200
- this.#opts = { ...this.#opts, ...opts };
205
+ this.#opts = {
206
+ ...this.#opts,
207
+ ...opts,
208
+ language:
209
+ opts.language !== undefined ? normalizeLanguage(opts.language) : this.#opts.language,
210
+ };
201
211
  if (opts.tags) this.#opts.tags = validateTags(opts.tags);
202
212
 
203
213
  // Trigger reconnection loop
@@ -478,7 +488,7 @@ function parseTranscription(
478
488
  }
479
489
 
480
490
  const sd: stt.SpeechData = {
481
- language: language,
491
+ language: normalizeLanguage(language),
482
492
  startTime: ((data.audio_window_start as number) || 0) + startTimeOffset,
483
493
  endTime: ((data.audio_window_end as number) || 0) + startTimeOffset,
484
494
  confidence: confidence,
package/src/tts.test.ts CHANGED
@@ -1,11 +1,19 @@
1
1
  // SPDX-FileCopyrightText: 2024 LiveKit, Inc.
2
2
  //
3
3
  // SPDX-License-Identifier: Apache-2.0
4
- import { STT } from '@livekit/agents-plugin-deepgram';
4
+ import { STT } from '@livekit/agents-plugin-openai';
5
5
  import { tts } from '@livekit/agents-plugins-test';
6
- import { describe } from 'vitest';
6
+ import { describe, it } from 'vitest';
7
7
  import { TTS } from './tts.js';
8
8
 
9
- describe('Deepgram', async () => {
10
- await tts(new TTS(), new STT());
11
- });
9
+ const hasDeepgramTtsConfig = Boolean(process.env.DEEPGRAM_API_KEY && process.env.OPENAI_API_KEY);
10
+
11
+ if (hasDeepgramTtsConfig) {
12
+ describe('Deepgram', async () => {
13
+ await tts(new TTS(), new STT());
14
+ });
15
+ } else {
16
+ describe('Deepgram', () => {
17
+ it.skip('requires DEEPGRAM_API_KEY and OPENAI_API_KEY', () => {});
18
+ });
19
+ }
package/src/tts.ts CHANGED
@@ -46,6 +46,14 @@ export class TTS extends tts.TTS {
46
46
  private opts: TTSOptions;
47
47
  label = 'deepgram.TTS';
48
48
 
49
+ get model(): string {
50
+ return this.opts.model;
51
+ }
52
+
53
+ get provider(): string {
54
+ return 'Deepgram';
55
+ }
56
+
49
57
  constructor(opts: Partial<TTSOptions> = {}) {
50
58
  super(opts.sampleRate || defaultTTSOptions.sampleRate, NUM_CHANNELS, {
51
59
  streaming: opts.capabilities?.streaming ?? defaultTTSOptions.capabilities.streaming,