@mastra/voice-deepgram 0.10.6-alpha.0 → 0.10.7-alpha.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/index.cjs CHANGED
@@ -177,3 +177,5 @@ var DeepgramVoice = class extends voice.MastraVoice {
177
177
  };
178
178
 
179
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","PassThrough"],"mappings":";;;;;;;;;AAKO,IAAM,eAAA,GAAkB;AAAA,EAC7B,YAAA;AAAA,EACA,SAAA;AAAA,EACA,WAAA;AAAA,EACA,WAAA;AAAA,EACA,SAAA;AAAA,EACA,UAAA;AAAA,EACA,UAAA;AAAA,EACA,YAAA;AAAA,EACA,UAAA;AAAA,EACA,YAAA;AAAA,EACA,WAAA;AAAA,EACA;AACF,CAAA;;;ACHO,IAAM,aAAA,GAAN,cAA4BA,iBAAA,CAAY;AAAA,EACrC,YAAA;AAAA,EACA,eAAA;AAAA,EAER,WAAA,CAAY;AAAA,IACV,WAAA;AAAA,IACA,cAAA;AAAA,IACA;AAAA,GACF,GAA4G,EAAC,EAAG;AAC9G,IAAA,MAAM,aAAA,GAAgB,QAAQ,GAAA,CAAI,gBAAA;AAElC,IAAA,MAAM,kBAAA,GAAqB;AAAA,MACzB,IAAA,EAAM,MAAA;AAAA,MACN,MAAA,EAAQ;AAAA,KACV;AAEA,IAAA,MAAM,qBAAA,GAAwB;AAAA,MAC5B,IAAA,EAAM,MAAA;AAAA,MACN,MAAA,EAAQ;AAAA,KACV;AAEA,IAAA,KAAA,CAAM;AAAA,MACJ,WAAA,EAAa;AAAA,QACX,IAAA,EAAM,WAAA,EAAa,IAAA,IAAQ,kBAAA,CAAmB,IAAA;AAAA,QAC9C,MAAA,EAAQ,WAAA,EAAa,MAAA,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,MAAO;AACL,QAAA,MAAA,CAAO,KAAK,KAAK,CAAA;AAAA,MACnB;AAAA,IACF;AACA,IAAA,MAAM,MAAA,GAAS,MAAA,CAAO,MAAA,CAAO,MAAM,CAAA;AAEnC,IAAA,OAAO,IAAA,CAAK,OAAO,YAAY;AAC7B,MAAA,IAAI,CAAC,KAAK,eAAA,EAAiB;AACzB,QAAA,MAAM,IAAI,MAAM,gCAAgC,CAAA;AAAA,MAClD;AACA,MAAA,MAAM,EAAE,MAAA,EAAQ,KAAA,EAAM,GAAI,MAAM,KAAK,eAAA,CAAgB,MAAA,CAAO,WAAA,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
@@ -175,3 +175,5 @@ var DeepgramVoice = class extends MastraVoice {
175
175
  };
176
176
 
177
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,YAAA;AAAA,EACA,SAAA;AAAA,EACA,WAAA;AAAA,EACA,WAAA;AAAA,EACA,SAAA;AAAA,EACA,UAAA;AAAA,EACA,UAAA;AAAA,EACA,YAAA;AAAA,EACA,UAAA;AAAA,EACA,YAAA;AAAA,EACA,WAAA;AAAA,EACA;AACF,CAAA;;;ACHO,IAAM,aAAA,GAAN,cAA4B,WAAA,CAAY;AAAA,EACrC,YAAA;AAAA,EACA,eAAA;AAAA,EAER,WAAA,CAAY;AAAA,IACV,WAAA;AAAA,IACA,cAAA;AAAA,IACA;AAAA,GACF,GAA4G,EAAC,EAAG;AAC9G,IAAA,MAAM,aAAA,GAAgB,QAAQ,GAAA,CAAI,gBAAA;AAElC,IAAA,MAAM,kBAAA,GAAqB;AAAA,MACzB,IAAA,EAAM,MAAA;AAAA,MACN,MAAA,EAAQ;AAAA,KACV;AAEA,IAAA,MAAM,qBAAA,GAAwB;AAAA,MAC5B,IAAA,EAAM,MAAA;AAAA,MACN,MAAA,EAAQ;AAAA,KACV;AAEA,IAAA,KAAA,CAAM;AAAA,MACJ,WAAA,EAAa;AAAA,QACX,IAAA,EAAM,WAAA,EAAa,IAAA,IAAQ,kBAAA,CAAmB,IAAA;AAAA,QAC9C,MAAA,EAAQ,WAAA,EAAa,MAAA,IAAU,kBAAA,CAAmB;AAAA,OACpD;AAAA,MACA,cA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,MACnB;AAAA,IACF;AACA,IAAA,MAAM,MAAA,GAAS,MAAA,CAAO,MAAA,CAAO,MAAM,CAAA;AAEnC,IAAA,OAAO,IAAA,CAAK,OAAO,YAAY;AAC7B,MAAA,IAAI,CAAC,KAAK,eAAA,EAAiB;AACzB,QAAA,MAAM,IAAI,MAAM,gCAAgC,CAAA;AAAA,MAClD;AACA,MAAA,MAAM,EAAE,MAAA,EAAQ,KAAA,EAAM,GAAI,MAAM,KAAK,eAAA,CAAgB,MAAA,CAAO,WAAA,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.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"]}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * List of available Deepgram voice models for text-to-speech
3
+ * Each voice is designed for specific use cases and languages
4
+ * Format: {name}-{language} (e.g. asteria-en)
5
+ */
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"];
7
+ export type DeepgramVoiceId = (typeof DEEPGRAM_VOICES)[number];
8
+ /**
9
+ * List of available Deepgram models for text-to-speech and speech-to-text
10
+ */
11
+ export declare const DEEPGRAM_MODELS: readonly ["aura", "whisper", "base", "enhanced", "nova", "nova-2", "nova-3"];
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,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/voice-deepgram",
3
- "version": "0.10.6-alpha.0",
3
+ "version": "0.10.7-alpha.0",
4
4
  "description": "Mastra Deepgram voice integration",
5
5
  "type": "module",
6
6
  "files": [
@@ -15,7 +15,7 @@
15
15
  "default": "./dist/index.js"
16
16
  },
17
17
  "require": {
18
- "types": "./dist/index.d.cts",
18
+ "types": "./dist/index.d.ts",
19
19
  "default": "./dist/index.cjs"
20
20
  }
21
21
  },
@@ -33,15 +33,16 @@
33
33
  "tsup": "^8.5.0",
34
34
  "typescript": "^5.8.3",
35
35
  "vitest": "^3.2.4",
36
- "@internal/lint": "0.0.23",
37
- "@mastra/core": "0.12.0-alpha.5"
36
+ "@internal/lint": "0.0.26",
37
+ "@internal/types-builder": "0.0.1",
38
+ "@mastra/core": "0.13.0-alpha.2"
38
39
  },
39
40
  "peerDependencies": {
40
- "@mastra/core": ">=0.10.7-0 <0.13.0-0"
41
+ "@mastra/core": ">=0.10.7-0 <0.14.0-0"
41
42
  },
42
43
  "scripts": {
43
- "build": "tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake=smallest --splitting",
44
- "build:watch": "pnpm build --watch",
44
+ "build": "tsup --silent --config tsup.config.ts",
45
+ "build:watch": "tsup --watch --silent --config tsup.config.ts",
45
46
  "test": "vitest run",
46
47
  "lint": "eslint ."
47
48
  }
@@ -1,58 +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
- /**
35
- * Checks if listening capabilities are enabled.
36
- *
37
- * @returns {Promise<{ enabled: boolean }>}
38
- */
39
- getListener(): Promise<{
40
- enabled: boolean;
41
- }>;
42
- listen(audioStream: NodeJS.ReadableStream, options?: {
43
- [key: string]: any;
44
- }): Promise<string>;
45
- }
46
-
47
- export declare interface DeepgramVoiceConfig {
48
- name?: DeepgramModel;
49
- apiKey?: string;
50
- properties?: Record<string, any>;
51
- language?: string;
52
- }
53
-
54
- declare type DeepgramVoiceId = (typeof DEEPGRAM_VOICES)[number];
55
- export { DeepgramVoiceId }
56
- export { DeepgramVoiceId as DeepgramVoiceId_alias_1 }
57
-
58
- export { }
@@ -1,58 +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
- /**
35
- * Checks if listening capabilities are enabled.
36
- *
37
- * @returns {Promise<{ enabled: boolean }>}
38
- */
39
- getListener(): Promise<{
40
- enabled: boolean;
41
- }>;
42
- listen(audioStream: NodeJS.ReadableStream, options?: {
43
- [key: string]: any;
44
- }): Promise<string>;
45
- }
46
-
47
- export declare interface DeepgramVoiceConfig {
48
- name?: DeepgramModel;
49
- apiKey?: string;
50
- properties?: Record<string, any>;
51
- language?: string;
52
- }
53
-
54
- declare type DeepgramVoiceId = (typeof DEEPGRAM_VOICES)[number];
55
- export { DeepgramVoiceId }
56
- export { DeepgramVoiceId as DeepgramVoiceId_alias_1 }
57
-
58
- export { }
package/dist/index.d.cts DELETED
@@ -1,4 +0,0 @@
1
- export { DeepgramVoice } from './_tsup-dts-rollup.cjs';
2
- export { DeepgramVoiceConfig } from './_tsup-dts-rollup.cjs';
3
- export { DeepgramVoiceId } from './_tsup-dts-rollup.cjs';
4
- export { DeepgramModel } from './_tsup-dts-rollup.cjs';