@mastra/voice-deepgram 0.0.0-storage-20250225005900 → 0.0.0-stream-vnext-usage-20250908171242

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/LICENSE.md ADDED
@@ -0,0 +1,15 @@
1
+ # Apache License 2.0
2
+
3
+ Copyright (c) 2025 Kepler Software, Inc.
4
+
5
+ Licensed under the Apache License, Version 2.0 (the "License");
6
+ you may not use this file except in compliance with the License.
7
+ You may obtain a copy of the License at
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
package/dist/index.cjs ADDED
@@ -0,0 +1,181 @@
1
+ 'use strict';
2
+
3
+ var stream = require('stream');
4
+ var sdk = require('@deepgram/sdk');
5
+ var voice = require('@mastra/core/voice');
6
+
7
+ // src/index.ts
8
+
9
+ // src/voices.ts
10
+ var DEEPGRAM_VOICES = [
11
+ "asteria-en",
12
+ "luna-en",
13
+ "stella-en",
14
+ "athena-en",
15
+ "hera-en",
16
+ "orion-en",
17
+ "arcas-en",
18
+ "perseus-en",
19
+ "angus-en",
20
+ "orpheus-en",
21
+ "helios-en",
22
+ "zeus-en"
23
+ ];
24
+
25
+ // src/index.ts
26
+ var DeepgramVoice = class extends voice.MastraVoice {
27
+ speechClient;
28
+ listeningClient;
29
+ constructor({
30
+ speechModel,
31
+ listeningModel,
32
+ speaker
33
+ } = {}) {
34
+ const defaultApiKey = process.env.DEEPGRAM_API_KEY;
35
+ const defaultSpeechModel = {
36
+ name: "aura",
37
+ apiKey: defaultApiKey
38
+ };
39
+ const defaultListeningModel = {
40
+ name: "nova",
41
+ apiKey: defaultApiKey
42
+ };
43
+ super({
44
+ speechModel: {
45
+ name: speechModel?.name ?? defaultSpeechModel.name,
46
+ apiKey: speechModel?.apiKey ?? defaultSpeechModel.apiKey
47
+ },
48
+ listeningModel: {
49
+ name: listeningModel?.name ?? defaultListeningModel.name,
50
+ apiKey: listeningModel?.apiKey ?? defaultListeningModel.apiKey
51
+ },
52
+ speaker
53
+ });
54
+ const speechApiKey = speechModel?.apiKey || defaultApiKey;
55
+ const listeningApiKey = listeningModel?.apiKey || defaultApiKey;
56
+ if (!speechApiKey && !listeningApiKey) {
57
+ throw new Error("At least one of DEEPGRAM_API_KEY, speechModel.apiKey, or listeningModel.apiKey must be set");
58
+ }
59
+ if (speechApiKey) {
60
+ this.speechClient = sdk.createClient(speechApiKey);
61
+ }
62
+ if (listeningApiKey) {
63
+ this.listeningClient = sdk.createClient(listeningApiKey);
64
+ }
65
+ this.speaker = speaker || "asteria-en";
66
+ }
67
+ async getSpeakers() {
68
+ return this.traced(async () => {
69
+ return DEEPGRAM_VOICES.map((voice) => ({
70
+ voiceId: voice
71
+ }));
72
+ }, "voice.deepgram.getSpeakers")();
73
+ }
74
+ async speak(input, options) {
75
+ if (!this.speechClient) {
76
+ throw new Error("Deepgram speech client not configured");
77
+ }
78
+ let text;
79
+ if (typeof input !== "string") {
80
+ const chunks = [];
81
+ for await (const chunk of input) {
82
+ if (typeof chunk === "string") {
83
+ chunks.push(Buffer.from(chunk));
84
+ } else {
85
+ chunks.push(chunk);
86
+ }
87
+ }
88
+ text = Buffer.concat(chunks).toString("utf-8");
89
+ } else {
90
+ text = input;
91
+ }
92
+ if (text.trim().length === 0) {
93
+ throw new Error("Input text is empty");
94
+ }
95
+ return this.traced(async () => {
96
+ if (!this.speechClient) {
97
+ throw new Error("No speech client configured");
98
+ }
99
+ let model;
100
+ if (options?.speaker) {
101
+ model = this.speechModel?.name + "-" + options.speaker;
102
+ } else if (this.speaker) {
103
+ model = this.speechModel?.name + "-" + this.speaker;
104
+ }
105
+ const speakClient = this.speechClient.speak;
106
+ const response = await speakClient.request(
107
+ { text },
108
+ {
109
+ model,
110
+ ...options
111
+ }
112
+ );
113
+ const webStream = await response.getStream();
114
+ if (!webStream) {
115
+ throw new Error("No stream returned from Deepgram");
116
+ }
117
+ const reader = webStream.getReader();
118
+ const nodeStream = new stream.PassThrough();
119
+ (async () => {
120
+ try {
121
+ while (true) {
122
+ const { done, value } = await reader.read();
123
+ if (done) {
124
+ nodeStream.end();
125
+ break;
126
+ }
127
+ nodeStream.write(value);
128
+ }
129
+ } catch (error) {
130
+ nodeStream.destroy(error);
131
+ }
132
+ })().catch((error) => {
133
+ nodeStream.destroy(error);
134
+ });
135
+ return nodeStream;
136
+ }, "voice.deepgram.speak")();
137
+ }
138
+ /**
139
+ * Checks if listening capabilities are enabled.
140
+ *
141
+ * @returns {Promise<{ enabled: boolean }>}
142
+ */
143
+ async getListener() {
144
+ return { enabled: true };
145
+ }
146
+ async listen(audioStream, options) {
147
+ if (!this.listeningClient) {
148
+ throw new Error("Deepgram listening client not configured");
149
+ }
150
+ const chunks = [];
151
+ for await (const chunk of audioStream) {
152
+ if (typeof chunk === "string") {
153
+ chunks.push(Buffer.from(chunk));
154
+ } else {
155
+ chunks.push(chunk);
156
+ }
157
+ }
158
+ const buffer = Buffer.concat(chunks);
159
+ return this.traced(async () => {
160
+ if (!this.listeningClient) {
161
+ throw new Error("No listening client configured");
162
+ }
163
+ const { result, error } = await this.listeningClient.listen.prerecorded.transcribeFile(buffer, {
164
+ model: this.listeningModel?.name,
165
+ ...options
166
+ });
167
+ if (error) {
168
+ throw error;
169
+ }
170
+ const transcript = result.results?.channels?.[0]?.alternatives?.[0]?.transcript;
171
+ if (!transcript) {
172
+ throw new Error("No transcript found in Deepgram response");
173
+ }
174
+ return transcript;
175
+ }, "voice.deepgram.listen")();
176
+ }
177
+ };
178
+
179
+ exports.DeepgramVoice = DeepgramVoice;
180
+ //# sourceMappingURL=index.cjs.map
181
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/voices.ts","../src/index.ts"],"names":["MastraVoice","createClient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AA,CAAY,cAAA,CAAe,MAAA,EAAQ;AAAA,QAC7F,KAAA,EAAO,KAAK,cAAA,EAAgB,IAAA;AAAA,QAC5B,GAAG;AAAA,OACJ,CAAA;AAED,MAAA,IAAI,KAAA,EAAO;AACT,QAAA,MAAM,KAAA;AAAA,MACR;AAEA,MAAA,MAAM,UAAA,GAAa,OAAO,OAAA,EAAS,QAAA,GAAW,CAAC,CAAA,EAAG,YAAA,GAAe,CAAC,CAAA,EAAG,UAAA;AACrE,MAAA,IAAI,CAAC,UAAA,EAAY;AACf,QAAA,MAAM,IAAI,MAAM,0CAA0C,CAAA;AAAA,MAC5D;AAEA,MAAA,OAAO,UAAA;AAAA,IACT,CAAA,EAAG,uBAAuB,CAAA,EAAE;AAAA,EAC9B;AACF","file":"index.cjs","sourcesContent":["/**\n * List of available Deepgram voice models for text-to-speech\n * Each voice is designed for specific use cases and languages\n * Format: {name}-{language} (e.g. asteria-en)\n */\nexport const DEEPGRAM_VOICES = [\n 'asteria-en',\n 'luna-en',\n 'stella-en',\n 'athena-en',\n 'hera-en',\n 'orion-en',\n 'arcas-en',\n 'perseus-en',\n 'angus-en',\n 'orpheus-en',\n 'helios-en',\n 'zeus-en',\n] as const;\n\nexport type DeepgramVoiceId = (typeof DEEPGRAM_VOICES)[number];\n\n/**\n * List of available Deepgram models for text-to-speech and speech-to-text\n */\nexport const DEEPGRAM_MODELS = ['aura', 'whisper', 'base', 'enhanced', 'nova', 'nova-2', 'nova-3'] as const;\n\nexport type DeepgramModel = (typeof DEEPGRAM_MODELS)[number];\n","import { PassThrough } from 'stream';\n\nimport { createClient } from '@deepgram/sdk';\nimport { MastraVoice } from '@mastra/core/voice';\n\nimport { DEEPGRAM_VOICES } from './voices';\nimport type { DeepgramVoiceId, DeepgramModel } from './voices';\n\ninterface DeepgramVoiceConfig {\n name?: DeepgramModel;\n apiKey?: string;\n properties?: Record<string, any>;\n language?: string;\n}\n\nexport class DeepgramVoice extends MastraVoice {\n private speechClient?: ReturnType<typeof createClient>;\n private listeningClient?: ReturnType<typeof createClient>;\n\n constructor({\n speechModel,\n listeningModel,\n speaker,\n }: { speechModel?: DeepgramVoiceConfig; listeningModel?: DeepgramVoiceConfig; speaker?: DeepgramVoiceId } = {}) {\n const defaultApiKey = process.env.DEEPGRAM_API_KEY;\n\n const defaultSpeechModel = {\n name: 'aura',\n apiKey: defaultApiKey,\n };\n\n const defaultListeningModel = {\n name: 'nova',\n apiKey: defaultApiKey,\n };\n\n super({\n speechModel: {\n name: speechModel?.name ?? defaultSpeechModel.name,\n apiKey: speechModel?.apiKey ?? defaultSpeechModel.apiKey,\n },\n listeningModel: {\n name: listeningModel?.name ?? defaultListeningModel.name,\n apiKey: listeningModel?.apiKey ?? defaultListeningModel.apiKey,\n },\n speaker,\n });\n\n const speechApiKey = speechModel?.apiKey || defaultApiKey;\n const listeningApiKey = listeningModel?.apiKey || defaultApiKey;\n\n if (!speechApiKey && !listeningApiKey) {\n throw new Error('At least one of DEEPGRAM_API_KEY, speechModel.apiKey, or listeningModel.apiKey must be set');\n }\n\n if (speechApiKey) {\n this.speechClient = createClient(speechApiKey);\n }\n if (listeningApiKey) {\n this.listeningClient = createClient(listeningApiKey);\n }\n\n this.speaker = speaker || 'asteria-en';\n }\n\n async getSpeakers() {\n return this.traced(async () => {\n return DEEPGRAM_VOICES.map(voice => ({\n voiceId: voice,\n }));\n }, 'voice.deepgram.getSpeakers')();\n }\n\n async speak(\n input: string | NodeJS.ReadableStream,\n options?: {\n speaker?: string;\n [key: string]: any;\n },\n ): Promise<NodeJS.ReadableStream> {\n if (!this.speechClient) {\n throw new Error('Deepgram speech client not configured');\n }\n\n let text: string;\n if (typeof input !== 'string') {\n const chunks: Buffer[] = [];\n for await (const chunk of input) {\n if (typeof chunk === 'string') {\n chunks.push(Buffer.from(chunk));\n } else {\n chunks.push(chunk);\n }\n }\n text = Buffer.concat(chunks).toString('utf-8');\n } else {\n text = input;\n }\n\n if (text.trim().length === 0) {\n throw new Error('Input text is empty');\n }\n\n return this.traced(async () => {\n if (!this.speechClient) {\n throw new Error('No speech client configured');\n }\n\n let model;\n if (options?.speaker) {\n model = this.speechModel?.name + '-' + options.speaker;\n } else if (this.speaker) {\n model = this.speechModel?.name + '-' + this.speaker;\n }\n\n const speakClient = this.speechClient.speak;\n const response = await speakClient.request(\n { text },\n {\n model,\n ...options,\n },\n );\n\n const webStream = await response.getStream();\n if (!webStream) {\n throw new Error('No stream returned from Deepgram');\n }\n\n const reader = webStream.getReader();\n const nodeStream = new PassThrough();\n\n // Add error handling for the stream processing\n (async () => {\n try {\n while (true) {\n const { done, value } = await reader.read();\n if (done) {\n nodeStream.end();\n break;\n }\n nodeStream.write(value);\n }\n } catch (error) {\n nodeStream.destroy(error as Error);\n }\n })().catch(error => {\n nodeStream.destroy(error as Error);\n });\n\n return nodeStream;\n }, 'voice.deepgram.speak')();\n }\n\n /**\n * Checks if listening capabilities are enabled.\n *\n * @returns {Promise<{ enabled: boolean }>}\n */\n async getListener() {\n return { enabled: true };\n }\n\n async listen(\n audioStream: NodeJS.ReadableStream,\n options?: {\n [key: string]: any;\n },\n ): Promise<string> {\n if (!this.listeningClient) {\n throw new Error('Deepgram listening client not configured');\n }\n\n const chunks: Buffer[] = [];\n for await (const chunk of audioStream) {\n if (typeof chunk === 'string') {\n chunks.push(Buffer.from(chunk));\n } else {\n chunks.push(chunk);\n }\n }\n const buffer = Buffer.concat(chunks);\n\n return this.traced(async () => {\n if (!this.listeningClient) {\n throw new Error('No listening client configured');\n }\n const { result, error } = await this.listeningClient.listen.prerecorded.transcribeFile(buffer, {\n model: this.listeningModel?.name,\n ...options,\n });\n\n if (error) {\n throw error;\n }\n\n const transcript = result.results?.channels?.[0]?.alternatives?.[0]?.transcript;\n if (!transcript) {\n throw new Error('No transcript found in Deepgram response');\n }\n\n return transcript;\n }, 'voice.deepgram.listen')();\n }\n}\n\nexport type { DeepgramVoiceConfig, DeepgramVoiceId, DeepgramModel };\n"]}
package/dist/index.d.ts CHANGED
@@ -1,4 +1,37 @@
1
- export { DeepgramVoice } from './_tsup-dts-rollup.js';
2
- export { DeepgramVoiceConfig } from './_tsup-dts-rollup.js';
3
- export { DeepgramVoiceId } from './_tsup-dts-rollup.js';
4
- export { DeepgramModel } from './_tsup-dts-rollup.js';
1
+ import { MastraVoice } from '@mastra/core/voice';
2
+ import type { DeepgramVoiceId, DeepgramModel } from './voices.js';
3
+ interface DeepgramVoiceConfig {
4
+ name?: DeepgramModel;
5
+ apiKey?: string;
6
+ properties?: Record<string, any>;
7
+ language?: string;
8
+ }
9
+ export declare class DeepgramVoice extends MastraVoice {
10
+ private speechClient?;
11
+ private listeningClient?;
12
+ constructor({ speechModel, listeningModel, speaker, }?: {
13
+ speechModel?: DeepgramVoiceConfig;
14
+ listeningModel?: DeepgramVoiceConfig;
15
+ speaker?: DeepgramVoiceId;
16
+ });
17
+ getSpeakers(): Promise<{
18
+ voiceId: "asteria-en" | "luna-en" | "stella-en" | "athena-en" | "hera-en" | "orion-en" | "arcas-en" | "perseus-en" | "angus-en" | "orpheus-en" | "helios-en" | "zeus-en";
19
+ }[]>;
20
+ speak(input: string | NodeJS.ReadableStream, options?: {
21
+ speaker?: string;
22
+ [key: string]: any;
23
+ }): Promise<NodeJS.ReadableStream>;
24
+ /**
25
+ * Checks if listening capabilities are enabled.
26
+ *
27
+ * @returns {Promise<{ enabled: boolean }>}
28
+ */
29
+ getListener(): Promise<{
30
+ enabled: boolean;
31
+ }>;
32
+ listen(audioStream: NodeJS.ReadableStream, options?: {
33
+ [key: string]: any;
34
+ }): Promise<string>;
35
+ }
36
+ export type { DeepgramVoiceConfig, DeepgramVoiceId, DeepgramModel };
37
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAGjD,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE/D,UAAU,mBAAmB;IAC3B,IAAI,CAAC,EAAE,aAAa,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACjC,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,qBAAa,aAAc,SAAQ,WAAW;IAC5C,OAAO,CAAC,YAAY,CAAC,CAAkC;IACvD,OAAO,CAAC,eAAe,CAAC,CAAkC;gBAE9C,EACV,WAAW,EACX,cAAc,EACd,OAAO,GACR,GAAE;QAAE,WAAW,CAAC,EAAE,mBAAmB,CAAC;QAAC,cAAc,CAAC,EAAE,mBAAmB,CAAC;QAAC,OAAO,CAAC,EAAE,eAAe,CAAA;KAAO;IA0CxG,WAAW;;;IAQX,KAAK,CACT,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,cAAc,EACrC,OAAO,CAAC,EAAE;QACR,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;KACpB,GACA,OAAO,CAAC,MAAM,CAAC,cAAc,CAAC;IA2EjC;;;;OAIG;IACG,WAAW;;;IAIX,MAAM,CACV,WAAW,EAAE,MAAM,CAAC,cAAc,EAClC,OAAO,CAAC,EAAE;QACR,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;KACpB,GACA,OAAO,CAAC,MAAM,CAAC;CAoCnB;AAED,YAAY,EAAE,mBAAmB,EAAE,eAAe,EAAE,aAAa,EAAE,CAAC"}
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
+ import { PassThrough } from 'stream';
1
2
  import { createClient } from '@deepgram/sdk';
2
3
  import { MastraVoice } from '@mastra/core/voice';
3
- import { PassThrough } from 'stream';
4
4
 
5
5
  // src/index.ts
6
6
 
@@ -51,8 +51,6 @@ var DeepgramVoice = class extends MastraVoice {
51
51
  });
52
52
  const speechApiKey = speechModel?.apiKey || defaultApiKey;
53
53
  const listeningApiKey = listeningModel?.apiKey || defaultApiKey;
54
- console.log("speechApiKey", speechApiKey);
55
- console.log("listeningApiKey", listeningApiKey);
56
54
  if (!speechApiKey && !listeningApiKey) {
57
55
  throw new Error("At least one of DEEPGRAM_API_KEY, speechModel.apiKey, or listeningModel.apiKey must be set");
58
56
  }
@@ -79,7 +77,11 @@ var DeepgramVoice = class extends MastraVoice {
79
77
  if (typeof input !== "string") {
80
78
  const chunks = [];
81
79
  for await (const chunk of input) {
82
- chunks.push(Buffer.from(chunk));
80
+ if (typeof chunk === "string") {
81
+ chunks.push(Buffer.from(chunk));
82
+ } else {
83
+ chunks.push(chunk);
84
+ }
83
85
  }
84
86
  text = Buffer.concat(chunks).toString("utf-8");
85
87
  } else {
@@ -131,13 +133,25 @@ var DeepgramVoice = class extends MastraVoice {
131
133
  return nodeStream;
132
134
  }, "voice.deepgram.speak")();
133
135
  }
136
+ /**
137
+ * Checks if listening capabilities are enabled.
138
+ *
139
+ * @returns {Promise<{ enabled: boolean }>}
140
+ */
141
+ async getListener() {
142
+ return { enabled: true };
143
+ }
134
144
  async listen(audioStream, options) {
135
145
  if (!this.listeningClient) {
136
146
  throw new Error("Deepgram listening client not configured");
137
147
  }
138
148
  const chunks = [];
139
149
  for await (const chunk of audioStream) {
140
- chunks.push(Buffer.from(chunk));
150
+ if (typeof chunk === "string") {
151
+ chunks.push(Buffer.from(chunk));
152
+ } else {
153
+ chunks.push(chunk);
154
+ }
141
155
  }
142
156
  const buffer = Buffer.concat(chunks);
143
157
  return this.traced(async () => {
@@ -161,3 +175,5 @@ var DeepgramVoice = class extends MastraVoice {
161
175
  };
162
176
 
163
177
  export { DeepgramVoice };
178
+ //# sourceMappingURL=index.js.map
179
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/voices.ts","../src/index.ts"],"names":[],"mappings":";;;;;;;AAKO,IAAM,eAAA,GAAkB;AAAA,EAC7B,Y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gB,IAAA;AAAA,QAC5B,GAAG;AAAA,OACJ,CAAA;AAED,MAAA,IAAI,KAAA,EAAO;AACT,QAAA,MAAM,KAAA;AAAA,MACR;AAEA,MAAA,MAAM,UAAA,GAAa,OAAO,OAAA,EAAS,QAAA,GAAW,CAAC,CAAA,EAAG,YAAA,GAAe,CAAC,CAAA,EAAG,UAAA;AACrE,MAAA,IAAI,CAAC,UAAA,EAAY;AACf,QAAA,MAAM,IAAI,MAAM,0CAA0C,CAAA;AAAA,MAC5D;AAEA,MAAA,OAAO,UAAA;AAAA,IACT,CAAA,EAAG,uBAAuB,CAAA,EAAE;AAAA,EAC9B;AACF","file":"index.js","sourcesContent":["/**\n * List of available Deepgram voice models for text-to-speech\n * Each voice is designed for specific use cases and languages\n * Format: {name}-{language} (e.g. asteria-en)\n */\nexport const DEEPGRAM_VOICES = [\n 'asteria-en',\n 'luna-en',\n 'stella-en',\n 'athena-en',\n 'hera-en',\n 'orion-en',\n 'arcas-en',\n 'perseus-en',\n 'angus-en',\n 'orpheus-en',\n 'helios-en',\n 'zeus-en',\n] as const;\n\nexport type DeepgramVoiceId = (typeof DEEPGRAM_VOICES)[number];\n\n/**\n * List of available Deepgram models for text-to-speech and speech-to-text\n */\nexport const DEEPGRAM_MODELS = ['aura', 'whisper', 'base', 'enhanced', 'nova', 'nova-2', 'nova-3'] as const;\n\nexport type DeepgramModel = (typeof DEEPGRAM_MODELS)[number];\n","import { PassThrough } from 'stream';\n\nimport { createClient } from '@deepgram/sdk';\nimport { MastraVoice } from '@mastra/core/voice';\n\nimport { DEEPGRAM_VOICES } from './voices';\nimport type { DeepgramVoiceId, DeepgramModel } from './voices';\n\ninterface DeepgramVoiceConfig {\n name?: DeepgramModel;\n apiKey?: string;\n properties?: Record<string, any>;\n language?: string;\n}\n\nexport class DeepgramVoice extends MastraVoice {\n private speechClient?: ReturnType<typeof createClient>;\n private listeningClient?: ReturnType<typeof createClient>;\n\n constructor({\n speechModel,\n listeningModel,\n speaker,\n }: { speechModel?: DeepgramVoiceConfig; listeningModel?: DeepgramVoiceConfig; speaker?: DeepgramVoiceId } = {}) {\n const defaultApiKey = process.env.DEEPGRAM_API_KEY;\n\n const defaultSpeechModel = {\n name: 'aura',\n apiKey: defaultApiKey,\n };\n\n const defaultListeningModel = {\n name: 'nova',\n apiKey: defaultApiKey,\n };\n\n super({\n speechModel: {\n name: speechModel?.name ?? defaultSpeechModel.name,\n apiKey: speechModel?.apiKey ?? defaultSpeechModel.apiKey,\n },\n listeningModel: {\n name: listeningModel?.name ?? defaultListeningModel.name,\n apiKey: listeningModel?.apiKey ?? defaultListeningModel.apiKey,\n },\n speaker,\n });\n\n const speechApiKey = speechModel?.apiKey || defaultApiKey;\n const listeningApiKey = listeningModel?.apiKey || defaultApiKey;\n\n if (!speechApiKey && !listeningApiKey) {\n throw new Error('At least one of DEEPGRAM_API_KEY, speechModel.apiKey, or listeningModel.apiKey must be set');\n }\n\n if (speechApiKey) {\n this.speechClient = createClient(speechApiKey);\n }\n if (listeningApiKey) {\n this.listeningClient = createClient(listeningApiKey);\n }\n\n this.speaker = speaker || 'asteria-en';\n }\n\n async getSpeakers() {\n return this.traced(async () => {\n return DEEPGRAM_VOICES.map(voice => ({\n voiceId: voice,\n }));\n }, 'voice.deepgram.getSpeakers')();\n }\n\n async speak(\n input: string | NodeJS.ReadableStream,\n options?: {\n speaker?: string;\n [key: string]: any;\n },\n ): Promise<NodeJS.ReadableStream> {\n if (!this.speechClient) {\n throw new Error('Deepgram speech client not configured');\n }\n\n let text: string;\n if (typeof input !== 'string') {\n const chunks: Buffer[] = [];\n for await (const chunk of input) {\n if (typeof chunk === 'string') {\n chunks.push(Buffer.from(chunk));\n } else {\n chunks.push(chunk);\n }\n }\n text = Buffer.concat(chunks).toString('utf-8');\n } else {\n text = input;\n }\n\n if (text.trim().length === 0) {\n throw new Error('Input text is empty');\n }\n\n return this.traced(async () => {\n if (!this.speechClient) {\n throw new Error('No speech client configured');\n }\n\n let model;\n if (options?.speaker) {\n model = this.speechModel?.name + '-' + options.speaker;\n } else if (this.speaker) {\n model = this.speechModel?.name + '-' + this.speaker;\n }\n\n const speakClient = this.speechClient.speak;\n const response = await speakClient.request(\n { text },\n {\n model,\n ...options,\n },\n );\n\n const webStream = await response.getStream();\n if (!webStream) {\n throw new Error('No stream returned from Deepgram');\n }\n\n const reader = webStream.getReader();\n const nodeStream = new PassThrough();\n\n // Add error handling for the stream processing\n (async () => {\n try {\n while (true) {\n const { done, value } = await reader.read();\n if (done) {\n nodeStream.end();\n break;\n }\n nodeStream.write(value);\n }\n } catch (error) {\n nodeStream.destroy(error as Error);\n }\n })().catch(error => {\n nodeStream.destroy(error as Error);\n });\n\n return nodeStream;\n }, 'voice.deepgram.speak')();\n }\n\n /**\n * Checks if listening capabilities are enabled.\n *\n * @returns {Promise<{ enabled: boolean }>}\n */\n async getListener() {\n return { enabled: true };\n }\n\n async listen(\n audioStream: NodeJS.ReadableStream,\n options?: {\n [key: string]: any;\n },\n ): Promise<string> {\n if (!this.listeningClient) {\n throw new Error('Deepgram listening client not configured');\n }\n\n const chunks: Buffer[] = [];\n for await (const chunk of audioStream) {\n if (typeof chunk === 'string') {\n chunks.push(Buffer.from(chunk));\n } else {\n chunks.push(chunk);\n }\n }\n const buffer = Buffer.concat(chunks);\n\n return this.traced(async () => {\n if (!this.listeningClient) {\n throw new Error('No listening client configured');\n }\n const { result, error } = await this.listeningClient.listen.prerecorded.transcribeFile(buffer, {\n model: this.listeningModel?.name,\n ...options,\n });\n\n if (error) {\n throw error;\n }\n\n const transcript = result.results?.channels?.[0]?.alternatives?.[0]?.transcript;\n if (!transcript) {\n throw new Error('No transcript found in Deepgram response');\n }\n\n return transcript;\n }, 'voice.deepgram.listen')();\n }\n}\n\nexport type { DeepgramVoiceConfig, DeepgramVoiceId, DeepgramModel };\n"]}
@@ -3,26 +3,11 @@
3
3
  * Each voice is designed for specific use cases and languages
4
4
  * Format: {name}-{language} (e.g. asteria-en)
5
5
  */
6
- export const DEEPGRAM_VOICES = [
7
- 'asteria-en',
8
- 'luna-en',
9
- 'stella-en',
10
- 'athena-en',
11
- 'hera-en',
12
- 'orion-en',
13
- 'arcas-en',
14
- 'perseus-en',
15
- 'angus-en',
16
- 'orpheus-en',
17
- 'helios-en',
18
- 'zeus-en',
19
- ] as const;
20
-
6
+ export declare const DEEPGRAM_VOICES: readonly ["asteria-en", "luna-en", "stella-en", "athena-en", "hera-en", "orion-en", "arcas-en", "perseus-en", "angus-en", "orpheus-en", "helios-en", "zeus-en"];
21
7
  export type DeepgramVoiceId = (typeof DEEPGRAM_VOICES)[number];
22
-
23
8
  /**
24
9
  * List of available Deepgram models for text-to-speech and speech-to-text
25
10
  */
26
- export const DEEPGRAM_MODELS = ['aura', 'whisper', 'base', 'enhanced', 'nova', 'nova-2', 'nova-3'] as const;
27
-
11
+ export declare const DEEPGRAM_MODELS: readonly ["aura", "whisper", "base", "enhanced", "nova", "nova-2", "nova-3"];
28
12
  export type DeepgramModel = (typeof DEEPGRAM_MODELS)[number];
13
+ //# sourceMappingURL=voices.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"voices.d.ts","sourceRoot":"","sources":["../src/voices.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,eAAe,iKAalB,CAAC;AAEX,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC;AAE/D;;GAEG;AACH,eAAO,MAAM,eAAe,8EAA+E,CAAC;AAE5G,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,8 +1,12 @@
1
1
  {
2
2
  "name": "@mastra/voice-deepgram",
3
- "version": "0.0.0-storage-20250225005900",
3
+ "version": "0.0.0-stream-vnext-usage-20250908171242",
4
4
  "description": "Mastra Deepgram voice integration",
5
5
  "type": "module",
6
+ "files": [
7
+ "dist",
8
+ "CHANGELOG.md"
9
+ ],
6
10
  "main": "dist/index.js",
7
11
  "types": "dist/index.d.ts",
8
12
  "exports": {
@@ -10,27 +14,45 @@
10
14
  "import": {
11
15
  "types": "./dist/index.d.ts",
12
16
  "default": "./dist/index.js"
17
+ },
18
+ "require": {
19
+ "types": "./dist/index.d.ts",
20
+ "default": "./dist/index.cjs"
13
21
  }
14
22
  },
15
23
  "./package.json": "./package.json"
16
24
  },
25
+ "license": "Apache-2.0",
17
26
  "dependencies": {
18
- "@deepgram/sdk": "^3.9.0",
19
- "zod": "^3.24.1",
20
- "@mastra/core": "^0.0.0-storage-20250225005900"
27
+ "@deepgram/sdk": "^3.13.0"
21
28
  },
22
29
  "devDependencies": {
23
- "@microsoft/api-extractor": "^7.49.2",
24
- "@types/node": "^22.13.1",
25
- "tsup": "^8.3.6",
26
- "typescript": "^5.7.3",
27
- "vitest": "^2.1.8",
28
- "eslint": "^9.20.1",
29
- "@internal/lint": "0.0.0"
30
+ "@microsoft/api-extractor": "^7.52.8",
31
+ "@types/node": "^20.19.0",
32
+ "eslint": "^9.30.1",
33
+ "tsup": "^8.5.0",
34
+ "typescript": "^5.8.3",
35
+ "vitest": "^3.2.4",
36
+ "@internal/lint": "0.0.0-stream-vnext-usage-20250908171242",
37
+ "@mastra/core": "0.0.0-stream-vnext-usage-20250908171242",
38
+ "@internal/types-builder": "0.0.0-stream-vnext-usage-20250908171242"
39
+ },
40
+ "peerDependencies": {
41
+ "zod": "^3.25.0 || ^4.0.0",
42
+ "@mastra/core": "0.0.0-stream-vnext-usage-20250908171242"
43
+ },
44
+ "homepage": "https://mastra.ai",
45
+ "repository": {
46
+ "type": "git",
47
+ "url": "git+https://github.com/mastra-ai/mastra.git",
48
+ "directory": "voice/deepgram"
49
+ },
50
+ "bugs": {
51
+ "url": "https://github.com/mastra-ai/mastra/issues"
30
52
  },
31
53
  "scripts": {
32
- "build": "tsup src/index.ts --format esm --experimental-dts --clean --treeshake",
33
- "build:watch": "pnpm build --watch",
54
+ "build": "tsup --silent --config tsup.config.ts",
55
+ "build:watch": "tsup --watch --silent --config tsup.config.ts",
34
56
  "test": "vitest run",
35
57
  "lint": "eslint ."
36
58
  }
@@ -1,19 +0,0 @@
1
-
2
- 
3
- > @mastra/voice-deepgram@0.1.0-alpha.2 build /Users/ward/projects/mastra/mastra/voice/deepgram
4
- > tsup src/index.ts --format esm --experimental-dts --clean --treeshake
5
-
6
- CLI Building entry: src/index.ts
7
- CLI Using tsconfig: tsconfig.json
8
- CLI tsup v8.3.6
9
- TSC Build start
10
- TSC ⚡️ Build success in 2750ms
11
- DTS Build start
12
- CLI Target: es2022
13
- Analysis will use the bundled TypeScript version 5.7.3
14
- Writing package typings: /Users/ward/projects/mastra/mastra/voice/deepgram/dist/_tsup-dts-rollup.d.ts
15
- DTS ⚡️ Build success in 1597ms
16
- CLI Cleaning output folder
17
- ESM Build start
18
- ESM dist/index.js 4.50 KB
19
- ESM ⚡️ Build success in 115ms
package/LICENSE DELETED
@@ -1,44 +0,0 @@
1
- Elastic License 2.0 (ELv2)
2
-
3
- **Acceptance**
4
- By using the software, you agree to all of the terms and conditions below.
5
-
6
- **Copyright License**
7
- The licensor grants you a non-exclusive, royalty-free, worldwide, non-sublicensable, non-transferable license to use, copy, distribute, make available, and prepare derivative works of the software, in each case subject to the limitations and conditions below
8
-
9
- **Limitations**
10
- You may not provide the software to third parties as a hosted or managed service, where the service provides users with access to any substantial set of the features or functionality of the software.
11
-
12
- You may not move, change, disable, or circumvent the license key functionality in the software, and you may not remove or obscure any functionality in the software that is protected by the license key.
13
-
14
- You may not alter, remove, or obscure any licensing, copyright, or other notices of the licensor in the software. Any use of the licensor’s trademarks is subject to applicable law.
15
-
16
- **Patents**
17
- The licensor grants you a license, under any patent claims the licensor can license, or becomes able to license, to make, have made, use, sell, offer for sale, import and have imported the software, in each case subject to the limitations and conditions in this license. This license does not cover any patent claims that you cause to be infringed by modifications or additions to the software. If you or your company make any written claim that the software infringes or contributes to infringement of any patent, your patent license for the software granted under these terms ends immediately. If your company makes such a claim, your patent license ends immediately for work on behalf of your company.
18
-
19
- **Notices**
20
- You must ensure that anyone who gets a copy of any part of the software from you also gets a copy of these terms.
21
-
22
- If you modify the software, you must include in any modified copies of the software prominent notices stating that you have modified the software.
23
-
24
- **No Other Rights**
25
- These terms do not imply any licenses other than those expressly granted in these terms.
26
-
27
- **Termination**
28
- If you use the software in violation of these terms, such use is not licensed, and your licenses will automatically terminate. If the licensor provides you with a notice of your violation, and you cease all violation of this license no later than 30 days after you receive that notice, your licenses will be reinstated retroactively. However, if you violate these terms after such reinstatement, any additional violation of these terms will cause your licenses to terminate automatically and permanently.
29
-
30
- **No Liability**
31
- As far as the law allows, the software comes as is, without any warranty or condition, and the licensor will not be liable to you for any damages arising out of these terms or the use or nature of the software, under any kind of legal claim.
32
-
33
- **Definitions**
34
- The _licensor_ is the entity offering these terms, and the _software_ is the software the licensor makes available under these terms, including any portion of it.
35
-
36
- _you_ refers to the individual or entity agreeing to these terms.
37
-
38
- _your company_ is any legal entity, sole proprietorship, or other kind of organization that you work for, plus all organizations that have control over, are under the control of, or are under common control with that organization. _control_ means ownership of substantially all the assets of an entity, or the power to direct its management and policies by vote, contract, or otherwise. Control can be direct or indirect.
39
-
40
- _your licenses_ are all the licenses granted to you for the software under these terms.
41
-
42
- _use_ means anything you do with the software requiring one of your licenses.
43
-
44
- _trademark_ means trademarks, service marks, and similar rights.
Binary file
@@ -1,50 +0,0 @@
1
- import { MastraVoice } from '@mastra/core/voice';
2
-
3
- /**
4
- * List of available Deepgram models for text-to-speech and speech-to-text
5
- */
6
- export declare const DEEPGRAM_MODELS: readonly ["aura", "whisper", "base", "enhanced", "nova", "nova-2", "nova-3"];
7
-
8
- /**
9
- * List of available Deepgram voice models for text-to-speech
10
- * Each voice is designed for specific use cases and languages
11
- * Format: {name}-{language} (e.g. asteria-en)
12
- */
13
- export declare const DEEPGRAM_VOICES: readonly ["asteria-en", "luna-en", "stella-en", "athena-en", "hera-en", "orion-en", "arcas-en", "perseus-en", "angus-en", "orpheus-en", "helios-en", "zeus-en"];
14
-
15
- declare type DeepgramModel = (typeof DEEPGRAM_MODELS)[number];
16
- export { DeepgramModel }
17
- export { DeepgramModel as DeepgramModel_alias_1 }
18
-
19
- export declare class DeepgramVoice extends MastraVoice {
20
- private speechClient?;
21
- private listeningClient?;
22
- constructor({ speechModel, listeningModel, speaker, }?: {
23
- speechModel?: DeepgramVoiceConfig;
24
- listeningModel?: DeepgramVoiceConfig;
25
- speaker?: DeepgramVoiceId;
26
- });
27
- getSpeakers(): Promise<{
28
- voiceId: "asteria-en" | "luna-en" | "stella-en" | "athena-en" | "hera-en" | "orion-en" | "arcas-en" | "perseus-en" | "angus-en" | "orpheus-en" | "helios-en" | "zeus-en";
29
- }[]>;
30
- speak(input: string | NodeJS.ReadableStream, options?: {
31
- speaker?: string;
32
- [key: string]: any;
33
- }): Promise<NodeJS.ReadableStream>;
34
- listen(audioStream: NodeJS.ReadableStream, options?: {
35
- [key: string]: any;
36
- }): Promise<string>;
37
- }
38
-
39
- export declare interface DeepgramVoiceConfig {
40
- name?: DeepgramModel;
41
- apiKey?: string;
42
- properties?: Record<string, any>;
43
- language?: string;
44
- }
45
-
46
- declare type DeepgramVoiceId = (typeof DEEPGRAM_VOICES)[number];
47
- export { DeepgramVoiceId }
48
- export { DeepgramVoiceId as DeepgramVoiceId_alias_1 }
49
-
50
- export { }
package/eslint.config.js DELETED
@@ -1,6 +0,0 @@
1
- import { createConfig } from '@internal/lint/eslint';
2
-
3
- const config = await createConfig();
4
-
5
- /** @type {import("eslint").Linter.Config[]} */
6
- export default [...config];