@livekit/agents-plugin-deepgram 1.4.9 → 1.4.11

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/src/tts.ts CHANGED
@@ -26,7 +26,9 @@ export interface TTSOptions {
26
26
  model: TTSModels | string;
27
27
  encoding: TTSEncoding;
28
28
  sampleRate: number;
29
+ bitRate?: number | null;
29
30
  speed?: number;
31
+ mipOptOut: boolean;
30
32
  apiKey?: string;
31
33
  baseUrl?: string;
32
34
  sentenceTokenizer: tokenize.SentenceTokenizer;
@@ -34,9 +36,11 @@ export interface TTSOptions {
34
36
  }
35
37
 
36
38
  const defaultTTSOptions: TTSOptions = {
37
- model: 'aura-asteria-en',
39
+ model: 'aura-2-andromeda-en',
38
40
  encoding: 'linear16',
39
41
  sampleRate: 24000,
42
+ bitRate: null,
43
+ mipOptOut: false,
40
44
  apiKey: process.env.DEEPGRAM_API_KEY,
41
45
  baseUrl: 'https://api.deepgram.com',
42
46
  capabilities: {
@@ -59,6 +63,10 @@ export class TTS extends tts.TTS {
59
63
  return 'Deepgram';
60
64
  }
61
65
 
66
+ override get sampleRate(): number {
67
+ return this.opts.sampleRate;
68
+ }
69
+
62
70
  constructor(opts: Partial<TTSOptions> = {}) {
63
71
  super(opts.sampleRate || defaultTTSOptions.sampleRate, NUM_CHANNELS, {
64
72
  streaming: opts.capabilities?.streaming ?? defaultTTSOptions.capabilities.streaming,
@@ -91,6 +99,17 @@ export class TTS extends tts.TTS {
91
99
  stream(options?: { connOptions?: APIConnectOptions }): tts.SynthesizeStream {
92
100
  return new SynthesizeStream(this, this.opts, options?.connOptions);
93
101
  }
102
+
103
+ updateOptions(
104
+ opts: Partial<
105
+ Pick<TTSOptions, 'model' | 'encoding' | 'sampleRate' | 'bitRate' | 'speed' | 'mipOptOut'>
106
+ >,
107
+ ) {
108
+ this.opts = {
109
+ ...this.opts,
110
+ ...opts,
111
+ };
112
+ }
94
113
  }
95
114
 
96
115
  export class ChunkedStream extends tts.ChunkedStream {
@@ -119,6 +138,11 @@ export class ChunkedStream extends tts.ChunkedStream {
119
138
  url.searchParams.append('sample_rate', this.opts.sampleRate.toString());
120
139
  url.searchParams.append('model', this.opts.model);
121
140
  url.searchParams.append('encoding', this.opts.encoding);
141
+ url.searchParams.append('container', 'none');
142
+ url.searchParams.append('mip_opt_out', String(this.opts.mipOptOut));
143
+ if (this.opts.bitRate !== undefined && this.opts.bitRate !== null) {
144
+ url.searchParams.append('bit_rate', this.opts.bitRate.toString());
145
+ }
122
146
  if (this.opts.speed !== undefined) {
123
147
  url.searchParams.append('speed', this.opts.speed.toString());
124
148
  }
@@ -275,6 +299,10 @@ export class SynthesizeStream extends tts.SynthesizeStream {
275
299
  url.searchParams.append('sample_rate', this.opts.sampleRate.toString());
276
300
  url.searchParams.append('model', this.opts.model);
277
301
  url.searchParams.append('encoding', this.opts.encoding);
302
+ url.searchParams.append('mip_opt_out', String(this.opts.mipOptOut));
303
+ if (this.opts.bitRate !== undefined && this.opts.bitRate !== null) {
304
+ url.searchParams.append('bit_rate', this.opts.bitRate.toString());
305
+ }
278
306
  if (this.opts.speed !== undefined) {
279
307
  url.searchParams.append('speed', this.opts.speed.toString());
280
308
  }