@mastra/voice-murf 0.13.0 → 0.13.1-alpha.1

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
@@ -1,534 +1,640 @@
1
- 'use strict';
2
-
3
- var stream = require('stream');
4
-
5
- // src/index.ts
6
-
7
- // ../../packages/_internal-core/dist/chunk-3M4SEWMI.js
8
- var RegisteredLogger = {
9
- LLM: "LLM"};
10
- var LogLevel = {
11
- DEBUG: "debug",
12
- INFO: "info",
13
- WARN: "warn",
14
- ERROR: "error"};
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ let stream = require("stream");
3
+ //#region ../../packages/_internal-core/dist/logger/index.js
4
+ /**
5
+ * Export a tracked exception through the adapter sink, mirroring the
6
+ * DualLogger dual-write shape (`errorId`/`domain`/`category`/`details`/`cause`
7
+ * when present on a MastraError-like value). Never throws into the caller.
8
+ */
9
+ function exportTrackedException(ctx, error, metadata) {
10
+ if (!ctx?.options.export) return;
11
+ try {
12
+ const mastraError = error;
13
+ ctx.getLogSink()?.error(error.message, {
14
+ ...mastraError.id !== void 0 ? { errorId: mastraError.id } : {},
15
+ ...mastraError.domain !== void 0 ? { domain: mastraError.domain } : {},
16
+ ...mastraError.category !== void 0 ? { category: mastraError.category } : {},
17
+ ...mastraError.details !== void 0 ? { details: mastraError.details } : {},
18
+ ...error.cause instanceof Error ? { cause: error.cause.message } : {},
19
+ ...metadata
20
+ });
21
+ } catch {}
22
+ }
23
+ /**
24
+ * Adapt IMastraLogger's variadic args into the structured `data` payload of
25
+ * an exported log record. Extracts the first plain object as data,
26
+ * serializes an Error arg, and collects remaining primitives under `args`
27
+ * so the derived record preserves all context from the native call.
28
+ */
29
+ function buildLogRecordData(args) {
30
+ const objectData = args.find((arg) => arg !== null && typeof arg === "object" && !Array.isArray(arg) && !(arg instanceof Error));
31
+ const errorArg = args.find((arg) => arg instanceof Error);
32
+ const extraArgs = args.filter((arg) => arg !== objectData && arg !== errorArg);
33
+ if (!objectData && !errorArg && extraArgs.length === 0) return void 0;
34
+ return {
35
+ ...objectData ?? {},
36
+ ...errorArg ? { error: {
37
+ name: errorArg.name,
38
+ message: errorArg.message,
39
+ stack: errorArg.stack
40
+ } } : {},
41
+ ...extraArgs.length > 0 ? { args: extraArgs } : {}
42
+ };
43
+ }
44
+ const RegisteredLogger = {
45
+ AGENT: "AGENT",
46
+ OBSERVABILITY: "OBSERVABILITY",
47
+ AUTH: "AUTH",
48
+ BROWSER: "BROWSER",
49
+ NETWORK: "NETWORK",
50
+ WORKFLOW: "WORKFLOW",
51
+ LLM: "LLM",
52
+ TTS: "TTS",
53
+ VOICE: "VOICE",
54
+ VECTOR: "VECTOR",
55
+ BUNDLER: "BUNDLER",
56
+ DEPLOYER: "DEPLOYER",
57
+ MEMORY: "MEMORY",
58
+ STORAGE: "STORAGE",
59
+ EMBEDDINGS: "EMBEDDINGS",
60
+ MCP_SERVER: "MCP_SERVER",
61
+ SERVER_CACHE: "SERVER_CACHE",
62
+ SERVER: "SERVER",
63
+ WORKSPACE: "WORKSPACE",
64
+ CHANNEL: "CHANNEL"
65
+ };
66
+ const LogLevel = {
67
+ DEBUG: "debug",
68
+ INFO: "info",
69
+ WARN: "warn",
70
+ ERROR: "error",
71
+ NONE: "silent"
72
+ };
15
73
  var MastraLogger = class {
16
- name;
17
- level;
18
- transports;
19
- constructor(options = {}) {
20
- this.name = options.name || "Mastra";
21
- this.level = options.level || LogLevel.ERROR;
22
- this.transports = new Map(Object.entries(options.transports || {}));
23
- }
24
- getTransports() {
25
- return this.transports;
26
- }
27
- trackException(_error, _metadata) {
28
- }
29
- async listLogs(transportId, params) {
30
- if (!transportId || !this.transports.has(transportId)) {
31
- return { logs: [], total: 0, page: params?.page ?? 1, perPage: params?.perPage ?? 100, hasMore: false };
32
- }
33
- return this.transports.get(transportId).listLogs?.(params) ?? {
34
- logs: [],
35
- total: 0,
36
- page: params?.page ?? 1,
37
- perPage: params?.perPage ?? 100,
38
- hasMore: false
39
- };
40
- }
41
- async listLogsByRunId({
42
- transportId,
43
- runId,
44
- fromDate,
45
- toDate,
46
- logLevel,
47
- filters,
48
- page,
49
- perPage
50
- }) {
51
- if (!transportId || !this.transports.has(transportId) || !runId) {
52
- return { logs: [], total: 0, page: page ?? 1, perPage: perPage ?? 100, hasMore: false };
53
- }
54
- return this.transports.get(transportId).listLogsByRunId?.({ runId, fromDate, toDate, logLevel, filters, page, perPage }) ?? {
55
- logs: [],
56
- total: 0,
57
- page: page ?? 1,
58
- perPage: perPage ?? 100,
59
- hasMore: false
60
- };
61
- }
74
+ name;
75
+ level;
76
+ transports;
77
+ constructor(options = {}) {
78
+ this.name = options.name || "Mastra";
79
+ this.level = options.level || LogLevel.ERROR;
80
+ this.transports = new Map(Object.entries(options.transports || {}));
81
+ }
82
+ getTransports() {
83
+ return this.transports;
84
+ }
85
+ trackException(_error, _metadata) {}
86
+ async listLogs(transportId, params) {
87
+ if (!transportId || !this.transports.has(transportId)) return {
88
+ logs: [],
89
+ total: 0,
90
+ page: params?.page ?? 1,
91
+ perPage: params?.perPage ?? 100,
92
+ hasMore: false
93
+ };
94
+ return this.transports.get(transportId).listLogs?.(params) ?? {
95
+ logs: [],
96
+ total: 0,
97
+ page: params?.page ?? 1,
98
+ perPage: params?.perPage ?? 100,
99
+ hasMore: false
100
+ };
101
+ }
102
+ async listLogsByRunId({ transportId, runId, fromDate, toDate, logLevel, filters, page, perPage }) {
103
+ if (!transportId || !this.transports.has(transportId) || !runId) return {
104
+ logs: [],
105
+ total: 0,
106
+ page: page ?? 1,
107
+ perPage: perPage ?? 100,
108
+ hasMore: false
109
+ };
110
+ return this.transports.get(transportId).listLogsByRunId?.({
111
+ runId,
112
+ fromDate,
113
+ toDate,
114
+ logLevel,
115
+ filters,
116
+ page,
117
+ perPage
118
+ }) ?? {
119
+ logs: [],
120
+ total: 0,
121
+ page: page ?? 1,
122
+ perPage: perPage ?? 100,
123
+ hasMore: false
124
+ };
125
+ }
62
126
  };
63
- var ConsoleLogger = class _ConsoleLogger extends MastraLogger {
64
- component;
65
- filter;
66
- constructor(options = {}) {
67
- super(options);
68
- this.component = options.component;
69
- this.filter = options.filter;
70
- }
71
- child(componentOrBindings) {
72
- const component = typeof componentOrBindings === "string" ? componentOrBindings : componentOrBindings?.component ?? this.component;
73
- return new _ConsoleLogger({
74
- name: this.name,
75
- level: this.level,
76
- component,
77
- filter: this.filter
78
- });
79
- }
80
- shouldLog(level, message, args) {
81
- if (!this.filter) return true;
82
- try {
83
- return this.filter({ component: this.component, level, message, args });
84
- } catch (e) {
85
- console.error(`[Logger] Filter error for component=${this.component} level=${level}:`, e);
86
- return true;
87
- }
88
- }
89
- prefix() {
90
- return this.component ? `[${this.component}] ` : "";
91
- }
92
- debug(message, ...args) {
93
- if (this.level === LogLevel.DEBUG && this.shouldLog(LogLevel.DEBUG, message, args)) {
94
- console.info(`${this.prefix()}${message}`, ...args);
95
- }
96
- }
97
- info(message, ...args) {
98
- if ((this.level === LogLevel.INFO || this.level === LogLevel.DEBUG) && this.shouldLog(LogLevel.INFO, message, args)) {
99
- console.info(`${this.prefix()}${message}`, ...args);
100
- }
101
- }
102
- warn(message, ...args) {
103
- if ((this.level === LogLevel.WARN || this.level === LogLevel.INFO || this.level === LogLevel.DEBUG) && this.shouldLog(LogLevel.WARN, message, args)) {
104
- console.warn(`${this.prefix()}${message}`, ...args);
105
- }
106
- }
107
- error(message, ...args) {
108
- if ((this.level === LogLevel.ERROR || this.level === LogLevel.WARN || this.level === LogLevel.INFO || this.level === LogLevel.DEBUG) && this.shouldLog(LogLevel.ERROR, message, args)) {
109
- console.error(`${this.prefix()}${message}`, ...args);
110
- }
111
- }
112
- async listLogs(_transportId, _params) {
113
- return { logs: [], total: 0, page: _params?.page ?? 1, perPage: _params?.perPage ?? 100, hasMore: false };
114
- }
115
- async listLogsByRunId(_args) {
116
- return { logs: [], total: 0, page: _args.page ?? 1, perPage: _args.perPage ?? 100, hasMore: false };
117
- }
127
+ var ConsoleLogger = class ConsoleLogger extends MastraLogger {
128
+ component;
129
+ filter;
130
+ #adapterContext;
131
+ constructor(options = {}) {
132
+ super(options);
133
+ this.component = options.component;
134
+ this.filter = options.filter;
135
+ }
136
+ /**
137
+ * Adapter hook (see `AdaptableLogger`): enables native trace correlation
138
+ * (trace_id/span_id appended to console output) and observability export
139
+ * derived from the same record. Called by Mastra during setup.
140
+ */
141
+ __attachObservability(ctx) {
142
+ this.#adapterContext = ctx;
143
+ }
144
+ child(componentOrBindings) {
145
+ const component = typeof componentOrBindings === "string" ? componentOrBindings : componentOrBindings?.component ?? this.component;
146
+ const child = new ConsoleLogger({
147
+ name: this.name,
148
+ level: this.level,
149
+ component,
150
+ filter: this.filter
151
+ });
152
+ if (this.#adapterContext) child.__attachObservability(this.#adapterContext);
153
+ return child;
154
+ }
155
+ /**
156
+ * Native-record correlation: when a span is active, append the trace
157
+ * fields object to the console args so every destination sees them.
158
+ */
159
+ #correlate(args) {
160
+ const ctx = this.#adapterContext;
161
+ if (!ctx?.options.correlation) return args;
162
+ try {
163
+ const fields = ctx.resolveTraceFields();
164
+ return fields ? [...args, fields] : args;
165
+ } catch {
166
+ return args;
167
+ }
168
+ }
169
+ /**
170
+ * Export the record derived from the same native call to observability.
171
+ * Mirrors DualLogger semantics: export is independent of the console
172
+ * level filter, and never throws into the caller.
173
+ */
174
+ #export(level, message, args) {
175
+ const ctx = this.#adapterContext;
176
+ if (!ctx?.options.export) return;
177
+ try {
178
+ ctx.getLogSink()?.[level](message, buildLogRecordData(args));
179
+ } catch {}
180
+ }
181
+ shouldLog(level, message, args) {
182
+ if (!this.filter) return true;
183
+ try {
184
+ return this.filter({
185
+ component: this.component,
186
+ level,
187
+ message,
188
+ args
189
+ });
190
+ } catch (e) {
191
+ console.error(`[Logger] Filter error for component=${this.component} level=${level}:`, e);
192
+ return true;
193
+ }
194
+ }
195
+ prefix() {
196
+ return this.component ? `[${this.component}] ` : "";
197
+ }
198
+ debug(message, ...args) {
199
+ if (this.level === LogLevel.DEBUG && this.shouldLog(LogLevel.DEBUG, message, args)) console.info(`${this.prefix()}${message}`, ...this.#correlate(args));
200
+ this.#export("debug", message, args);
201
+ }
202
+ info(message, ...args) {
203
+ if ((this.level === LogLevel.INFO || this.level === LogLevel.DEBUG) && this.shouldLog(LogLevel.INFO, message, args)) console.info(`${this.prefix()}${message}`, ...this.#correlate(args));
204
+ this.#export("info", message, args);
205
+ }
206
+ warn(message, ...args) {
207
+ if ((this.level === LogLevel.WARN || this.level === LogLevel.INFO || this.level === LogLevel.DEBUG) && this.shouldLog(LogLevel.WARN, message, args)) console.warn(`${this.prefix()}${message}`, ...this.#correlate(args));
208
+ this.#export("warn", message, args);
209
+ }
210
+ error(message, ...args) {
211
+ if ((this.level === LogLevel.ERROR || this.level === LogLevel.WARN || this.level === LogLevel.INFO || this.level === LogLevel.DEBUG) && this.shouldLog(LogLevel.ERROR, message, args)) console.error(`${this.prefix()}${message}`, ...this.#correlate(args));
212
+ this.#export("error", message, args);
213
+ }
214
+ trackException(error, metadata) {
215
+ exportTrackedException(this.#adapterContext, error, metadata);
216
+ }
217
+ async listLogs(_transportId, _params) {
218
+ return {
219
+ logs: [],
220
+ total: 0,
221
+ page: _params?.page ?? 1,
222
+ perPage: _params?.perPage ?? 100,
223
+ hasMore: false
224
+ };
225
+ }
226
+ async listLogsByRunId(_args) {
227
+ return {
228
+ logs: [],
229
+ total: 0,
230
+ page: _args.page ?? 1,
231
+ perPage: _args.perPage ?? 100,
232
+ hasMore: false
233
+ };
234
+ }
118
235
  };
119
-
120
- // ../../packages/_internal-core/dist/base/index.js
236
+ //#endregion
237
+ //#region ../../packages/_internal-core/dist/base/index.js
121
238
  var MastraBase = class {
122
- component = RegisteredLogger.LLM;
123
- logger;
124
- name;
125
- #rawConfig;
126
- constructor({
127
- component,
128
- name,
129
- rawConfig
130
- }) {
131
- this.component = component || RegisteredLogger.LLM;
132
- this.name = name;
133
- this.#rawConfig = rawConfig;
134
- this.logger = new ConsoleLogger({ name: `${this.component} - ${this.name}` });
135
- }
136
- /**
137
- * Returns the raw storage configuration this primitive was created from,
138
- * or undefined if it was created from code.
139
- */
140
- toRawConfig() {
141
- return this.#rawConfig;
142
- }
143
- /**
144
- * Sets the raw storage configuration for this primitive.
145
- * @internal
146
- */
147
- __setRawConfig(rawConfig) {
148
- this.#rawConfig = rawConfig;
149
- }
150
- /**
151
- * Set the logger for the agent
152
- * @param logger
153
- */
154
- __setLogger(logger) {
155
- this.logger = "child" in logger && typeof logger.child === "function" ? logger.child({ component: this.component }) : logger;
156
- }
239
+ component = RegisteredLogger.LLM;
240
+ logger;
241
+ name;
242
+ #rawConfig;
243
+ constructor({ component, name, rawConfig }) {
244
+ this.component = component || RegisteredLogger.LLM;
245
+ this.name = name;
246
+ this.#rawConfig = rawConfig;
247
+ this.logger = new ConsoleLogger({ name: `${this.component} - ${this.name}` });
248
+ }
249
+ /**
250
+ * Returns the raw storage configuration this primitive was created from,
251
+ * or undefined if it was created from code.
252
+ */
253
+ toRawConfig() {
254
+ return this.#rawConfig;
255
+ }
256
+ /**
257
+ * Sets the raw storage configuration for this primitive.
258
+ * @internal
259
+ */
260
+ __setRawConfig(rawConfig) {
261
+ this.#rawConfig = rawConfig;
262
+ }
263
+ /**
264
+ * Set the logger for the agent
265
+ * @param logger
266
+ */
267
+ __setLogger(logger) {
268
+ this.logger = "child" in logger && typeof logger.child === "function" ? logger.child({ component: this.component }) : logger;
269
+ }
157
270
  };
158
-
159
- // ../../packages/_internals/voice/dist/chunk-NWNKSBZV.js
271
+ //#endregion
272
+ //#region ../../packages/_internals/voice/dist/aisdk-C_K-VCwq.js
160
273
  var MastraVoice = class extends MastraBase {
161
- listeningModel;
162
- speechModel;
163
- speaker;
164
- realtimeConfig;
165
- constructor({ listeningModel, speechModel, speaker, realtimeConfig, name } = {}) {
166
- super({
167
- component: "VOICE",
168
- name
169
- });
170
- this.listeningModel = listeningModel;
171
- this.speechModel = speechModel;
172
- this.speaker = speaker;
173
- this.realtimeConfig = realtimeConfig;
174
- }
175
- /**
176
- * Custom serialization for tracing/observability spans.
177
- * Excludes `apiKey` from listeningModel / speechModel / realtimeConfig
178
- * and any provider-specific state held by subclasses. Subclasses that
179
- * need to expose additional non-sensitive fields can override.
180
- */
181
- serializeForSpan() {
182
- return {
183
- component: "VOICE",
184
- name: this.name,
185
- speaker: this.speaker,
186
- listeningModel: this.listeningModel ? { name: this.listeningModel.name } : void 0,
187
- speechModel: this.speechModel ? { name: this.speechModel.name } : void 0,
188
- realtimeModel: this.realtimeConfig?.model
189
- };
190
- }
191
- updateConfig(_options) {
192
- this.logger.debug("updateConfig not implemented by this voice provider");
193
- }
194
- /**
195
- * Initializes a WebSocket or WebRTC connection for real-time communication
196
- * @returns Promise that resolves when the connection is established
197
- */
198
- async connect(_options) {
199
- this.logger.debug("connect not implemented by this voice provider");
200
- }
201
- /**
202
- * Relay audio data to the voice provider for real-time processing
203
- * @param audioData Audio data to relay
204
- */
205
- async send(_audioData) {
206
- this.logger.debug("relay not implemented by this voice provider");
207
- }
208
- /**
209
- * Trigger voice providers to respond
210
- */
211
- async answer(_options) {
212
- this.logger.debug("answer not implemented by this voice provider");
213
- }
214
- /**
215
- * Equip the voice provider with instructions
216
- * @param instructions Instructions to add
217
- */
218
- addInstructions(_instructions) {
219
- }
220
- /**
221
- * Equip the voice provider with tools
222
- * @param tools Array of tools to add
223
- */
224
- addTools(_tools) {
225
- }
226
- /**
227
- * Disconnect from the WebSocket or WebRTC connection
228
- */
229
- close() {
230
- this.logger.debug("close not implemented by this voice provider");
231
- }
232
- /**
233
- * Register an event listener
234
- * @param event Event name (e.g., 'speaking', 'writing', 'error')
235
- * @param callback Callback function that receives event data
236
- */
237
- on(_event, _callback) {
238
- this.logger.debug("on not implemented by this voice provider");
239
- }
240
- /**
241
- * Remove an event listener
242
- * @param event Event name (e.g., 'speaking', 'writing', 'error')
243
- * @param callback Callback function to remove
244
- */
245
- off(_event, _callback) {
246
- this.logger.debug("off not implemented by this voice provider");
247
- }
248
- /**
249
- * Get available speakers/voices
250
- * @returns Array of available voice IDs and their metadata
251
- */
252
- getSpeakers() {
253
- this.logger.debug("getSpeakers not implemented by this voice provider");
254
- return Promise.resolve([]);
255
- }
256
- /**
257
- * Get available speakers/voices
258
- * @returns Array of available voice IDs and their metadata
259
- */
260
- getListener() {
261
- this.logger.debug("getListener not implemented by this voice provider");
262
- return Promise.resolve({ enabled: false });
263
- }
274
+ listeningModel;
275
+ speechModel;
276
+ speaker;
277
+ realtimeConfig;
278
+ constructor({ listeningModel, speechModel, speaker, realtimeConfig, name } = {}) {
279
+ super({
280
+ component: "VOICE",
281
+ name
282
+ });
283
+ this.listeningModel = listeningModel;
284
+ this.speechModel = speechModel;
285
+ this.speaker = speaker;
286
+ this.realtimeConfig = realtimeConfig;
287
+ }
288
+ /**
289
+ * Custom serialization for tracing/observability spans.
290
+ * Excludes `apiKey` from listeningModel / speechModel / realtimeConfig
291
+ * and any provider-specific state held by subclasses. Subclasses that
292
+ * need to expose additional non-sensitive fields can override.
293
+ */
294
+ serializeForSpan() {
295
+ return {
296
+ component: "VOICE",
297
+ name: this.name,
298
+ speaker: this.speaker,
299
+ listeningModel: this.listeningModel ? { name: this.listeningModel.name } : void 0,
300
+ speechModel: this.speechModel ? { name: this.speechModel.name } : void 0,
301
+ realtimeModel: this.realtimeConfig?.model
302
+ };
303
+ }
304
+ updateConfig(_options) {
305
+ this.logger.debug("updateConfig not implemented by this voice provider");
306
+ }
307
+ /**
308
+ * Initializes a WebSocket or WebRTC connection for real-time communication
309
+ * @returns Promise that resolves when the connection is established
310
+ */
311
+ async connect(_options) {
312
+ this.logger.debug("connect not implemented by this voice provider");
313
+ }
314
+ /**
315
+ * Relay audio data to the voice provider for real-time processing
316
+ * @param audioData Audio data to relay
317
+ */
318
+ async send(_audioData) {
319
+ this.logger.debug("relay not implemented by this voice provider");
320
+ }
321
+ /**
322
+ * Trigger voice providers to respond
323
+ */
324
+ async answer(_options) {
325
+ this.logger.debug("answer not implemented by this voice provider");
326
+ }
327
+ /**
328
+ * Equip the voice provider with instructions
329
+ * @param instructions Instructions to add
330
+ */
331
+ addInstructions(_instructions) {}
332
+ /**
333
+ * Equip the voice provider with tools
334
+ * @param tools Array of tools to add
335
+ */
336
+ addTools(_tools) {}
337
+ /**
338
+ * Disconnect from the WebSocket or WebRTC connection
339
+ */
340
+ close() {
341
+ this.logger.debug("close not implemented by this voice provider");
342
+ }
343
+ /**
344
+ * Register an event listener
345
+ * @param event Event name (e.g., 'speaking', 'writing', 'error')
346
+ * @param callback Callback function that receives event data
347
+ */
348
+ on(_event, _callback) {
349
+ this.logger.debug("on not implemented by this voice provider");
350
+ }
351
+ /**
352
+ * Remove an event listener
353
+ * @param event Event name (e.g., 'speaking', 'writing', 'error')
354
+ * @param callback Callback function to remove
355
+ */
356
+ off(_event, _callback) {
357
+ this.logger.debug("off not implemented by this voice provider");
358
+ }
359
+ /**
360
+ * Get available speakers/voices
361
+ * @returns Array of available voice IDs and their metadata
362
+ */
363
+ getSpeakers() {
364
+ this.logger.debug("getSpeakers not implemented by this voice provider");
365
+ return Promise.resolve([]);
366
+ }
367
+ /**
368
+ * Get available speakers/voices
369
+ * @returns Array of available voice IDs and their metadata
370
+ */
371
+ getListener() {
372
+ this.logger.debug("getListener not implemented by this voice provider");
373
+ return Promise.resolve({ enabled: false });
374
+ }
264
375
  };
265
-
266
- // src/voices.ts
267
- var MURF_VOICES = [
268
- "en-UK-hazel",
269
- "en-US-cooper",
270
- "en-US-imani",
271
- "it-IT-giorgio",
272
- "en-US-wayne",
273
- "en-IN-shivani",
274
- "en-US-daniel",
275
- "bn-IN-anwesha",
276
- "es-MX-alejandro",
277
- "en-AU-joyce",
278
- "en-US-zion",
279
- "en-IN-isha",
280
- "en-US-riley",
281
- "ko-KR-hwan",
282
- "fr-FR-ad\xE9lie",
283
- "en-US-carter",
284
- "en-UK-gabriel",
285
- "en-UK-juliet",
286
- "en-IN-arohi",
287
- "fr-FR-maxime",
288
- "de-DE-josephine",
289
- "en-UK-hugo",
290
- "en-US-samantha",
291
- "de-DE-erna",
292
- "zh-CN-baolin",
293
- "pt-BR-isadora",
294
- "it-IT-vincenzo",
295
- "en-US-terrell",
296
- "en-US-denzel",
297
- "en-UK-heidi",
298
- "en-US-miles",
299
- "en-US-abigail",
300
- "fr-FR-justine",
301
- "it-IT-greta",
302
- "en-AU-shane",
303
- "en-UK-peter",
304
- "nl-NL-famke",
305
- "en-AU-ivy",
306
- "nl-NL-dirk",
307
- "fr-FR-axel",
308
- "es-ES-carla",
309
- "en-US-claire",
310
- "ko-KR-jangmi",
311
- "ko-KR-sanghoon",
312
- "it-IT-vera",
313
- "hi-IN-rahul",
314
- "es-ES-elvira",
315
- "es-ES-enrique",
316
- "en-UK-aiden",
317
- "en-US-ronnie",
318
- "en-UK-amber",
319
- "hi-IN-shweta",
320
- "hi-IN-amit",
321
- "en-AU-jimm",
322
- "en-UK-pearl",
323
- "pt-BR-ben\xEDcio",
324
- "en-UK-freddie",
325
- "en-US-ryan",
326
- "pt-BR-eloa",
327
- "en-US-charlotte",
328
- "de-DE-lia",
329
- "en-US-natalie",
330
- "en-US-michelle",
331
- "en-US-phoebe",
332
- "es-ES-carmen",
333
- "en-US-caleb",
334
- "en-US-iris",
335
- "en-UK-harrison",
336
- "en-US-marcus",
337
- "en-US-josie",
338
- "en-US-daisy",
339
- "en-US-charles",
340
- "en-UK-reggie",
341
- "en-US-julia",
342
- "en-SCOTT-emily",
343
- "en-US-dylan",
344
- "es-MX-valeria",
345
- "en-IN-eashwar",
346
- "en-AU-evelyn",
347
- "de-DE-lara",
348
- "en-US-evander",
349
- "en-SCOTT-rory",
350
- "ta-IN-iniya",
351
- "en-AU-leyton",
352
- "fr-FR-louise",
353
- "zh-CN-wei",
354
- "ko-KR-gyeong",
355
- "de-DE-matthias",
356
- "en-IN-rohan",
357
- "en-US-delilah",
358
- "bn-IN-abhik",
359
- "en-US-angela",
360
- "en-US-naomi",
361
- "es-MX-carlos",
362
- "nl-NL-merel",
363
- "en-US-alicia",
364
- "en-IN-alia",
365
- "zh-CN-jiao",
366
- "en-US-june",
367
- "en-AU-ashton",
368
- "en-UK-finley",
369
- "pl-PL-blazej",
370
- "zh-CN-zhang",
371
- "en-AU-kylie",
372
- "en-US-jayden",
373
- "en-IN-aarav",
374
- "de-DE-bj\xF6rn",
375
- "bn-IN-ishani",
376
- "zh-CN-yuxan",
377
- "fr-FR-louis",
378
- "ko-KR-jong-su",
379
- "en-AU-harper",
380
- "en-UK-ruby",
381
- "en-US-ken",
382
- "ta-IN-mani",
383
- "de-DE-ralf",
384
- "en-UK-jaxon",
385
- "en-US-river",
386
- "en-IN-priya",
387
- "en-UK-theo",
388
- "en-UK-katie",
389
- "pl-PL-jacek",
390
- "it-IT-lorenzo",
391
- "hi-IN-shaan",
392
- "en-US-amara",
393
- "en-UK-mason",
394
- "en-IN-surya",
395
- "en-US-finn",
396
- "pt-BR-gustavo",
397
- "hi-IN-kabir",
398
- "es-ES-javier",
399
- "en-AU-mitch",
400
- "pt-BR-heitor",
401
- "en-US-edmund",
402
- "hi-IN-ayushi",
403
- "pl-PL-kasia",
404
- "es-MX-luisa",
405
- "zh-CN-tao",
406
- "en-US-molly"
376
+ //#endregion
377
+ //#region src/voices.ts
378
+ /**
379
+ * List of available voices for Murf TTS
380
+ */
381
+ const MURF_VOICES = [
382
+ "en-UK-hazel",
383
+ "en-US-cooper",
384
+ "en-US-imani",
385
+ "it-IT-giorgio",
386
+ "en-US-wayne",
387
+ "en-IN-shivani",
388
+ "en-US-daniel",
389
+ "bn-IN-anwesha",
390
+ "es-MX-alejandro",
391
+ "en-AU-joyce",
392
+ "en-US-zion",
393
+ "en-IN-isha",
394
+ "en-US-riley",
395
+ "ko-KR-hwan",
396
+ "fr-FR-adélie",
397
+ "en-US-carter",
398
+ "en-UK-gabriel",
399
+ "en-UK-juliet",
400
+ "en-IN-arohi",
401
+ "fr-FR-maxime",
402
+ "de-DE-josephine",
403
+ "en-UK-hugo",
404
+ "en-US-samantha",
405
+ "de-DE-erna",
406
+ "zh-CN-baolin",
407
+ "pt-BR-isadora",
408
+ "it-IT-vincenzo",
409
+ "en-US-terrell",
410
+ "en-US-denzel",
411
+ "en-UK-heidi",
412
+ "en-US-miles",
413
+ "en-US-abigail",
414
+ "fr-FR-justine",
415
+ "it-IT-greta",
416
+ "en-AU-shane",
417
+ "en-UK-peter",
418
+ "nl-NL-famke",
419
+ "en-AU-ivy",
420
+ "nl-NL-dirk",
421
+ "fr-FR-axel",
422
+ "es-ES-carla",
423
+ "en-US-claire",
424
+ "ko-KR-jangmi",
425
+ "ko-KR-sanghoon",
426
+ "it-IT-vera",
427
+ "hi-IN-rahul",
428
+ "es-ES-elvira",
429
+ "es-ES-enrique",
430
+ "en-UK-aiden",
431
+ "en-US-ronnie",
432
+ "en-UK-amber",
433
+ "hi-IN-shweta",
434
+ "hi-IN-amit",
435
+ "en-AU-jimm",
436
+ "en-UK-pearl",
437
+ "pt-BR-benício",
438
+ "en-UK-freddie",
439
+ "en-US-ryan",
440
+ "pt-BR-eloa",
441
+ "en-US-charlotte",
442
+ "de-DE-lia",
443
+ "en-US-natalie",
444
+ "en-US-michelle",
445
+ "en-US-phoebe",
446
+ "es-ES-carmen",
447
+ "en-US-caleb",
448
+ "en-US-iris",
449
+ "en-UK-harrison",
450
+ "en-US-marcus",
451
+ "en-US-josie",
452
+ "en-US-daisy",
453
+ "en-US-charles",
454
+ "en-UK-reggie",
455
+ "en-US-julia",
456
+ "en-SCOTT-emily",
457
+ "en-US-dylan",
458
+ "es-MX-valeria",
459
+ "en-IN-eashwar",
460
+ "en-AU-evelyn",
461
+ "de-DE-lara",
462
+ "en-US-evander",
463
+ "en-SCOTT-rory",
464
+ "ta-IN-iniya",
465
+ "en-AU-leyton",
466
+ "fr-FR-louise",
467
+ "zh-CN-wei",
468
+ "ko-KR-gyeong",
469
+ "de-DE-matthias",
470
+ "en-IN-rohan",
471
+ "en-US-delilah",
472
+ "bn-IN-abhik",
473
+ "en-US-angela",
474
+ "en-US-naomi",
475
+ "es-MX-carlos",
476
+ "nl-NL-merel",
477
+ "en-US-alicia",
478
+ "en-IN-alia",
479
+ "zh-CN-jiao",
480
+ "en-US-june",
481
+ "en-AU-ashton",
482
+ "en-UK-finley",
483
+ "pl-PL-blazej",
484
+ "zh-CN-zhang",
485
+ "en-AU-kylie",
486
+ "en-US-jayden",
487
+ "en-IN-aarav",
488
+ "de-DE-björn",
489
+ "bn-IN-ishani",
490
+ "zh-CN-yuxan",
491
+ "fr-FR-louis",
492
+ "ko-KR-jong-su",
493
+ "en-AU-harper",
494
+ "en-UK-ruby",
495
+ "en-US-ken",
496
+ "ta-IN-mani",
497
+ "de-DE-ralf",
498
+ "en-UK-jaxon",
499
+ "en-US-river",
500
+ "en-IN-priya",
501
+ "en-UK-theo",
502
+ "en-UK-katie",
503
+ "pl-PL-jacek",
504
+ "it-IT-lorenzo",
505
+ "hi-IN-shaan",
506
+ "en-US-amara",
507
+ "en-UK-mason",
508
+ "en-IN-surya",
509
+ "en-US-finn",
510
+ "pt-BR-gustavo",
511
+ "hi-IN-kabir",
512
+ "es-ES-javier",
513
+ "en-AU-mitch",
514
+ "pt-BR-heitor",
515
+ "en-US-edmund",
516
+ "hi-IN-ayushi",
517
+ "pl-PL-kasia",
518
+ "es-MX-luisa",
519
+ "zh-CN-tao",
520
+ "en-US-molly"
407
521
  ];
408
-
409
- // src/index.ts
410
- var DEFAULT_RETRY_COUNT = 2;
411
- var RETRY_STATUS_CODES = /* @__PURE__ */ new Set([408, 413, 429, 500, 502, 503, 504]);
412
- var RETRY_DELAY_MS = 300;
522
+ //#endregion
523
+ //#region src/index.ts
524
+ const DEFAULT_RETRY_COUNT = 2;
525
+ const RETRY_STATUS_CODES = /* @__PURE__ */ new Set([
526
+ 408,
527
+ 413,
528
+ 429,
529
+ 500,
530
+ 502,
531
+ 503,
532
+ 504
533
+ ]);
534
+ const RETRY_DELAY_MS = 300;
413
535
  var MurfVoice = class extends MastraVoice {
414
- baseUrl = "https://api.murf.ai";
415
- apiKey;
416
- defaultVoice;
417
- properties;
418
- constructor({ speechModel, speaker } = {}) {
419
- super({
420
- speechModel: {
421
- name: speechModel?.name ?? "GEN2",
422
- apiKey: speechModel?.apiKey ?? process.env.MURF_API_KEY
423
- },
424
- speaker: speaker ?? MURF_VOICES[0]
425
- });
426
- const apiKey = this.speechModel?.apiKey;
427
- if (!apiKey) {
428
- throw new Error("MURF_API_KEY is not set");
429
- }
430
- this.apiKey = apiKey;
431
- this.properties = {
432
- ...speechModel?.properties
433
- };
434
- this.defaultVoice = speaker ?? MURF_VOICES[0];
435
- }
436
- async streamToString(stream) {
437
- const chunks = [];
438
- for await (const chunk of stream) {
439
- if (typeof chunk === "string") {
440
- chunks.push(Buffer.from(chunk));
441
- } else {
442
- chunks.push(chunk);
443
- }
444
- }
445
- return Buffer.concat(chunks).toString("utf-8");
446
- }
447
- async speak(input, options) {
448
- const text = typeof input === "string" ? input : await this.streamToString(input);
449
- const response = await this.makeRequest("/v1/speech/generate", {
450
- voiceId: options?.speaker || this.defaultVoice,
451
- text,
452
- modelVersion: this.speechModel?.name,
453
- ...this.properties,
454
- ...options?.properties
455
- });
456
- const stream$1 = new stream.PassThrough();
457
- const audioResponse = await fetch(response.audioFile);
458
- if (!audioResponse.body) {
459
- throw new Error("No response body received");
460
- }
461
- const reader = audioResponse.body.getReader();
462
- (async () => {
463
- try {
464
- while (true) {
465
- const { done, value } = await reader.read();
466
- if (done) {
467
- stream$1.end();
468
- break;
469
- }
470
- stream$1.write(value);
471
- }
472
- } catch (error) {
473
- stream$1.destroy(error);
474
- }
475
- })().catch((error) => {
476
- stream$1.destroy(error);
477
- });
478
- return stream$1;
479
- }
480
- /**
481
- * Checks if listening capabilities are enabled.
482
- *
483
- * @returns {Promise<{ enabled: boolean }>}
484
- */
485
- async getListener() {
486
- return { enabled: false };
487
- }
488
- async listen(_input, _options) {
489
- throw new Error("Murf does not support speech recognition");
490
- }
491
- async makeRequest(endpoint, payload) {
492
- let lastError;
493
- for (let attempt = 0; attempt <= DEFAULT_RETRY_COUNT; attempt++) {
494
- if (attempt > 0) {
495
- await new Promise((resolve) => setTimeout(resolve, RETRY_DELAY_MS * 2 ** (attempt - 1)));
496
- }
497
- const res = await fetch(`${this.baseUrl}${endpoint}`, {
498
- method: "POST",
499
- headers: {
500
- "api-key": this.apiKey,
501
- "Content-Type": "application/json"
502
- },
503
- body: JSON.stringify(payload)
504
- });
505
- if (res.ok) {
506
- return await res.json();
507
- }
508
- if (!RETRY_STATUS_CODES.has(res.status) || attempt === DEFAULT_RETRY_COUNT) {
509
- let errorMessage;
510
- try {
511
- const error = await res.json();
512
- errorMessage = error.message || res.statusText;
513
- } catch {
514
- errorMessage = res.statusText;
515
- }
516
- throw new Error(`Murf API Error: ${errorMessage}`);
517
- }
518
- lastError = new Error(`Murf API Error: ${res.statusText}`);
519
- }
520
- throw lastError ?? new Error("Murf API Error: request failed");
521
- }
522
- async getSpeakers() {
523
- return MURF_VOICES.map((voice) => ({
524
- voiceId: voice,
525
- name: voice,
526
- language: voice.split("-")[0],
527
- gender: "neutral"
528
- }));
529
- }
536
+ baseUrl = "https://api.murf.ai";
537
+ apiKey;
538
+ defaultVoice;
539
+ properties;
540
+ constructor({ speechModel, speaker } = {}) {
541
+ super({
542
+ speechModel: {
543
+ name: speechModel?.name ?? "GEN2",
544
+ apiKey: speechModel?.apiKey ?? process.env.MURF_API_KEY
545
+ },
546
+ speaker: speaker ?? MURF_VOICES[0]
547
+ });
548
+ const apiKey = this.speechModel?.apiKey;
549
+ if (!apiKey) throw new Error("MURF_API_KEY is not set");
550
+ this.apiKey = apiKey;
551
+ this.properties = { ...speechModel?.properties };
552
+ this.defaultVoice = speaker ?? MURF_VOICES[0];
553
+ }
554
+ async streamToString(stream$1) {
555
+ const chunks = [];
556
+ for await (const chunk of stream$1) if (typeof chunk === "string") chunks.push(Buffer.from(chunk));
557
+ else chunks.push(chunk);
558
+ return Buffer.concat(chunks).toString("utf-8");
559
+ }
560
+ async speak(input, options) {
561
+ const text = typeof input === "string" ? input : await this.streamToString(input);
562
+ const response = await this.makeRequest("/v1/speech/generate", {
563
+ voiceId: options?.speaker || this.defaultVoice,
564
+ text,
565
+ modelVersion: this.speechModel?.name,
566
+ ...this.properties,
567
+ ...options?.properties
568
+ });
569
+ const stream$2 = new stream.PassThrough();
570
+ const audioResponse = await fetch(response.audioFile);
571
+ if (!audioResponse.body) throw new Error("No response body received");
572
+ const reader = audioResponse.body.getReader();
573
+ (async () => {
574
+ try {
575
+ while (true) {
576
+ const { done, value } = await reader.read();
577
+ if (done) {
578
+ stream$2.end();
579
+ break;
580
+ }
581
+ stream$2.write(value);
582
+ }
583
+ } catch (error) {
584
+ stream$2.destroy(error);
585
+ }
586
+ })().catch((error) => {
587
+ stream$2.destroy(error);
588
+ });
589
+ return stream$2;
590
+ }
591
+ /**
592
+ * Checks if listening capabilities are enabled.
593
+ *
594
+ * @returns {Promise<{ enabled: boolean }>}
595
+ */
596
+ async getListener() {
597
+ return { enabled: false };
598
+ }
599
+ async listen(_input, _options) {
600
+ throw new Error("Murf does not support speech recognition");
601
+ }
602
+ async makeRequest(endpoint, payload) {
603
+ let lastError;
604
+ for (let attempt = 0; attempt <= DEFAULT_RETRY_COUNT; attempt++) {
605
+ if (attempt > 0) await new Promise((resolve) => setTimeout(resolve, RETRY_DELAY_MS * 2 ** (attempt - 1)));
606
+ const res = await fetch(`${this.baseUrl}${endpoint}`, {
607
+ method: "POST",
608
+ headers: {
609
+ "api-key": this.apiKey,
610
+ "Content-Type": "application/json"
611
+ },
612
+ body: JSON.stringify(payload)
613
+ });
614
+ if (res.ok) return await res.json();
615
+ if (!RETRY_STATUS_CODES.has(res.status) || attempt === DEFAULT_RETRY_COUNT) {
616
+ let errorMessage;
617
+ try {
618
+ errorMessage = (await res.json()).message || res.statusText;
619
+ } catch {
620
+ errorMessage = res.statusText;
621
+ }
622
+ throw new Error(`Murf API Error: ${errorMessage}`);
623
+ }
624
+ lastError = /* @__PURE__ */ new Error(`Murf API Error: ${res.statusText}`);
625
+ }
626
+ throw lastError ?? /* @__PURE__ */ new Error("Murf API Error: request failed");
627
+ }
628
+ async getSpeakers() {
629
+ return MURF_VOICES.map((voice) => ({
630
+ voiceId: voice,
631
+ name: voice,
632
+ language: voice.split("-")[0],
633
+ gender: "neutral"
634
+ }));
635
+ }
530
636
  };
531
-
637
+ //#endregion
532
638
  exports.MurfVoice = MurfVoice;
533
- //# sourceMappingURL=index.cjs.map
639
+
534
640
  //# sourceMappingURL=index.cjs.map