@mastra/voice-murf 0.0.0-storage-20250225005900 → 0.0.0-vnextWorkflows-20250417075051

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.
@@ -1,4 +1,6 @@
1
- Elastic License 2.0 (ELv2)
1
+ # Elastic License 2.0 (ELv2)
2
+
3
+ Copyright (c) 2025 Mastra AI, Inc.
2
4
 
3
5
  **Acceptance**
4
6
  By using the software, you agree to all of the terms and conditions below.
@@ -0,0 +1,57 @@
1
+ import { MastraVoice } from '@mastra/core/voice';
2
+
3
+ /**
4
+ * List of available voices for Murf TTS
5
+ */
6
+ export declare const MURF_VOICES: readonly ["en-UK-hazel", "en-US-cooper", "en-US-imani", "it-IT-giorgio", "en-US-wayne", "en-IN-shivani", "en-US-daniel", "bn-IN-anwesha", "es-MX-alejandro", "en-AU-joyce", "en-US-zion", "en-IN-isha", "en-US-riley", "ko-KR-hwan", "fr-FR-adélie", "en-US-carter", "en-UK-gabriel", "en-UK-juliet", "en-IN-arohi", "fr-FR-maxime", "de-DE-josephine", "en-UK-hugo", "en-US-samantha", "de-DE-erna", "zh-CN-baolin", "pt-BR-isadora", "it-IT-vincenzo", "en-US-terrell", "en-US-denzel", "en-UK-heidi", "en-US-miles", "en-US-abigail", "fr-FR-justine", "it-IT-greta", "en-AU-shane", "en-UK-peter", "nl-NL-famke", "en-AU-ivy", "nl-NL-dirk", "fr-FR-axel", "es-ES-carla", "en-US-claire", "ko-KR-jangmi", "ko-KR-sanghoon", "it-IT-vera", "hi-IN-rahul", "es-ES-elvira", "es-ES-enrique", "en-UK-aiden", "en-US-ronnie", "en-UK-amber", "hi-IN-shweta", "hi-IN-amit", "en-AU-jimm", "en-UK-pearl", "pt-BR-benício", "en-UK-freddie", "en-US-ryan", "pt-BR-eloa", "en-US-charlotte", "de-DE-lia", "en-US-natalie", "en-US-michelle", "en-US-phoebe", "es-ES-carmen", "en-US-caleb", "en-US-iris", "en-UK-harrison", "en-US-marcus", "en-US-josie", "en-US-daisy", "en-US-charles", "en-UK-reggie", "en-US-julia", "en-SCOTT-emily", "en-US-dylan", "es-MX-valeria", "en-IN-eashwar", "en-AU-evelyn", "de-DE-lara", "en-US-evander", "en-SCOTT-rory", "ta-IN-iniya", "en-AU-leyton", "fr-FR-louise", "zh-CN-wei", "ko-KR-gyeong", "de-DE-matthias", "en-IN-rohan", "en-US-delilah", "bn-IN-abhik", "en-US-angela", "en-US-naomi", "es-MX-carlos", "nl-NL-merel", "en-US-alicia", "en-IN-alia", "zh-CN-jiao", "en-US-june", "en-AU-ashton", "en-UK-finley", "pl-PL-blazej", "zh-CN-zhang", "en-AU-kylie", "en-US-jayden", "en-IN-aarav", "de-DE-björn", "bn-IN-ishani", "zh-CN-yuxan", "fr-FR-louis", "ko-KR-jong-su", "en-AU-harper", "en-UK-ruby", "en-US-ken", "ta-IN-mani", "de-DE-ralf", "en-UK-jaxon", "en-US-river", "en-IN-priya", "en-UK-theo", "en-UK-katie", "pl-PL-jacek", "it-IT-lorenzo", "hi-IN-shaan", "en-US-amara", "en-UK-mason", "en-IN-surya", "en-US-finn", "pt-BR-gustavo", "hi-IN-kabir", "es-ES-javier", "en-AU-mitch", "pt-BR-heitor", "en-US-edmund", "hi-IN-ayushi", "pl-PL-kasia", "es-MX-luisa", "zh-CN-tao", "en-US-molly"];
7
+
8
+ export declare type MurfConfig = {
9
+ name: 'GEN1' | 'GEN2';
10
+ apiKey?: string;
11
+ properties?: Omit<SpeechCreateParams, 'modelVersion' | 'voiceId' | 'text'>;
12
+ };
13
+
14
+ export declare class MurfVoice extends MastraVoice {
15
+ private client;
16
+ private defaultVoice;
17
+ private properties;
18
+ constructor({ speechModel, speaker }?: {
19
+ speechModel?: MurfConfig;
20
+ speaker?: string;
21
+ });
22
+ private streamToString;
23
+ speak(input: string | NodeJS.ReadableStream, options?: {
24
+ speaker?: string;
25
+ properties?: Omit<SpeechCreateParams, 'modelVersion' | 'voiceId' | 'text'>;
26
+ }): Promise<NodeJS.ReadableStream>;
27
+ listen(_input: NodeJS.ReadableStream, _options?: Record<string, unknown>): Promise<string | NodeJS.ReadableStream>;
28
+ getSpeakers(): Promise<{
29
+ voiceId: "en-UK-hazel" | "en-US-cooper" | "en-US-imani" | "it-IT-giorgio" | "en-US-wayne" | "en-IN-shivani" | "en-US-daniel" | "bn-IN-anwesha" | "es-MX-alejandro" | "en-AU-joyce" | "en-US-zion" | "en-IN-isha" | "en-US-riley" | "ko-KR-hwan" | "fr-FR-adélie" | "en-US-carter" | "en-UK-gabriel" | "en-UK-juliet" | "en-IN-arohi" | "fr-FR-maxime" | "de-DE-josephine" | "en-UK-hugo" | "en-US-samantha" | "de-DE-erna" | "zh-CN-baolin" | "pt-BR-isadora" | "it-IT-vincenzo" | "en-US-terrell" | "en-US-denzel" | "en-UK-heidi" | "en-US-miles" | "en-US-abigail" | "fr-FR-justine" | "it-IT-greta" | "en-AU-shane" | "en-UK-peter" | "nl-NL-famke" | "en-AU-ivy" | "nl-NL-dirk" | "fr-FR-axel" | "es-ES-carla" | "en-US-claire" | "ko-KR-jangmi" | "ko-KR-sanghoon" | "it-IT-vera" | "hi-IN-rahul" | "es-ES-elvira" | "es-ES-enrique" | "en-UK-aiden" | "en-US-ronnie" | "en-UK-amber" | "hi-IN-shweta" | "hi-IN-amit" | "en-AU-jimm" | "en-UK-pearl" | "pt-BR-benício" | "en-UK-freddie" | "en-US-ryan" | "pt-BR-eloa" | "en-US-charlotte" | "de-DE-lia" | "en-US-natalie" | "en-US-michelle" | "en-US-phoebe" | "es-ES-carmen" | "en-US-caleb" | "en-US-iris" | "en-UK-harrison" | "en-US-marcus" | "en-US-josie" | "en-US-daisy" | "en-US-charles" | "en-UK-reggie" | "en-US-julia" | "en-SCOTT-emily" | "en-US-dylan" | "es-MX-valeria" | "en-IN-eashwar" | "en-AU-evelyn" | "de-DE-lara" | "en-US-evander" | "en-SCOTT-rory" | "ta-IN-iniya" | "en-AU-leyton" | "fr-FR-louise" | "zh-CN-wei" | "ko-KR-gyeong" | "de-DE-matthias" | "en-IN-rohan" | "en-US-delilah" | "bn-IN-abhik" | "en-US-angela" | "en-US-naomi" | "es-MX-carlos" | "nl-NL-merel" | "en-US-alicia" | "en-IN-alia" | "zh-CN-jiao" | "en-US-june" | "en-AU-ashton" | "en-UK-finley" | "pl-PL-blazej" | "zh-CN-zhang" | "en-AU-kylie" | "en-US-jayden" | "en-IN-aarav" | "de-DE-björn" | "bn-IN-ishani" | "zh-CN-yuxan" | "fr-FR-louis" | "ko-KR-jong-su" | "en-AU-harper" | "en-UK-ruby" | "en-US-ken" | "ta-IN-mani" | "de-DE-ralf" | "en-UK-jaxon" | "en-US-river" | "en-IN-priya" | "en-UK-theo" | "en-UK-katie" | "pl-PL-jacek" | "it-IT-lorenzo" | "hi-IN-shaan" | "en-US-amara" | "en-UK-mason" | "en-IN-surya" | "en-US-finn" | "pt-BR-gustavo" | "hi-IN-kabir" | "es-ES-javier" | "en-AU-mitch" | "pt-BR-heitor" | "en-US-edmund" | "hi-IN-ayushi" | "pl-PL-kasia" | "es-MX-luisa" | "zh-CN-tao" | "en-US-molly";
30
+ name: "en-UK-hazel" | "en-US-cooper" | "en-US-imani" | "it-IT-giorgio" | "en-US-wayne" | "en-IN-shivani" | "en-US-daniel" | "bn-IN-anwesha" | "es-MX-alejandro" | "en-AU-joyce" | "en-US-zion" | "en-IN-isha" | "en-US-riley" | "ko-KR-hwan" | "fr-FR-adélie" | "en-US-carter" | "en-UK-gabriel" | "en-UK-juliet" | "en-IN-arohi" | "fr-FR-maxime" | "de-DE-josephine" | "en-UK-hugo" | "en-US-samantha" | "de-DE-erna" | "zh-CN-baolin" | "pt-BR-isadora" | "it-IT-vincenzo" | "en-US-terrell" | "en-US-denzel" | "en-UK-heidi" | "en-US-miles" | "en-US-abigail" | "fr-FR-justine" | "it-IT-greta" | "en-AU-shane" | "en-UK-peter" | "nl-NL-famke" | "en-AU-ivy" | "nl-NL-dirk" | "fr-FR-axel" | "es-ES-carla" | "en-US-claire" | "ko-KR-jangmi" | "ko-KR-sanghoon" | "it-IT-vera" | "hi-IN-rahul" | "es-ES-elvira" | "es-ES-enrique" | "en-UK-aiden" | "en-US-ronnie" | "en-UK-amber" | "hi-IN-shweta" | "hi-IN-amit" | "en-AU-jimm" | "en-UK-pearl" | "pt-BR-benício" | "en-UK-freddie" | "en-US-ryan" | "pt-BR-eloa" | "en-US-charlotte" | "de-DE-lia" | "en-US-natalie" | "en-US-michelle" | "en-US-phoebe" | "es-ES-carmen" | "en-US-caleb" | "en-US-iris" | "en-UK-harrison" | "en-US-marcus" | "en-US-josie" | "en-US-daisy" | "en-US-charles" | "en-UK-reggie" | "en-US-julia" | "en-SCOTT-emily" | "en-US-dylan" | "es-MX-valeria" | "en-IN-eashwar" | "en-AU-evelyn" | "de-DE-lara" | "en-US-evander" | "en-SCOTT-rory" | "ta-IN-iniya" | "en-AU-leyton" | "fr-FR-louise" | "zh-CN-wei" | "ko-KR-gyeong" | "de-DE-matthias" | "en-IN-rohan" | "en-US-delilah" | "bn-IN-abhik" | "en-US-angela" | "en-US-naomi" | "es-MX-carlos" | "nl-NL-merel" | "en-US-alicia" | "en-IN-alia" | "zh-CN-jiao" | "en-US-june" | "en-AU-ashton" | "en-UK-finley" | "pl-PL-blazej" | "zh-CN-zhang" | "en-AU-kylie" | "en-US-jayden" | "en-IN-aarav" | "de-DE-björn" | "bn-IN-ishani" | "zh-CN-yuxan" | "fr-FR-louis" | "ko-KR-jong-su" | "en-AU-harper" | "en-UK-ruby" | "en-US-ken" | "ta-IN-mani" | "de-DE-ralf" | "en-UK-jaxon" | "en-US-river" | "en-IN-priya" | "en-UK-theo" | "en-UK-katie" | "pl-PL-jacek" | "it-IT-lorenzo" | "hi-IN-shaan" | "en-US-amara" | "en-UK-mason" | "en-IN-surya" | "en-US-finn" | "pt-BR-gustavo" | "hi-IN-kabir" | "es-ES-javier" | "en-AU-mitch" | "pt-BR-heitor" | "en-US-edmund" | "hi-IN-ayushi" | "pl-PL-kasia" | "es-MX-luisa" | "zh-CN-tao" | "en-US-molly";
31
+ language: string | undefined;
32
+ gender: string;
33
+ }[]>;
34
+ }
35
+
36
+ declare type MurfVoiceId = (typeof MURF_VOICES)[number];
37
+ export { MurfVoiceId }
38
+ export { MurfVoiceId as MurfVoiceId_alias_1 }
39
+
40
+ declare type SpeechCreateParams = {
41
+ voiceId: MurfVoiceId;
42
+ text: string;
43
+ modelVersion: 'GEN1' | 'GEN2';
44
+ style?: string;
45
+ rate?: number;
46
+ pitch?: number;
47
+ sampleRate?: 8000 | 24000 | 44100 | 48000;
48
+ format?: 'MP3' | 'WAV' | 'FLAC' | 'ALAW' | 'ULAW';
49
+ channelType?: 'STEREO' | 'MONO';
50
+ pronunciationDictionary?: Record<string, string>;
51
+ encodeAsBase64?: boolean;
52
+ variation?: number;
53
+ audioDuration?: number;
54
+ multiNativeLocale?: string;
55
+ };
56
+
57
+ export { }
package/dist/index.cjs ADDED
@@ -0,0 +1,247 @@
1
+ 'use strict';
2
+
3
+ var stream = require('stream');
4
+ var voice = require('@mastra/core/voice');
5
+ var ky = require('ky');
6
+
7
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
8
+
9
+ var ky__default = /*#__PURE__*/_interopDefault(ky);
10
+
11
+ // src/index.ts
12
+
13
+ // src/voices.ts
14
+ var MURF_VOICES = [
15
+ "en-UK-hazel",
16
+ "en-US-cooper",
17
+ "en-US-imani",
18
+ "it-IT-giorgio",
19
+ "en-US-wayne",
20
+ "en-IN-shivani",
21
+ "en-US-daniel",
22
+ "bn-IN-anwesha",
23
+ "es-MX-alejandro",
24
+ "en-AU-joyce",
25
+ "en-US-zion",
26
+ "en-IN-isha",
27
+ "en-US-riley",
28
+ "ko-KR-hwan",
29
+ "fr-FR-ad\xE9lie",
30
+ "en-US-carter",
31
+ "en-UK-gabriel",
32
+ "en-UK-juliet",
33
+ "en-IN-arohi",
34
+ "fr-FR-maxime",
35
+ "de-DE-josephine",
36
+ "en-UK-hugo",
37
+ "en-US-samantha",
38
+ "de-DE-erna",
39
+ "zh-CN-baolin",
40
+ "pt-BR-isadora",
41
+ "it-IT-vincenzo",
42
+ "en-US-terrell",
43
+ "en-US-denzel",
44
+ "en-UK-heidi",
45
+ "en-US-miles",
46
+ "en-US-abigail",
47
+ "fr-FR-justine",
48
+ "it-IT-greta",
49
+ "en-AU-shane",
50
+ "en-UK-peter",
51
+ "nl-NL-famke",
52
+ "en-AU-ivy",
53
+ "nl-NL-dirk",
54
+ "fr-FR-axel",
55
+ "es-ES-carla",
56
+ "en-US-claire",
57
+ "ko-KR-jangmi",
58
+ "ko-KR-sanghoon",
59
+ "it-IT-vera",
60
+ "hi-IN-rahul",
61
+ "es-ES-elvira",
62
+ "es-ES-enrique",
63
+ "en-UK-aiden",
64
+ "en-US-ronnie",
65
+ "en-UK-amber",
66
+ "hi-IN-shweta",
67
+ "hi-IN-amit",
68
+ "en-AU-jimm",
69
+ "en-UK-pearl",
70
+ "pt-BR-ben\xEDcio",
71
+ "en-UK-freddie",
72
+ "en-US-ryan",
73
+ "pt-BR-eloa",
74
+ "en-US-charlotte",
75
+ "de-DE-lia",
76
+ "en-US-natalie",
77
+ "en-US-michelle",
78
+ "en-US-phoebe",
79
+ "es-ES-carmen",
80
+ "en-US-caleb",
81
+ "en-US-iris",
82
+ "en-UK-harrison",
83
+ "en-US-marcus",
84
+ "en-US-josie",
85
+ "en-US-daisy",
86
+ "en-US-charles",
87
+ "en-UK-reggie",
88
+ "en-US-julia",
89
+ "en-SCOTT-emily",
90
+ "en-US-dylan",
91
+ "es-MX-valeria",
92
+ "en-IN-eashwar",
93
+ "en-AU-evelyn",
94
+ "de-DE-lara",
95
+ "en-US-evander",
96
+ "en-SCOTT-rory",
97
+ "ta-IN-iniya",
98
+ "en-AU-leyton",
99
+ "fr-FR-louise",
100
+ "zh-CN-wei",
101
+ "ko-KR-gyeong",
102
+ "de-DE-matthias",
103
+ "en-IN-rohan",
104
+ "en-US-delilah",
105
+ "bn-IN-abhik",
106
+ "en-US-angela",
107
+ "en-US-naomi",
108
+ "es-MX-carlos",
109
+ "nl-NL-merel",
110
+ "en-US-alicia",
111
+ "en-IN-alia",
112
+ "zh-CN-jiao",
113
+ "en-US-june",
114
+ "en-AU-ashton",
115
+ "en-UK-finley",
116
+ "pl-PL-blazej",
117
+ "zh-CN-zhang",
118
+ "en-AU-kylie",
119
+ "en-US-jayden",
120
+ "en-IN-aarav",
121
+ "de-DE-bj\xF6rn",
122
+ "bn-IN-ishani",
123
+ "zh-CN-yuxan",
124
+ "fr-FR-louis",
125
+ "ko-KR-jong-su",
126
+ "en-AU-harper",
127
+ "en-UK-ruby",
128
+ "en-US-ken",
129
+ "ta-IN-mani",
130
+ "de-DE-ralf",
131
+ "en-UK-jaxon",
132
+ "en-US-river",
133
+ "en-IN-priya",
134
+ "en-UK-theo",
135
+ "en-UK-katie",
136
+ "pl-PL-jacek",
137
+ "it-IT-lorenzo",
138
+ "hi-IN-shaan",
139
+ "en-US-amara",
140
+ "en-UK-mason",
141
+ "en-IN-surya",
142
+ "en-US-finn",
143
+ "pt-BR-gustavo",
144
+ "hi-IN-kabir",
145
+ "es-ES-javier",
146
+ "en-AU-mitch",
147
+ "pt-BR-heitor",
148
+ "en-US-edmund",
149
+ "hi-IN-ayushi",
150
+ "pl-PL-kasia",
151
+ "es-MX-luisa",
152
+ "zh-CN-tao",
153
+ "en-US-molly"
154
+ ];
155
+
156
+ // src/index.ts
157
+ var MurfVoice = class extends voice.MastraVoice {
158
+ client;
159
+ defaultVoice;
160
+ properties;
161
+ constructor({ speechModel, speaker } = {}) {
162
+ super({
163
+ speechModel: {
164
+ name: speechModel?.name ?? "GEN2",
165
+ apiKey: speechModel?.apiKey ?? process.env.MURF_API_KEY
166
+ },
167
+ speaker: speaker ?? MURF_VOICES[0]
168
+ });
169
+ const apiKey = this.speechModel?.apiKey;
170
+ if (!apiKey) {
171
+ throw new Error("MURF_API_KEY is not set");
172
+ }
173
+ this.properties = {
174
+ ...speechModel?.properties
175
+ };
176
+ this.client = ky__default.default.create({
177
+ prefixUrl: "https://api.murf.ai",
178
+ headers: {
179
+ "api-key": apiKey
180
+ }
181
+ });
182
+ this.defaultVoice = speaker ?? MURF_VOICES[0];
183
+ }
184
+ async streamToString(stream) {
185
+ const chunks = [];
186
+ for await (const chunk of stream) {
187
+ if (typeof chunk === "string") {
188
+ chunks.push(Buffer.from(chunk));
189
+ } else {
190
+ chunks.push(chunk);
191
+ }
192
+ }
193
+ return Buffer.concat(chunks).toString("utf-8");
194
+ }
195
+ async speak(input, options) {
196
+ const text = typeof input === "string" ? input : await this.streamToString(input);
197
+ return this.traced(async () => {
198
+ const response = await this.client.post("v1/speech/generate", {
199
+ json: {
200
+ voiceId: options?.speaker || this.defaultVoice,
201
+ text,
202
+ modelVersion: this.speechModel?.name,
203
+ ...this.properties,
204
+ ...options?.properties
205
+ }
206
+ }).json();
207
+ const stream$1 = new stream.PassThrough();
208
+ const audioResponse = await fetch(response.audioFile);
209
+ if (!audioResponse.body) {
210
+ throw new Error("No response body received");
211
+ }
212
+ const reader = audioResponse.body.getReader();
213
+ (async () => {
214
+ try {
215
+ while (true) {
216
+ const { done, value } = await reader.read();
217
+ if (done) {
218
+ stream$1.end();
219
+ break;
220
+ }
221
+ stream$1.write(value);
222
+ }
223
+ } catch (error) {
224
+ stream$1.destroy(error);
225
+ }
226
+ })().catch((error) => {
227
+ stream$1.destroy(error);
228
+ });
229
+ return stream$1;
230
+ }, "voice.murf.speak")();
231
+ }
232
+ async listen(_input, _options) {
233
+ throw new Error("Murf does not support speech recognition");
234
+ }
235
+ async getSpeakers() {
236
+ return this.traced(async () => {
237
+ return MURF_VOICES.map((voice) => ({
238
+ voiceId: voice,
239
+ name: voice,
240
+ language: voice.split("-")[0],
241
+ gender: "neutral"
242
+ }));
243
+ }, "voice.murf.getSpeakers")();
244
+ }
245
+ };
246
+
247
+ exports.MurfVoice = MurfVoice;
@@ -0,0 +1,3 @@
1
+ export { MurfVoice } from './_tsup-dts-rollup.cjs';
2
+ export { MurfConfig } from './_tsup-dts-rollup.cjs';
3
+ export { MurfVoiceId } from './_tsup-dts-rollup.cjs';
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
+ import { PassThrough } from 'stream';
1
2
  import { MastraVoice } from '@mastra/core/voice';
2
3
  import ky from 'ky';
3
- import { PassThrough } from 'stream';
4
4
 
5
5
  // src/index.ts
6
6
 
@@ -178,7 +178,11 @@ var MurfVoice = class extends MastraVoice {
178
178
  async streamToString(stream) {
179
179
  const chunks = [];
180
180
  for await (const chunk of stream) {
181
- chunks.push(Buffer.from(chunk));
181
+ if (typeof chunk === "string") {
182
+ chunks.push(Buffer.from(chunk));
183
+ } else {
184
+ chunks.push(chunk);
185
+ }
182
186
  }
183
187
  return Buffer.concat(chunks).toString("utf-8");
184
188
  }
package/package.json CHANGED
@@ -1,8 +1,11 @@
1
1
  {
2
2
  "name": "@mastra/voice-murf",
3
- "version": "0.0.0-storage-20250225005900",
3
+ "version": "0.0.0-vnextWorkflows-20250417075051",
4
4
  "description": "Mastra Murf voice integration",
5
5
  "type": "module",
6
+ "files": [
7
+ "dist"
8
+ ],
6
9
  "main": "dist/index.js",
7
10
  "types": "dist/index.d.ts",
8
11
  "exports": {
@@ -10,26 +13,31 @@
10
13
  "import": {
11
14
  "types": "./dist/index.d.ts",
12
15
  "default": "./dist/index.js"
16
+ },
17
+ "require": {
18
+ "types": "./dist/index.d.cts",
19
+ "default": "./dist/index.cjs"
13
20
  }
14
21
  },
15
22
  "./package.json": "./package.json"
16
23
  },
24
+ "license": "Elastic-2.0",
17
25
  "dependencies": {
18
- "ky": "^1.7.4",
19
- "zod": "^3.24.1",
20
- "@mastra/core": "^0.0.0-storage-20250225005900"
26
+ "ky": "^1.7.5",
27
+ "zod": "^3.24.2",
28
+ "@mastra/core": "0.0.0-vnextWorkflows-20250417075051"
21
29
  },
22
30
  "devDependencies": {
23
- "@microsoft/api-extractor": "^7.49.2",
24
- "@types/node": "^22.13.1",
25
- "tsup": "^8.0.1",
26
- "typescript": "^5.7.3",
27
- "eslint": "^9.20.1",
28
- "vitest": "^2.1.8",
29
- "@internal/lint": "0.0.0"
31
+ "@microsoft/api-extractor": "^7.52.2",
32
+ "@types/node": "^20.17.27",
33
+ "eslint": "^9.23.0",
34
+ "tsup": "^8.4.0",
35
+ "typescript": "^5.8.2",
36
+ "vitest": "^2.1.9",
37
+ "@internal/lint": "0.0.2"
30
38
  },
31
39
  "scripts": {
32
- "build": "tsup src/index.ts --format esm --experimental-dts --clean --treeshake",
40
+ "build": "tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake=smallest --splitting",
33
41
  "build:watch": "pnpm build --watch",
34
42
  "test": "vitest run",
35
43
  "lint": "eslint ."
@@ -1,19 +0,0 @@
1
-
2
- 
3
- > @mastra/voice-murf@0.1.0-alpha.2 build /Users/ward/projects/mastra/mastra/voice/murf
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 1460ms
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/murf/dist/_tsup-dts-rollup.d.ts
15
- DTS ⚡️ Build success in 1814ms
16
- CLI Cleaning output folder
17
- ESM Build start
18
- ESM dist/index.js 4.95 KB
19
- ESM ⚡️ Build success in 127ms
package/CHANGELOG.md DELETED
@@ -1,51 +0,0 @@
1
- # @mastra/voice-murf
2
-
3
- ## 0.0.0-storage-20250225005900
4
-
5
- ### Patch Changes
6
-
7
- - 5b1af96: deprecate @mastra/speech-murf for @mastra/voice-murf
8
- - Updated dependencies [7fceae1]
9
- - Updated dependencies [f626fbb]
10
- - Updated dependencies [8db2a28]
11
- - @mastra/core@0.0.0-storage-20250225005900
12
-
13
- ## 0.1.0-alpha.2
14
-
15
- ### Patch Changes
16
-
17
- - 5b1af96: deprecate @mastra/speech-murf for @mastra/voice-murf
18
-
19
- ## 0.1.0 (2024-XX-XX)
20
-
21
- This package replaces the deprecated @mastra/speech-murf package. All functionality has been migrated to this new package with a more consistent naming scheme.
22
-
23
- ### Changes from @mastra/speech-murf
24
-
25
- - Package renamed from @mastra/speech-murf to @mastra/voice-murf
26
- - API changes:
27
- - `MurfTTS` class renamed to `MurfVoice`
28
- - `generate()` and `stream()` methods combined into `speak()`
29
- - `voices()` method renamed to `getSpeakers()`
30
- - Constructor configuration simplified
31
- - Added support for text stream input
32
- - Default speaker configuration added
33
- - All core functionality remains the same
34
- - Import paths should be updated from '@mastra/speech-murf' to '@mastra/voice-murf'
35
-
36
- ### Key Features Preserved
37
-
38
- - High-quality voice synthesis
39
- - Multiple voice options with rich metadata
40
- - Streaming support
41
- - Natural and expressive speech output
42
- - Voice customization options including:
43
- - Style control
44
- - Rate adjustment
45
- - Pitch modification
46
- - Sample rate selection
47
- - Audio format options
48
- - Channel type selection
49
- - Pronunciation dictionary support
50
-
51
- For a complete history of changes prior to the rename, please see the changelog of the original package.
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];
package/src/index.test.ts DELETED
@@ -1,97 +0,0 @@
1
- import { mkdirSync } from 'fs';
2
- import path, { join } from 'path';
3
- import { Readable } from 'stream';
4
- import { describe, expect, it, beforeAll } from 'vitest';
5
-
6
- import { writeFile, stat as fsStat } from 'fs/promises';
7
-
8
- import { MurfVoice } from './index';
9
-
10
- describe('MurfVoice', () => {
11
- const voice = new MurfVoice({
12
- speechModel: {
13
- name: 'GEN2',
14
- },
15
- speaker: 'en-US-natalie',
16
- });
17
-
18
- const outputDir = path.join(process.cwd(), 'test-outputs');
19
- beforeAll(() => {
20
- // Create output directory if it doesn't exist
21
- try {
22
- mkdirSync(outputDir, { recursive: true });
23
- } catch (err) {
24
- console.error(`Failed to create output directory: ${err}`);
25
- }
26
- });
27
-
28
- it('should list available speakers', async () => {
29
- const speakers = await voice.getSpeakers();
30
- expect(speakers.length).toBeGreaterThan(0);
31
- expect(speakers[0]).toHaveProperty('voiceId');
32
- });
33
-
34
- it('should generate audio from text', async () => {
35
- const audioStream = await voice.speak('Hello world!!!');
36
- expect(audioStream).toHaveProperty('pipe');
37
-
38
- // Collect the audio data
39
- const chunks: Buffer[] = [];
40
- for await (const chunk of audioStream) {
41
- chunks.push(Buffer.from(chunk));
42
- }
43
- const audioBuffer = Buffer.concat(chunks);
44
- expect(audioBuffer.length).toBeGreaterThan(0);
45
-
46
- // Write the audio to a file
47
- const outputPath = join(outputDir, 'test-audio.mp3');
48
- await writeFile(outputPath, audioBuffer);
49
- });
50
-
51
- it('should handle stream input', async () => {
52
- // Create a readable stream from text
53
- const textStream = Readable.from(['Hello', ' from', ' stream', ' input!']);
54
-
55
- const audioStream = await voice.speak(textStream);
56
- expect(audioStream).toHaveProperty('pipe');
57
-
58
- // Write the audio to a file using pipe
59
- const outputPath = join(outputDir, 'test-audio-stream.mp3');
60
-
61
- const chunks: Buffer[] = [];
62
- for await (const chunk of audioStream) {
63
- chunks.push(Buffer.from(chunk));
64
- }
65
- const audioBuffer = Buffer.concat(chunks);
66
- await writeFile(outputPath, audioBuffer);
67
- const stats = await fsStat(outputPath);
68
- expect(stats.size).toBeGreaterThan(0);
69
- });
70
-
71
- it('should work with default configuration', async () => {
72
- // Create instance with no args
73
- const defaultVoice = new MurfVoice();
74
-
75
- // Should use default model name and get API key from env
76
- const audioStream = await defaultVoice.speak('Testing default configuration');
77
- expect(audioStream).toHaveProperty('pipe');
78
-
79
- const chunks: Buffer[] = [];
80
- for await (const chunk of audioStream) {
81
- chunks.push(Buffer.from(chunk));
82
- }
83
- const audioBuffer = Buffer.concat(chunks);
84
-
85
- await writeFile(join(outputDir, 'murf-default-config-output.mp3'), audioBuffer);
86
- expect(audioBuffer.length).toBeGreaterThan(0);
87
-
88
- // Verify default speaker was used
89
- const speakers = await defaultVoice.getSpeakers();
90
- expect(speakers.length).toBeGreaterThan(0);
91
- });
92
-
93
- it('should throw error for speech recognition', async () => {
94
- const audioStream = Readable.from(Buffer.from('dummy audio data'));
95
- await expect(voice.listen(audioStream)).rejects.toThrow('Murf does not support speech recognition');
96
- });
97
- });
package/src/index.ts DELETED
@@ -1,159 +0,0 @@
1
- import { MastraVoice } from '@mastra/core/voice';
2
- import ky from 'ky';
3
- import { PassThrough } from 'stream';
4
-
5
- import { MURF_VOICES } from './voices';
6
- import type { MurfVoiceId } from './voices';
7
-
8
- type MurfConfig = {
9
- name: 'GEN1' | 'GEN2';
10
- apiKey?: string;
11
- properties?: Omit<SpeechCreateParams, 'modelVersion' | 'voiceId' | 'text'>;
12
- };
13
-
14
- type SpeechCreateParams = {
15
- voiceId: MurfVoiceId;
16
- text: string;
17
- modelVersion: 'GEN1' | 'GEN2';
18
- style?: string;
19
- rate?: number;
20
- pitch?: number;
21
- sampleRate?: 8000 | 24000 | 44100 | 48000;
22
- format?: 'MP3' | 'WAV' | 'FLAC' | 'ALAW' | 'ULAW';
23
- channelType?: 'STEREO' | 'MONO';
24
- pronunciationDictionary?: Record<string, string>;
25
- encodeAsBase64?: boolean;
26
- variation?: number;
27
- audioDuration?: number;
28
- multiNativeLocale?: string;
29
- };
30
-
31
- type SpeechCreateResponse = {
32
- audioFile: string;
33
- audioLengthInSeconds: number;
34
- consumedCharacterCount: number;
35
- encodedAudio: string;
36
- remainingCharacterCount: number;
37
- warning: string;
38
- wordDurations: {
39
- endMs: number;
40
- pitchScaleMaximum: number;
41
- pitchScaleMinimum: number;
42
- sourceWordIndex: number;
43
- startMs: number;
44
- word: string;
45
- }[];
46
- };
47
-
48
- export class MurfVoice extends MastraVoice {
49
- private client: typeof ky;
50
- private defaultVoice: MurfVoiceId;
51
- private properties: Omit<SpeechCreateParams, 'modelVersion' | 'voiceId' | 'text'>;
52
-
53
- constructor({ speechModel, speaker }: { speechModel?: MurfConfig; speaker?: string } = {}) {
54
- super({
55
- speechModel: {
56
- name: speechModel?.name ?? 'GEN2',
57
- apiKey: speechModel?.apiKey ?? process.env.MURF_API_KEY,
58
- },
59
- speaker: speaker ?? MURF_VOICES[0],
60
- });
61
-
62
- const apiKey = this.speechModel?.apiKey;
63
- if (!apiKey) {
64
- throw new Error('MURF_API_KEY is not set');
65
- }
66
-
67
- this.properties = {
68
- ...speechModel?.properties,
69
- };
70
-
71
- this.client = ky.create({
72
- prefixUrl: 'https://api.murf.ai',
73
- headers: {
74
- 'api-key': apiKey,
75
- },
76
- });
77
-
78
- this.defaultVoice = (speaker as MurfVoiceId) ?? MURF_VOICES[0];
79
- }
80
-
81
- private async streamToString(stream: NodeJS.ReadableStream): Promise<string> {
82
- const chunks: Buffer[] = [];
83
- for await (const chunk of stream) {
84
- chunks.push(Buffer.from(chunk));
85
- }
86
- return Buffer.concat(chunks).toString('utf-8');
87
- }
88
-
89
- async speak(
90
- input: string | NodeJS.ReadableStream,
91
- options?: { speaker?: string; properties?: Omit<SpeechCreateParams, 'modelVersion' | 'voiceId' | 'text'> },
92
- ): Promise<NodeJS.ReadableStream> {
93
- const text = typeof input === 'string' ? input : await this.streamToString(input);
94
-
95
- return this.traced(async () => {
96
- const response = await this.client
97
- .post('v1/speech/generate', {
98
- json: {
99
- voiceId: (options?.speaker || this.defaultVoice) as MurfVoiceId,
100
- text,
101
- modelVersion: this.speechModel?.name,
102
- ...this.properties,
103
- ...options?.properties,
104
- },
105
- })
106
- .json<SpeechCreateResponse>();
107
-
108
- // Create a PassThrough stream for the audio
109
- const stream = new PassThrough();
110
-
111
- // Get the audio file as a stream
112
- const audioResponse = await fetch(response.audioFile);
113
- if (!audioResponse.body) {
114
- throw new Error('No response body received');
115
- }
116
-
117
- // Process the stream
118
- const reader = audioResponse.body.getReader();
119
- (async () => {
120
- try {
121
- while (true) {
122
- const { done, value } = await reader.read();
123
- if (done) {
124
- stream.end();
125
- break;
126
- }
127
- stream.write(value);
128
- }
129
- } catch (error) {
130
- stream.destroy(error as Error);
131
- }
132
- })().catch(error => {
133
- stream.destroy(error as Error);
134
- });
135
-
136
- return stream;
137
- }, 'voice.murf.speak')();
138
- }
139
-
140
- async listen(
141
- _input: NodeJS.ReadableStream,
142
- _options?: Record<string, unknown>,
143
- ): Promise<string | NodeJS.ReadableStream> {
144
- throw new Error('Murf does not support speech recognition');
145
- }
146
-
147
- async getSpeakers() {
148
- return this.traced(async () => {
149
- return MURF_VOICES.map(voice => ({
150
- voiceId: voice,
151
- name: voice,
152
- language: voice.split('-')[0],
153
- gender: 'neutral',
154
- }));
155
- }, 'voice.murf.getSpeakers')();
156
- }
157
- }
158
-
159
- export type { MurfConfig, MurfVoiceId };
package/src/voices.ts DELETED
@@ -1,146 +0,0 @@
1
- /**
2
- * List of available voices for Murf TTS
3
- */
4
- export const MURF_VOICES = [
5
- 'en-UK-hazel',
6
- 'en-US-cooper',
7
- 'en-US-imani',
8
- 'it-IT-giorgio',
9
- 'en-US-wayne',
10
- 'en-IN-shivani',
11
- 'en-US-daniel',
12
- 'bn-IN-anwesha',
13
- 'es-MX-alejandro',
14
- 'en-AU-joyce',
15
- 'en-US-zion',
16
- 'en-IN-isha',
17
- 'en-US-riley',
18
- 'ko-KR-hwan',
19
- 'fr-FR-adélie',
20
- 'en-US-carter',
21
- 'en-UK-gabriel',
22
- 'en-UK-juliet',
23
- 'en-IN-arohi',
24
- 'fr-FR-maxime',
25
- 'de-DE-josephine',
26
- 'en-UK-hugo',
27
- 'en-US-samantha',
28
- 'de-DE-erna',
29
- 'zh-CN-baolin',
30
- 'pt-BR-isadora',
31
- 'it-IT-vincenzo',
32
- 'en-US-terrell',
33
- 'en-US-denzel',
34
- 'en-UK-heidi',
35
- 'en-US-miles',
36
- 'en-US-abigail',
37
- 'fr-FR-justine',
38
- 'it-IT-greta',
39
- 'en-AU-shane',
40
- 'en-UK-peter',
41
- 'nl-NL-famke',
42
- 'en-AU-ivy',
43
- 'nl-NL-dirk',
44
- 'fr-FR-axel',
45
- 'es-ES-carla',
46
- 'en-US-claire',
47
- 'ko-KR-jangmi',
48
- 'ko-KR-sanghoon',
49
- 'it-IT-vera',
50
- 'hi-IN-rahul',
51
- 'es-ES-elvira',
52
- 'es-ES-enrique',
53
- 'en-UK-aiden',
54
- 'en-US-ronnie',
55
- 'en-UK-amber',
56
- 'hi-IN-shweta',
57
- 'hi-IN-amit',
58
- 'en-AU-jimm',
59
- 'en-UK-pearl',
60
- 'pt-BR-benício',
61
- 'en-UK-freddie',
62
- 'en-US-ryan',
63
- 'pt-BR-eloa',
64
- 'en-US-charlotte',
65
- 'de-DE-lia',
66
- 'en-US-natalie',
67
- 'en-US-michelle',
68
- 'en-US-phoebe',
69
- 'es-ES-carmen',
70
- 'en-US-caleb',
71
- 'en-US-iris',
72
- 'en-UK-harrison',
73
- 'en-US-marcus',
74
- 'en-US-josie',
75
- 'en-US-daisy',
76
- 'en-US-charles',
77
- 'en-UK-reggie',
78
- 'en-US-julia',
79
- 'en-SCOTT-emily',
80
- 'en-US-dylan',
81
- 'es-MX-valeria',
82
- 'en-IN-eashwar',
83
- 'en-AU-evelyn',
84
- 'de-DE-lara',
85
- 'en-US-evander',
86
- 'en-SCOTT-rory',
87
- 'ta-IN-iniya',
88
- 'en-AU-leyton',
89
- 'fr-FR-louise',
90
- 'zh-CN-wei',
91
- 'ko-KR-gyeong',
92
- 'de-DE-matthias',
93
- 'en-IN-rohan',
94
- 'en-US-delilah',
95
- 'bn-IN-abhik',
96
- 'en-US-angela',
97
- 'en-US-naomi',
98
- 'es-MX-carlos',
99
- 'nl-NL-merel',
100
- 'en-US-alicia',
101
- 'en-IN-alia',
102
- 'zh-CN-jiao',
103
- 'en-US-june',
104
- 'en-AU-ashton',
105
- 'en-UK-finley',
106
- 'pl-PL-blazej',
107
- 'zh-CN-zhang',
108
- 'en-AU-kylie',
109
- 'en-US-jayden',
110
- 'en-IN-aarav',
111
- 'de-DE-björn',
112
- 'bn-IN-ishani',
113
- 'zh-CN-yuxan',
114
- 'fr-FR-louis',
115
- 'ko-KR-jong-su',
116
- 'en-AU-harper',
117
- 'en-UK-ruby',
118
- 'en-US-ken',
119
- 'ta-IN-mani',
120
- 'de-DE-ralf',
121
- 'en-UK-jaxon',
122
- 'en-US-river',
123
- 'en-IN-priya',
124
- 'en-UK-theo',
125
- 'en-UK-katie',
126
- 'pl-PL-jacek',
127
- 'it-IT-lorenzo',
128
- 'hi-IN-shaan',
129
- 'en-US-amara',
130
- 'en-UK-mason',
131
- 'en-IN-surya',
132
- 'en-US-finn',
133
- 'pt-BR-gustavo',
134
- 'hi-IN-kabir',
135
- 'es-ES-javier',
136
- 'en-AU-mitch',
137
- 'pt-BR-heitor',
138
- 'en-US-edmund',
139
- 'hi-IN-ayushi',
140
- 'pl-PL-kasia',
141
- 'es-MX-luisa',
142
- 'zh-CN-tao',
143
- 'en-US-molly',
144
- ] as const;
145
-
146
- export type MurfVoiceId = (typeof MURF_VOICES)[number];
package/tsconfig.json DELETED
@@ -1,5 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.node.json",
3
- "include": ["src/**/*"],
4
- "exclude": ["node_modules", "**/*.test.ts"]
5
- }
package/vitest.config.ts DELETED
@@ -1,8 +0,0 @@
1
- import { defineConfig } from 'vitest/config';
2
-
3
- export default defineConfig({
4
- test: {
5
- include: ['src/**/*.test.ts'],
6
- environment: 'node',
7
- },
8
- });