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