@mastra/voice-murf 0.1.3-alpha.9 → 0.1.3
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 +5 -1
- package/dist/index.js +5 -1
- package/package.json +15 -12
- package/.turbo/turbo-build.log +0 -23
- package/CHANGELOG.md +0 -246
- package/eslint.config.js +0 -6
- package/src/index.test.ts +0 -96
- package/src/index.ts +0 -160
- package/src/voices.ts +0 -146
- package/tsconfig.json +0 -5
- package/vitest.config.ts +0 -8
package/dist/index.cjs
CHANGED
|
@@ -184,7 +184,11 @@ var MurfVoice = class extends voice.MastraVoice {
|
|
|
184
184
|
async streamToString(stream) {
|
|
185
185
|
const chunks = [];
|
|
186
186
|
for await (const chunk of stream) {
|
|
187
|
-
|
|
187
|
+
if (typeof chunk === "string") {
|
|
188
|
+
chunks.push(Buffer.from(chunk));
|
|
189
|
+
} else {
|
|
190
|
+
chunks.push(chunk);
|
|
191
|
+
}
|
|
188
192
|
}
|
|
189
193
|
return Buffer.concat(chunks).toString("utf-8");
|
|
190
194
|
}
|
package/dist/index.js
CHANGED
|
@@ -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
|
-
|
|
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.1.3
|
|
3
|
+
"version": "0.1.3",
|
|
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": {
|
|
@@ -19,21 +22,21 @@
|
|
|
19
22
|
"./package.json": "./package.json"
|
|
20
23
|
},
|
|
21
24
|
"dependencies": {
|
|
22
|
-
"ky": "^1.7.
|
|
23
|
-
"zod": "^3.24.
|
|
24
|
-
"@mastra/core": "^0.5.0
|
|
25
|
+
"ky": "^1.7.5",
|
|
26
|
+
"zod": "^3.24.2",
|
|
27
|
+
"@mastra/core": "^0.5.0"
|
|
25
28
|
},
|
|
26
29
|
"devDependencies": {
|
|
27
|
-
"@microsoft/api-extractor": "^7.
|
|
28
|
-
"@types/node": "^22.13.
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"vitest": "^2.1.
|
|
33
|
-
"@internal/lint": "0.0.
|
|
30
|
+
"@microsoft/api-extractor": "^7.52.1",
|
|
31
|
+
"@types/node": "^22.13.10",
|
|
32
|
+
"eslint": "^9.22.0",
|
|
33
|
+
"tsup": "^8.4.0",
|
|
34
|
+
"typescript": "^5.8.2",
|
|
35
|
+
"vitest": "^2.1.9",
|
|
36
|
+
"@internal/lint": "0.0.1"
|
|
34
37
|
},
|
|
35
38
|
"scripts": {
|
|
36
|
-
"build": "tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake",
|
|
39
|
+
"build": "tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake=smallest --splitting",
|
|
37
40
|
"build:watch": "pnpm build --watch",
|
|
38
41
|
"test": "vitest run",
|
|
39
42
|
"lint": "eslint ."
|
package/.turbo/turbo-build.log
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
> @mastra/voice-murf@0.1.3-alpha.9 build /home/runner/work/mastra/mastra/voice/murf
|
|
3
|
-
> tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake
|
|
4
|
-
|
|
5
|
-
[34mCLI[39m Building entry: src/index.ts
|
|
6
|
-
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
7
|
-
[34mCLI[39m tsup v8.3.6
|
|
8
|
-
[34mTSC[39m Build start
|
|
9
|
-
[32mTSC[39m ⚡️ Build success in 7440ms
|
|
10
|
-
[34mDTS[39m Build start
|
|
11
|
-
[34mCLI[39m Target: es2022
|
|
12
|
-
Analysis will use the bundled TypeScript version 5.7.3
|
|
13
|
-
[36mWriting package typings: /home/runner/work/mastra/mastra/voice/murf/dist/_tsup-dts-rollup.d.ts[39m
|
|
14
|
-
Analysis will use the bundled TypeScript version 5.7.3
|
|
15
|
-
[36mWriting package typings: /home/runner/work/mastra/mastra/voice/murf/dist/_tsup-dts-rollup.d.cts[39m
|
|
16
|
-
[32mDTS[39m ⚡️ Build success in 8521ms
|
|
17
|
-
[34mCLI[39m Cleaning output folder
|
|
18
|
-
[34mESM[39m Build start
|
|
19
|
-
[34mCJS[39m Build start
|
|
20
|
-
[32mESM[39m [1mdist/index.js [22m[32m4.95 KB[39m
|
|
21
|
-
[32mESM[39m ⚡️ Build success in 396ms
|
|
22
|
-
[32mCJS[39m [1mdist/index.cjs [22m[32m5.13 KB[39m
|
|
23
|
-
[32mCJS[39m ⚡️ Build success in 397ms
|
package/CHANGELOG.md
DELETED
|
@@ -1,246 +0,0 @@
|
|
|
1
|
-
# @mastra/voice-murf
|
|
2
|
-
|
|
3
|
-
## 0.1.3-alpha.9
|
|
4
|
-
|
|
5
|
-
### Patch Changes
|
|
6
|
-
|
|
7
|
-
- Updated dependencies [e9fbac5]
|
|
8
|
-
- Updated dependencies [1e8bcbc]
|
|
9
|
-
- Updated dependencies [aeb5e36]
|
|
10
|
-
- Updated dependencies [f2301de]
|
|
11
|
-
- @mastra/core@0.5.0-alpha.9
|
|
12
|
-
|
|
13
|
-
## 0.1.3-alpha.8
|
|
14
|
-
|
|
15
|
-
### Patch Changes
|
|
16
|
-
|
|
17
|
-
- Updated dependencies [506f1d5]
|
|
18
|
-
- @mastra/core@0.5.0-alpha.8
|
|
19
|
-
|
|
20
|
-
## 0.1.3-alpha.7
|
|
21
|
-
|
|
22
|
-
### Patch Changes
|
|
23
|
-
|
|
24
|
-
- Updated dependencies [ee667a2]
|
|
25
|
-
- @mastra/core@0.5.0-alpha.7
|
|
26
|
-
|
|
27
|
-
## 0.1.3-alpha.6
|
|
28
|
-
|
|
29
|
-
### Patch Changes
|
|
30
|
-
|
|
31
|
-
- Updated dependencies [f6678e4]
|
|
32
|
-
- @mastra/core@0.5.0-alpha.6
|
|
33
|
-
|
|
34
|
-
## 0.1.3-alpha.5
|
|
35
|
-
|
|
36
|
-
### Patch Changes
|
|
37
|
-
|
|
38
|
-
- Updated dependencies [22643eb]
|
|
39
|
-
- Updated dependencies [6feb23f]
|
|
40
|
-
- Updated dependencies [f2d6727]
|
|
41
|
-
- Updated dependencies [301e4ee]
|
|
42
|
-
- Updated dependencies [dfbe4e9]
|
|
43
|
-
- Updated dependencies [9e81f35]
|
|
44
|
-
- Updated dependencies [caefaa2]
|
|
45
|
-
- Updated dependencies [c151ae6]
|
|
46
|
-
- Updated dependencies [52e0418]
|
|
47
|
-
- Updated dependencies [03236ec]
|
|
48
|
-
- Updated dependencies [3764e71]
|
|
49
|
-
- Updated dependencies [df982db]
|
|
50
|
-
- Updated dependencies [0461849]
|
|
51
|
-
- Updated dependencies [2259379]
|
|
52
|
-
- Updated dependencies [358f069]
|
|
53
|
-
- @mastra/core@0.5.0-alpha.5
|
|
54
|
-
|
|
55
|
-
## 0.1.3-alpha.4
|
|
56
|
-
|
|
57
|
-
### Patch Changes
|
|
58
|
-
|
|
59
|
-
- Updated dependencies [d79aedf]
|
|
60
|
-
- @mastra/core@0.5.0-alpha.4
|
|
61
|
-
|
|
62
|
-
## 0.1.3-alpha.3
|
|
63
|
-
|
|
64
|
-
### Patch Changes
|
|
65
|
-
|
|
66
|
-
- Updated dependencies [3d0e290]
|
|
67
|
-
- @mastra/core@0.5.0-alpha.3
|
|
68
|
-
|
|
69
|
-
## 0.1.3-alpha.2
|
|
70
|
-
|
|
71
|
-
### Patch Changes
|
|
72
|
-
|
|
73
|
-
- Updated dependencies [02ffb7b]
|
|
74
|
-
- @mastra/core@0.5.0-alpha.2
|
|
75
|
-
|
|
76
|
-
## 0.1.3-alpha.1
|
|
77
|
-
|
|
78
|
-
### Patch Changes
|
|
79
|
-
|
|
80
|
-
- Updated dependencies [dab255b]
|
|
81
|
-
- @mastra/core@0.5.0-alpha.1
|
|
82
|
-
|
|
83
|
-
## 0.1.3-alpha.0
|
|
84
|
-
|
|
85
|
-
### Patch Changes
|
|
86
|
-
|
|
87
|
-
- Updated dependencies [59df7b6]
|
|
88
|
-
- Updated dependencies [29f3a82]
|
|
89
|
-
- Updated dependencies [59df7b6]
|
|
90
|
-
- Updated dependencies [c139344]
|
|
91
|
-
- @mastra/core@0.5.0-alpha.0
|
|
92
|
-
|
|
93
|
-
## 0.1.2
|
|
94
|
-
|
|
95
|
-
### Patch Changes
|
|
96
|
-
|
|
97
|
-
- Updated dependencies [1da20e7]
|
|
98
|
-
- @mastra/core@0.4.4
|
|
99
|
-
|
|
100
|
-
## 0.1.2-alpha.0
|
|
101
|
-
|
|
102
|
-
### Patch Changes
|
|
103
|
-
|
|
104
|
-
- Updated dependencies [1da20e7]
|
|
105
|
-
- @mastra/core@0.4.4-alpha.0
|
|
106
|
-
|
|
107
|
-
## 0.1.1
|
|
108
|
-
|
|
109
|
-
### Patch Changes
|
|
110
|
-
|
|
111
|
-
- bb4f447: Add support for commonjs
|
|
112
|
-
- Updated dependencies [0d185b1]
|
|
113
|
-
- Updated dependencies [ed55f1d]
|
|
114
|
-
- Updated dependencies [06aa827]
|
|
115
|
-
- Updated dependencies [0fd78ac]
|
|
116
|
-
- Updated dependencies [2512a93]
|
|
117
|
-
- Updated dependencies [e62de74]
|
|
118
|
-
- Updated dependencies [0d25b75]
|
|
119
|
-
- Updated dependencies [fd14a3f]
|
|
120
|
-
- Updated dependencies [8d13b14]
|
|
121
|
-
- Updated dependencies [3f369a2]
|
|
122
|
-
- Updated dependencies [3ee4831]
|
|
123
|
-
- Updated dependencies [4d4e1e1]
|
|
124
|
-
- Updated dependencies [bb4f447]
|
|
125
|
-
- Updated dependencies [108793c]
|
|
126
|
-
- Updated dependencies [5f28f44]
|
|
127
|
-
- Updated dependencies [dabecf4]
|
|
128
|
-
- @mastra/core@0.4.3
|
|
129
|
-
|
|
130
|
-
## 0.1.1-alpha.4
|
|
131
|
-
|
|
132
|
-
### Patch Changes
|
|
133
|
-
|
|
134
|
-
- Updated dependencies [dabecf4]
|
|
135
|
-
- @mastra/core@0.4.3-alpha.4
|
|
136
|
-
|
|
137
|
-
## 0.1.1-alpha.3
|
|
138
|
-
|
|
139
|
-
### Patch Changes
|
|
140
|
-
|
|
141
|
-
- bb4f447: Add support for commonjs
|
|
142
|
-
- Updated dependencies [0fd78ac]
|
|
143
|
-
- Updated dependencies [0d25b75]
|
|
144
|
-
- Updated dependencies [fd14a3f]
|
|
145
|
-
- Updated dependencies [3f369a2]
|
|
146
|
-
- Updated dependencies [4d4e1e1]
|
|
147
|
-
- Updated dependencies [bb4f447]
|
|
148
|
-
- @mastra/core@0.4.3-alpha.3
|
|
149
|
-
|
|
150
|
-
## 0.1.1-alpha.2
|
|
151
|
-
|
|
152
|
-
### Patch Changes
|
|
153
|
-
|
|
154
|
-
- Updated dependencies [2512a93]
|
|
155
|
-
- Updated dependencies [e62de74]
|
|
156
|
-
- @mastra/core@0.4.3-alpha.2
|
|
157
|
-
|
|
158
|
-
## 0.1.1-alpha.1
|
|
159
|
-
|
|
160
|
-
### Patch Changes
|
|
161
|
-
|
|
162
|
-
- Updated dependencies [0d185b1]
|
|
163
|
-
- Updated dependencies [ed55f1d]
|
|
164
|
-
- Updated dependencies [8d13b14]
|
|
165
|
-
- Updated dependencies [3ee4831]
|
|
166
|
-
- Updated dependencies [108793c]
|
|
167
|
-
- Updated dependencies [5f28f44]
|
|
168
|
-
- @mastra/core@0.4.3-alpha.1
|
|
169
|
-
|
|
170
|
-
## 0.1.1-alpha.0
|
|
171
|
-
|
|
172
|
-
### Patch Changes
|
|
173
|
-
|
|
174
|
-
- Updated dependencies [06aa827]
|
|
175
|
-
- @mastra/core@0.4.3-alpha.0
|
|
176
|
-
|
|
177
|
-
## 0.1.0
|
|
178
|
-
|
|
179
|
-
### Patch Changes
|
|
180
|
-
|
|
181
|
-
- 5b1af96: deprecate @mastra/speech-murf for @mastra/voice-murf
|
|
182
|
-
- Updated dependencies [7fceae1]
|
|
183
|
-
- Updated dependencies [8d94c3e]
|
|
184
|
-
- Updated dependencies [99dcdb5]
|
|
185
|
-
- Updated dependencies [6cb63e0]
|
|
186
|
-
- Updated dependencies [f626fbb]
|
|
187
|
-
- Updated dependencies [e752340]
|
|
188
|
-
- Updated dependencies [eb91535]
|
|
189
|
-
- @mastra/core@0.4.2
|
|
190
|
-
|
|
191
|
-
## 0.1.0-alpha.4
|
|
192
|
-
|
|
193
|
-
### Patch Changes
|
|
194
|
-
|
|
195
|
-
- Updated dependencies [8d94c3e]
|
|
196
|
-
- Updated dependencies [99dcdb5]
|
|
197
|
-
- Updated dependencies [e752340]
|
|
198
|
-
- Updated dependencies [eb91535]
|
|
199
|
-
- @mastra/core@0.4.2-alpha.2
|
|
200
|
-
|
|
201
|
-
## 0.1.0-alpha.3
|
|
202
|
-
|
|
203
|
-
### Patch Changes
|
|
204
|
-
|
|
205
|
-
- Updated dependencies [6cb63e0]
|
|
206
|
-
- @mastra/core@0.4.2-alpha.1
|
|
207
|
-
|
|
208
|
-
## 0.1.0-alpha.2
|
|
209
|
-
|
|
210
|
-
### Patch Changes
|
|
211
|
-
|
|
212
|
-
- 5b1af96: deprecate @mastra/speech-murf for @mastra/voice-murf
|
|
213
|
-
|
|
214
|
-
## 0.1.0 (2024-XX-XX)
|
|
215
|
-
|
|
216
|
-
This package replaces the deprecated @mastra/speech-murf package. All functionality has been migrated to this new package with a more consistent naming scheme.
|
|
217
|
-
|
|
218
|
-
### Changes from @mastra/speech-murf
|
|
219
|
-
|
|
220
|
-
- Package renamed from @mastra/speech-murf to @mastra/voice-murf
|
|
221
|
-
- API changes:
|
|
222
|
-
- `MurfTTS` class renamed to `MurfVoice`
|
|
223
|
-
- `generate()` and `stream()` methods combined into `speak()`
|
|
224
|
-
- `voices()` method renamed to `getSpeakers()`
|
|
225
|
-
- Constructor configuration simplified
|
|
226
|
-
- Added support for text stream input
|
|
227
|
-
- Default speaker configuration added
|
|
228
|
-
- All core functionality remains the same
|
|
229
|
-
- Import paths should be updated from '@mastra/speech-murf' to '@mastra/voice-murf'
|
|
230
|
-
|
|
231
|
-
### Key Features Preserved
|
|
232
|
-
|
|
233
|
-
- High-quality voice synthesis
|
|
234
|
-
- Multiple voice options with rich metadata
|
|
235
|
-
- Streaming support
|
|
236
|
-
- Natural and expressive speech output
|
|
237
|
-
- Voice customization options including:
|
|
238
|
-
- Style control
|
|
239
|
-
- Rate adjustment
|
|
240
|
-
- Pitch modification
|
|
241
|
-
- Sample rate selection
|
|
242
|
-
- Audio format options
|
|
243
|
-
- Channel type selection
|
|
244
|
-
- Pronunciation dictionary support
|
|
245
|
-
|
|
246
|
-
For a complete history of changes prior to the rename, please see the changelog of the original package.
|
package/eslint.config.js
DELETED
package/src/index.test.ts
DELETED
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import { mkdirSync } from 'fs';
|
|
2
|
-
import { writeFile, stat as fsStat } from 'fs/promises';
|
|
3
|
-
import path, { join } from 'path';
|
|
4
|
-
import { Readable } from 'stream';
|
|
5
|
-
import { describe, expect, it, beforeAll } from 'vitest';
|
|
6
|
-
|
|
7
|
-
import { MurfVoice } from './index';
|
|
8
|
-
|
|
9
|
-
describe('MurfVoice', () => {
|
|
10
|
-
const voice = new MurfVoice({
|
|
11
|
-
speechModel: {
|
|
12
|
-
name: 'GEN2',
|
|
13
|
-
},
|
|
14
|
-
speaker: 'en-US-natalie',
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
const outputDir = path.join(process.cwd(), 'test-outputs');
|
|
18
|
-
beforeAll(() => {
|
|
19
|
-
// Create output directory if it doesn't exist
|
|
20
|
-
try {
|
|
21
|
-
mkdirSync(outputDir, { recursive: true });
|
|
22
|
-
} catch (err) {
|
|
23
|
-
console.error(`Failed to create output directory: ${err}`);
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
it('should list available speakers', async () => {
|
|
28
|
-
const speakers = await voice.getSpeakers();
|
|
29
|
-
expect(speakers.length).toBeGreaterThan(0);
|
|
30
|
-
expect(speakers[0]).toHaveProperty('voiceId');
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
it('should generate audio from text', async () => {
|
|
34
|
-
const audioStream = await voice.speak('Hello world!!!');
|
|
35
|
-
expect(audioStream).toHaveProperty('pipe');
|
|
36
|
-
|
|
37
|
-
// Collect the audio data
|
|
38
|
-
const chunks: Buffer[] = [];
|
|
39
|
-
for await (const chunk of audioStream) {
|
|
40
|
-
chunks.push(Buffer.from(chunk));
|
|
41
|
-
}
|
|
42
|
-
const audioBuffer = Buffer.concat(chunks);
|
|
43
|
-
expect(audioBuffer.length).toBeGreaterThan(0);
|
|
44
|
-
|
|
45
|
-
// Write the audio to a file
|
|
46
|
-
const outputPath = join(outputDir, 'test-audio.mp3');
|
|
47
|
-
await writeFile(outputPath, audioBuffer);
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
it('should handle stream input', async () => {
|
|
51
|
-
// Create a readable stream from text
|
|
52
|
-
const textStream = Readable.from(['Hello', ' from', ' stream', ' input!']);
|
|
53
|
-
|
|
54
|
-
const audioStream = await voice.speak(textStream);
|
|
55
|
-
expect(audioStream).toHaveProperty('pipe');
|
|
56
|
-
|
|
57
|
-
// Write the audio to a file using pipe
|
|
58
|
-
const outputPath = join(outputDir, 'test-audio-stream.mp3');
|
|
59
|
-
|
|
60
|
-
const chunks: Buffer[] = [];
|
|
61
|
-
for await (const chunk of audioStream) {
|
|
62
|
-
chunks.push(Buffer.from(chunk));
|
|
63
|
-
}
|
|
64
|
-
const audioBuffer = Buffer.concat(chunks);
|
|
65
|
-
await writeFile(outputPath, audioBuffer);
|
|
66
|
-
const stats = await fsStat(outputPath);
|
|
67
|
-
expect(stats.size).toBeGreaterThan(0);
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
it('should work with default configuration', async () => {
|
|
71
|
-
// Create instance with no args
|
|
72
|
-
const defaultVoice = new MurfVoice();
|
|
73
|
-
|
|
74
|
-
// Should use default model name and get API key from env
|
|
75
|
-
const audioStream = await defaultVoice.speak('Testing default configuration');
|
|
76
|
-
expect(audioStream).toHaveProperty('pipe');
|
|
77
|
-
|
|
78
|
-
const chunks: Buffer[] = [];
|
|
79
|
-
for await (const chunk of audioStream) {
|
|
80
|
-
chunks.push(Buffer.from(chunk));
|
|
81
|
-
}
|
|
82
|
-
const audioBuffer = Buffer.concat(chunks);
|
|
83
|
-
|
|
84
|
-
await writeFile(join(outputDir, 'murf-default-config-output.mp3'), audioBuffer);
|
|
85
|
-
expect(audioBuffer.length).toBeGreaterThan(0);
|
|
86
|
-
|
|
87
|
-
// Verify default speaker was used
|
|
88
|
-
const speakers = await defaultVoice.getSpeakers();
|
|
89
|
-
expect(speakers.length).toBeGreaterThan(0);
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
it('should throw error for speech recognition', async () => {
|
|
93
|
-
const audioStream = Readable.from(Buffer.from('dummy audio data'));
|
|
94
|
-
await expect(voice.listen(audioStream)).rejects.toThrow('Murf does not support speech recognition');
|
|
95
|
-
});
|
|
96
|
-
});
|
package/src/index.ts
DELETED
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
import { PassThrough } from 'stream';
|
|
2
|
-
|
|
3
|
-
import { MastraVoice } from '@mastra/core/voice';
|
|
4
|
-
import ky from 'ky';
|
|
5
|
-
|
|
6
|
-
import { MURF_VOICES } from './voices';
|
|
7
|
-
import type { MurfVoiceId } from './voices';
|
|
8
|
-
|
|
9
|
-
type MurfConfig = {
|
|
10
|
-
name: 'GEN1' | 'GEN2';
|
|
11
|
-
apiKey?: string;
|
|
12
|
-
properties?: Omit<SpeechCreateParams, 'modelVersion' | 'voiceId' | 'text'>;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
type SpeechCreateParams = {
|
|
16
|
-
voiceId: MurfVoiceId;
|
|
17
|
-
text: string;
|
|
18
|
-
modelVersion: 'GEN1' | 'GEN2';
|
|
19
|
-
style?: string;
|
|
20
|
-
rate?: number;
|
|
21
|
-
pitch?: number;
|
|
22
|
-
sampleRate?: 8000 | 24000 | 44100 | 48000;
|
|
23
|
-
format?: 'MP3' | 'WAV' | 'FLAC' | 'ALAW' | 'ULAW';
|
|
24
|
-
channelType?: 'STEREO' | 'MONO';
|
|
25
|
-
pronunciationDictionary?: Record<string, string>;
|
|
26
|
-
encodeAsBase64?: boolean;
|
|
27
|
-
variation?: number;
|
|
28
|
-
audioDuration?: number;
|
|
29
|
-
multiNativeLocale?: string;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
type SpeechCreateResponse = {
|
|
33
|
-
audioFile: string;
|
|
34
|
-
audioLengthInSeconds: number;
|
|
35
|
-
consumedCharacterCount: number;
|
|
36
|
-
encodedAudio: string;
|
|
37
|
-
remainingCharacterCount: number;
|
|
38
|
-
warning: string;
|
|
39
|
-
wordDurations: {
|
|
40
|
-
endMs: number;
|
|
41
|
-
pitchScaleMaximum: number;
|
|
42
|
-
pitchScaleMinimum: number;
|
|
43
|
-
sourceWordIndex: number;
|
|
44
|
-
startMs: number;
|
|
45
|
-
word: string;
|
|
46
|
-
}[];
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
export class MurfVoice extends MastraVoice {
|
|
50
|
-
private client: typeof ky;
|
|
51
|
-
private defaultVoice: MurfVoiceId;
|
|
52
|
-
private properties: Omit<SpeechCreateParams, 'modelVersion' | 'voiceId' | 'text'>;
|
|
53
|
-
|
|
54
|
-
constructor({ speechModel, speaker }: { speechModel?: MurfConfig; speaker?: string } = {}) {
|
|
55
|
-
super({
|
|
56
|
-
speechModel: {
|
|
57
|
-
name: speechModel?.name ?? 'GEN2',
|
|
58
|
-
apiKey: speechModel?.apiKey ?? process.env.MURF_API_KEY,
|
|
59
|
-
},
|
|
60
|
-
speaker: speaker ?? MURF_VOICES[0],
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
const apiKey = this.speechModel?.apiKey;
|
|
64
|
-
if (!apiKey) {
|
|
65
|
-
throw new Error('MURF_API_KEY is not set');
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
this.properties = {
|
|
69
|
-
...speechModel?.properties,
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
this.client = ky.create({
|
|
73
|
-
prefixUrl: 'https://api.murf.ai',
|
|
74
|
-
headers: {
|
|
75
|
-
'api-key': apiKey,
|
|
76
|
-
},
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
this.defaultVoice = (speaker as MurfVoiceId) ?? MURF_VOICES[0];
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
private async streamToString(stream: NodeJS.ReadableStream): Promise<string> {
|
|
83
|
-
const chunks: Buffer[] = [];
|
|
84
|
-
for await (const chunk of stream) {
|
|
85
|
-
chunks.push(Buffer.from(chunk));
|
|
86
|
-
}
|
|
87
|
-
return Buffer.concat(chunks).toString('utf-8');
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
async speak(
|
|
91
|
-
input: string | NodeJS.ReadableStream,
|
|
92
|
-
options?: { speaker?: string; properties?: Omit<SpeechCreateParams, 'modelVersion' | 'voiceId' | 'text'> },
|
|
93
|
-
): Promise<NodeJS.ReadableStream> {
|
|
94
|
-
const text = typeof input === 'string' ? input : await this.streamToString(input);
|
|
95
|
-
|
|
96
|
-
return this.traced(async () => {
|
|
97
|
-
const response = await this.client
|
|
98
|
-
.post('v1/speech/generate', {
|
|
99
|
-
json: {
|
|
100
|
-
voiceId: (options?.speaker || this.defaultVoice) as MurfVoiceId,
|
|
101
|
-
text,
|
|
102
|
-
modelVersion: this.speechModel?.name,
|
|
103
|
-
...this.properties,
|
|
104
|
-
...options?.properties,
|
|
105
|
-
},
|
|
106
|
-
})
|
|
107
|
-
.json<SpeechCreateResponse>();
|
|
108
|
-
|
|
109
|
-
// Create a PassThrough stream for the audio
|
|
110
|
-
const stream = new PassThrough();
|
|
111
|
-
|
|
112
|
-
// Get the audio file as a stream
|
|
113
|
-
const audioResponse = await fetch(response.audioFile);
|
|
114
|
-
if (!audioResponse.body) {
|
|
115
|
-
throw new Error('No response body received');
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
// Process the stream
|
|
119
|
-
const reader = audioResponse.body.getReader();
|
|
120
|
-
(async () => {
|
|
121
|
-
try {
|
|
122
|
-
while (true) {
|
|
123
|
-
const { done, value } = await reader.read();
|
|
124
|
-
if (done) {
|
|
125
|
-
stream.end();
|
|
126
|
-
break;
|
|
127
|
-
}
|
|
128
|
-
stream.write(value);
|
|
129
|
-
}
|
|
130
|
-
} catch (error) {
|
|
131
|
-
stream.destroy(error as Error);
|
|
132
|
-
}
|
|
133
|
-
})().catch(error => {
|
|
134
|
-
stream.destroy(error as Error);
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
return stream;
|
|
138
|
-
}, 'voice.murf.speak')();
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
async listen(
|
|
142
|
-
_input: NodeJS.ReadableStream,
|
|
143
|
-
_options?: Record<string, unknown>,
|
|
144
|
-
): Promise<string | NodeJS.ReadableStream> {
|
|
145
|
-
throw new Error('Murf does not support speech recognition');
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
async getSpeakers() {
|
|
149
|
-
return this.traced(async () => {
|
|
150
|
-
return MURF_VOICES.map(voice => ({
|
|
151
|
-
voiceId: voice,
|
|
152
|
-
name: voice,
|
|
153
|
-
language: voice.split('-')[0],
|
|
154
|
-
gender: 'neutral',
|
|
155
|
-
}));
|
|
156
|
-
}, 'voice.murf.getSpeakers')();
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
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