@mastra/voice-murf 0.0.0-storage-20250225005900

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.
@@ -0,0 +1,19 @@
1
+
2
+ 
3
+ > @mastra/voice-murf@0.1.0-alpha.2 build /Users/ward/projects/mastra/mastra/voice/murf
4
+ > tsup src/index.ts --format esm --experimental-dts --clean --treeshake
5
+
6
+ CLI Building entry: src/index.ts
7
+ CLI Using tsconfig: tsconfig.json
8
+ CLI tsup v8.3.6
9
+ TSC Build start
10
+ TSC ⚡️ Build success in 1460ms
11
+ DTS Build start
12
+ CLI Target: es2022
13
+ Analysis will use the bundled TypeScript version 5.7.3
14
+ Writing package typings: /Users/ward/projects/mastra/mastra/voice/murf/dist/_tsup-dts-rollup.d.ts
15
+ DTS ⚡️ Build success in 1814ms
16
+ CLI Cleaning output folder
17
+ ESM Build start
18
+ ESM dist/index.js 4.95 KB
19
+ ESM ⚡️ Build success in 127ms
package/CHANGELOG.md ADDED
@@ -0,0 +1,51 @@
1
+ # @mastra/voice-murf
2
+
3
+ ## 0.0.0-storage-20250225005900
4
+
5
+ ### Patch Changes
6
+
7
+ - 5b1af96: deprecate @mastra/speech-murf for @mastra/voice-murf
8
+ - Updated dependencies [7fceae1]
9
+ - Updated dependencies [f626fbb]
10
+ - Updated dependencies [8db2a28]
11
+ - @mastra/core@0.0.0-storage-20250225005900
12
+
13
+ ## 0.1.0-alpha.2
14
+
15
+ ### Patch Changes
16
+
17
+ - 5b1af96: deprecate @mastra/speech-murf for @mastra/voice-murf
18
+
19
+ ## 0.1.0 (2024-XX-XX)
20
+
21
+ This package replaces the deprecated @mastra/speech-murf package. All functionality has been migrated to this new package with a more consistent naming scheme.
22
+
23
+ ### Changes from @mastra/speech-murf
24
+
25
+ - Package renamed from @mastra/speech-murf to @mastra/voice-murf
26
+ - API changes:
27
+ - `MurfTTS` class renamed to `MurfVoice`
28
+ - `generate()` and `stream()` methods combined into `speak()`
29
+ - `voices()` method renamed to `getSpeakers()`
30
+ - Constructor configuration simplified
31
+ - Added support for text stream input
32
+ - Default speaker configuration added
33
+ - All core functionality remains the same
34
+ - Import paths should be updated from '@mastra/speech-murf' to '@mastra/voice-murf'
35
+
36
+ ### Key Features Preserved
37
+
38
+ - High-quality voice synthesis
39
+ - Multiple voice options with rich metadata
40
+ - Streaming support
41
+ - Natural and expressive speech output
42
+ - Voice customization options including:
43
+ - Style control
44
+ - Rate adjustment
45
+ - Pitch modification
46
+ - Sample rate selection
47
+ - Audio format options
48
+ - Channel type selection
49
+ - Pronunciation dictionary support
50
+
51
+ For a complete history of changes prior to the rename, please see the changelog of the original package.
package/LICENSE ADDED
@@ -0,0 +1,44 @@
1
+ Elastic License 2.0 (ELv2)
2
+
3
+ **Acceptance**
4
+ By using the software, you agree to all of the terms and conditions below.
5
+
6
+ **Copyright License**
7
+ The licensor grants you a non-exclusive, royalty-free, worldwide, non-sublicensable, non-transferable license to use, copy, distribute, make available, and prepare derivative works of the software, in each case subject to the limitations and conditions below
8
+
9
+ **Limitations**
10
+ You may not provide the software to third parties as a hosted or managed service, where the service provides users with access to any substantial set of the features or functionality of the software.
11
+
12
+ You may not move, change, disable, or circumvent the license key functionality in the software, and you may not remove or obscure any functionality in the software that is protected by the license key.
13
+
14
+ You may not alter, remove, or obscure any licensing, copyright, or other notices of the licensor in the software. Any use of the licensor’s trademarks is subject to applicable law.
15
+
16
+ **Patents**
17
+ The licensor grants you a license, under any patent claims the licensor can license, or becomes able to license, to make, have made, use, sell, offer for sale, import and have imported the software, in each case subject to the limitations and conditions in this license. This license does not cover any patent claims that you cause to be infringed by modifications or additions to the software. If you or your company make any written claim that the software infringes or contributes to infringement of any patent, your patent license for the software granted under these terms ends immediately. If your company makes such a claim, your patent license ends immediately for work on behalf of your company.
18
+
19
+ **Notices**
20
+ You must ensure that anyone who gets a copy of any part of the software from you also gets a copy of these terms.
21
+
22
+ If you modify the software, you must include in any modified copies of the software prominent notices stating that you have modified the software.
23
+
24
+ **No Other Rights**
25
+ These terms do not imply any licenses other than those expressly granted in these terms.
26
+
27
+ **Termination**
28
+ If you use the software in violation of these terms, such use is not licensed, and your licenses will automatically terminate. If the licensor provides you with a notice of your violation, and you cease all violation of this license no later than 30 days after you receive that notice, your licenses will be reinstated retroactively. However, if you violate these terms after such reinstatement, any additional violation of these terms will cause your licenses to terminate automatically and permanently.
29
+
30
+ **No Liability**
31
+ As far as the law allows, the software comes as is, without any warranty or condition, and the licensor will not be liable to you for any damages arising out of these terms or the use or nature of the software, under any kind of legal claim.
32
+
33
+ **Definitions**
34
+ The _licensor_ is the entity offering these terms, and the _software_ is the software the licensor makes available under these terms, including any portion of it.
35
+
36
+ _you_ refers to the individual or entity agreeing to these terms.
37
+
38
+ _your company_ is any legal entity, sole proprietorship, or other kind of organization that you work for, plus all organizations that have control over, are under the control of, or are under common control with that organization. _control_ means ownership of substantially all the assets of an entity, or the power to direct its management and policies by vote, contract, or otherwise. Control can be direct or indirect.
39
+
40
+ _your licenses_ are all the licenses granted to you for the software under these terms.
41
+
42
+ _use_ means anything you do with the software requiring one of your licenses.
43
+
44
+ _trademark_ means trademarks, service marks, and similar rights.
package/README.md ADDED
@@ -0,0 +1,75 @@
1
+ # @mastra/voice-murf
2
+
3
+ Murf Voice integration for Mastra, providing Text-to-Speech (TTS) capabilities using Murf's AI voice technology.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @mastra/voice-murf
9
+ ```
10
+
11
+ ## Configuration
12
+
13
+ The module requires the following environment variable:
14
+
15
+ ```bash
16
+ MURF_API_KEY=your_api_key
17
+ ```
18
+
19
+ ## Usage
20
+
21
+ ```typescript
22
+ import { MurfVoice } from '@mastra/voice-murf';
23
+ // Or generate speech from a text stream
24
+ import { Readable } from 'stream';
25
+
26
+ // Initialize with configuration
27
+ const voice = new MurfVoice({
28
+ speechModel: {
29
+ name: 'GEN2', // Optional, defaults to 'GEN2'
30
+ apiKey: 'your-api-key', // Optional, can use MURF_API_KEY env var
31
+ },
32
+ speaker: 'en-US-natalie', // Optional, defaults to first available voice
33
+ });
34
+
35
+ // Or use with defaults (using env vars)
36
+ const defaultVoice = new MurfVoice();
37
+
38
+ // List available speakers
39
+ const speakers = await voice.getSpeakers();
40
+
41
+ // Generate speech from text
42
+ const stream = await voice.speak('Hello from Mastra!');
43
+
44
+ const textStream = Readable.from(['Hello', ' from', ' stream', ' input!']);
45
+ const audioStream = await voice.speak(textStream);
46
+
47
+ // Speech recognition is not supported
48
+ try {
49
+ await voice.listen(audioStream);
50
+ } catch (error) {
51
+ console.error(error); // "Murf does not support speech recognition"
52
+ }
53
+ ```
54
+
55
+ ## Features
56
+
57
+ - High-quality Text-to-Speech synthesis
58
+ - Multiple voice options
59
+ - Streaming support for both input and output
60
+ - Natural-sounding voice synthesis
61
+ - Voice customization options
62
+ - Default configuration support
63
+
64
+ ## Voice Options
65
+
66
+ Murf provides a variety of voices with different accents and styles:
67
+
68
+ - en-US-natalie (Female, American)
69
+ - en-US-marcus (Male, American)
70
+ - en-GB-oliver (Male, British)
71
+ - en-GB-emma (Female, British)
72
+ - en-AU-lucas (Male, Australian)
73
+ - en-AU-sophia (Female, Australian)
74
+
75
+ View the complete list in the `voices.ts` file or [Murf's documentation](https://murf.ai/docs/api).
@@ -0,0 +1,57 @@
1
+ import { MastraVoice } from '@mastra/core/voice';
2
+
3
+ /**
4
+ * List of available voices for Murf TTS
5
+ */
6
+ export declare const MURF_VOICES: readonly ["en-UK-hazel", "en-US-cooper", "en-US-imani", "it-IT-giorgio", "en-US-wayne", "en-IN-shivani", "en-US-daniel", "bn-IN-anwesha", "es-MX-alejandro", "en-AU-joyce", "en-US-zion", "en-IN-isha", "en-US-riley", "ko-KR-hwan", "fr-FR-adélie", "en-US-carter", "en-UK-gabriel", "en-UK-juliet", "en-IN-arohi", "fr-FR-maxime", "de-DE-josephine", "en-UK-hugo", "en-US-samantha", "de-DE-erna", "zh-CN-baolin", "pt-BR-isadora", "it-IT-vincenzo", "en-US-terrell", "en-US-denzel", "en-UK-heidi", "en-US-miles", "en-US-abigail", "fr-FR-justine", "it-IT-greta", "en-AU-shane", "en-UK-peter", "nl-NL-famke", "en-AU-ivy", "nl-NL-dirk", "fr-FR-axel", "es-ES-carla", "en-US-claire", "ko-KR-jangmi", "ko-KR-sanghoon", "it-IT-vera", "hi-IN-rahul", "es-ES-elvira", "es-ES-enrique", "en-UK-aiden", "en-US-ronnie", "en-UK-amber", "hi-IN-shweta", "hi-IN-amit", "en-AU-jimm", "en-UK-pearl", "pt-BR-benício", "en-UK-freddie", "en-US-ryan", "pt-BR-eloa", "en-US-charlotte", "de-DE-lia", "en-US-natalie", "en-US-michelle", "en-US-phoebe", "es-ES-carmen", "en-US-caleb", "en-US-iris", "en-UK-harrison", "en-US-marcus", "en-US-josie", "en-US-daisy", "en-US-charles", "en-UK-reggie", "en-US-julia", "en-SCOTT-emily", "en-US-dylan", "es-MX-valeria", "en-IN-eashwar", "en-AU-evelyn", "de-DE-lara", "en-US-evander", "en-SCOTT-rory", "ta-IN-iniya", "en-AU-leyton", "fr-FR-louise", "zh-CN-wei", "ko-KR-gyeong", "de-DE-matthias", "en-IN-rohan", "en-US-delilah", "bn-IN-abhik", "en-US-angela", "en-US-naomi", "es-MX-carlos", "nl-NL-merel", "en-US-alicia", "en-IN-alia", "zh-CN-jiao", "en-US-june", "en-AU-ashton", "en-UK-finley", "pl-PL-blazej", "zh-CN-zhang", "en-AU-kylie", "en-US-jayden", "en-IN-aarav", "de-DE-björn", "bn-IN-ishani", "zh-CN-yuxan", "fr-FR-louis", "ko-KR-jong-su", "en-AU-harper", "en-UK-ruby", "en-US-ken", "ta-IN-mani", "de-DE-ralf", "en-UK-jaxon", "en-US-river", "en-IN-priya", "en-UK-theo", "en-UK-katie", "pl-PL-jacek", "it-IT-lorenzo", "hi-IN-shaan", "en-US-amara", "en-UK-mason", "en-IN-surya", "en-US-finn", "pt-BR-gustavo", "hi-IN-kabir", "es-ES-javier", "en-AU-mitch", "pt-BR-heitor", "en-US-edmund", "hi-IN-ayushi", "pl-PL-kasia", "es-MX-luisa", "zh-CN-tao", "en-US-molly"];
7
+
8
+ export declare type MurfConfig = {
9
+ name: 'GEN1' | 'GEN2';
10
+ apiKey?: string;
11
+ properties?: Omit<SpeechCreateParams, 'modelVersion' | 'voiceId' | 'text'>;
12
+ };
13
+
14
+ export declare class MurfVoice extends MastraVoice {
15
+ private client;
16
+ private defaultVoice;
17
+ private properties;
18
+ constructor({ speechModel, speaker }?: {
19
+ speechModel?: MurfConfig;
20
+ speaker?: string;
21
+ });
22
+ private streamToString;
23
+ speak(input: string | NodeJS.ReadableStream, options?: {
24
+ speaker?: string;
25
+ properties?: Omit<SpeechCreateParams, 'modelVersion' | 'voiceId' | 'text'>;
26
+ }): Promise<NodeJS.ReadableStream>;
27
+ listen(_input: NodeJS.ReadableStream, _options?: Record<string, unknown>): Promise<string | NodeJS.ReadableStream>;
28
+ getSpeakers(): Promise<{
29
+ voiceId: "en-UK-hazel" | "en-US-cooper" | "en-US-imani" | "it-IT-giorgio" | "en-US-wayne" | "en-IN-shivani" | "en-US-daniel" | "bn-IN-anwesha" | "es-MX-alejandro" | "en-AU-joyce" | "en-US-zion" | "en-IN-isha" | "en-US-riley" | "ko-KR-hwan" | "fr-FR-adélie" | "en-US-carter" | "en-UK-gabriel" | "en-UK-juliet" | "en-IN-arohi" | "fr-FR-maxime" | "de-DE-josephine" | "en-UK-hugo" | "en-US-samantha" | "de-DE-erna" | "zh-CN-baolin" | "pt-BR-isadora" | "it-IT-vincenzo" | "en-US-terrell" | "en-US-denzel" | "en-UK-heidi" | "en-US-miles" | "en-US-abigail" | "fr-FR-justine" | "it-IT-greta" | "en-AU-shane" | "en-UK-peter" | "nl-NL-famke" | "en-AU-ivy" | "nl-NL-dirk" | "fr-FR-axel" | "es-ES-carla" | "en-US-claire" | "ko-KR-jangmi" | "ko-KR-sanghoon" | "it-IT-vera" | "hi-IN-rahul" | "es-ES-elvira" | "es-ES-enrique" | "en-UK-aiden" | "en-US-ronnie" | "en-UK-amber" | "hi-IN-shweta" | "hi-IN-amit" | "en-AU-jimm" | "en-UK-pearl" | "pt-BR-benício" | "en-UK-freddie" | "en-US-ryan" | "pt-BR-eloa" | "en-US-charlotte" | "de-DE-lia" | "en-US-natalie" | "en-US-michelle" | "en-US-phoebe" | "es-ES-carmen" | "en-US-caleb" | "en-US-iris" | "en-UK-harrison" | "en-US-marcus" | "en-US-josie" | "en-US-daisy" | "en-US-charles" | "en-UK-reggie" | "en-US-julia" | "en-SCOTT-emily" | "en-US-dylan" | "es-MX-valeria" | "en-IN-eashwar" | "en-AU-evelyn" | "de-DE-lara" | "en-US-evander" | "en-SCOTT-rory" | "ta-IN-iniya" | "en-AU-leyton" | "fr-FR-louise" | "zh-CN-wei" | "ko-KR-gyeong" | "de-DE-matthias" | "en-IN-rohan" | "en-US-delilah" | "bn-IN-abhik" | "en-US-angela" | "en-US-naomi" | "es-MX-carlos" | "nl-NL-merel" | "en-US-alicia" | "en-IN-alia" | "zh-CN-jiao" | "en-US-june" | "en-AU-ashton" | "en-UK-finley" | "pl-PL-blazej" | "zh-CN-zhang" | "en-AU-kylie" | "en-US-jayden" | "en-IN-aarav" | "de-DE-björn" | "bn-IN-ishani" | "zh-CN-yuxan" | "fr-FR-louis" | "ko-KR-jong-su" | "en-AU-harper" | "en-UK-ruby" | "en-US-ken" | "ta-IN-mani" | "de-DE-ralf" | "en-UK-jaxon" | "en-US-river" | "en-IN-priya" | "en-UK-theo" | "en-UK-katie" | "pl-PL-jacek" | "it-IT-lorenzo" | "hi-IN-shaan" | "en-US-amara" | "en-UK-mason" | "en-IN-surya" | "en-US-finn" | "pt-BR-gustavo" | "hi-IN-kabir" | "es-ES-javier" | "en-AU-mitch" | "pt-BR-heitor" | "en-US-edmund" | "hi-IN-ayushi" | "pl-PL-kasia" | "es-MX-luisa" | "zh-CN-tao" | "en-US-molly";
30
+ name: "en-UK-hazel" | "en-US-cooper" | "en-US-imani" | "it-IT-giorgio" | "en-US-wayne" | "en-IN-shivani" | "en-US-daniel" | "bn-IN-anwesha" | "es-MX-alejandro" | "en-AU-joyce" | "en-US-zion" | "en-IN-isha" | "en-US-riley" | "ko-KR-hwan" | "fr-FR-adélie" | "en-US-carter" | "en-UK-gabriel" | "en-UK-juliet" | "en-IN-arohi" | "fr-FR-maxime" | "de-DE-josephine" | "en-UK-hugo" | "en-US-samantha" | "de-DE-erna" | "zh-CN-baolin" | "pt-BR-isadora" | "it-IT-vincenzo" | "en-US-terrell" | "en-US-denzel" | "en-UK-heidi" | "en-US-miles" | "en-US-abigail" | "fr-FR-justine" | "it-IT-greta" | "en-AU-shane" | "en-UK-peter" | "nl-NL-famke" | "en-AU-ivy" | "nl-NL-dirk" | "fr-FR-axel" | "es-ES-carla" | "en-US-claire" | "ko-KR-jangmi" | "ko-KR-sanghoon" | "it-IT-vera" | "hi-IN-rahul" | "es-ES-elvira" | "es-ES-enrique" | "en-UK-aiden" | "en-US-ronnie" | "en-UK-amber" | "hi-IN-shweta" | "hi-IN-amit" | "en-AU-jimm" | "en-UK-pearl" | "pt-BR-benício" | "en-UK-freddie" | "en-US-ryan" | "pt-BR-eloa" | "en-US-charlotte" | "de-DE-lia" | "en-US-natalie" | "en-US-michelle" | "en-US-phoebe" | "es-ES-carmen" | "en-US-caleb" | "en-US-iris" | "en-UK-harrison" | "en-US-marcus" | "en-US-josie" | "en-US-daisy" | "en-US-charles" | "en-UK-reggie" | "en-US-julia" | "en-SCOTT-emily" | "en-US-dylan" | "es-MX-valeria" | "en-IN-eashwar" | "en-AU-evelyn" | "de-DE-lara" | "en-US-evander" | "en-SCOTT-rory" | "ta-IN-iniya" | "en-AU-leyton" | "fr-FR-louise" | "zh-CN-wei" | "ko-KR-gyeong" | "de-DE-matthias" | "en-IN-rohan" | "en-US-delilah" | "bn-IN-abhik" | "en-US-angela" | "en-US-naomi" | "es-MX-carlos" | "nl-NL-merel" | "en-US-alicia" | "en-IN-alia" | "zh-CN-jiao" | "en-US-june" | "en-AU-ashton" | "en-UK-finley" | "pl-PL-blazej" | "zh-CN-zhang" | "en-AU-kylie" | "en-US-jayden" | "en-IN-aarav" | "de-DE-björn" | "bn-IN-ishani" | "zh-CN-yuxan" | "fr-FR-louis" | "ko-KR-jong-su" | "en-AU-harper" | "en-UK-ruby" | "en-US-ken" | "ta-IN-mani" | "de-DE-ralf" | "en-UK-jaxon" | "en-US-river" | "en-IN-priya" | "en-UK-theo" | "en-UK-katie" | "pl-PL-jacek" | "it-IT-lorenzo" | "hi-IN-shaan" | "en-US-amara" | "en-UK-mason" | "en-IN-surya" | "en-US-finn" | "pt-BR-gustavo" | "hi-IN-kabir" | "es-ES-javier" | "en-AU-mitch" | "pt-BR-heitor" | "en-US-edmund" | "hi-IN-ayushi" | "pl-PL-kasia" | "es-MX-luisa" | "zh-CN-tao" | "en-US-molly";
31
+ language: string | undefined;
32
+ gender: string;
33
+ }[]>;
34
+ }
35
+
36
+ declare type MurfVoiceId = (typeof MURF_VOICES)[number];
37
+ export { MurfVoiceId }
38
+ export { MurfVoiceId as MurfVoiceId_alias_1 }
39
+
40
+ declare type SpeechCreateParams = {
41
+ voiceId: MurfVoiceId;
42
+ text: string;
43
+ modelVersion: 'GEN1' | 'GEN2';
44
+ style?: string;
45
+ rate?: number;
46
+ pitch?: number;
47
+ sampleRate?: 8000 | 24000 | 44100 | 48000;
48
+ format?: 'MP3' | 'WAV' | 'FLAC' | 'ALAW' | 'ULAW';
49
+ channelType?: 'STEREO' | 'MONO';
50
+ pronunciationDictionary?: Record<string, string>;
51
+ encodeAsBase64?: boolean;
52
+ variation?: number;
53
+ audioDuration?: number;
54
+ multiNativeLocale?: string;
55
+ };
56
+
57
+ export { }
@@ -0,0 +1,3 @@
1
+ export { MurfVoice } from './_tsup-dts-rollup.js';
2
+ export { MurfConfig } from './_tsup-dts-rollup.js';
3
+ export { MurfVoiceId } from './_tsup-dts-rollup.js';
package/dist/index.js ADDED
@@ -0,0 +1,237 @@
1
+ import { MastraVoice } from '@mastra/core/voice';
2
+ import ky from 'ky';
3
+ import { PassThrough } from 'stream';
4
+
5
+ // src/index.ts
6
+
7
+ // src/voices.ts
8
+ var MURF_VOICES = [
9
+ "en-UK-hazel",
10
+ "en-US-cooper",
11
+ "en-US-imani",
12
+ "it-IT-giorgio",
13
+ "en-US-wayne",
14
+ "en-IN-shivani",
15
+ "en-US-daniel",
16
+ "bn-IN-anwesha",
17
+ "es-MX-alejandro",
18
+ "en-AU-joyce",
19
+ "en-US-zion",
20
+ "en-IN-isha",
21
+ "en-US-riley",
22
+ "ko-KR-hwan",
23
+ "fr-FR-ad\xE9lie",
24
+ "en-US-carter",
25
+ "en-UK-gabriel",
26
+ "en-UK-juliet",
27
+ "en-IN-arohi",
28
+ "fr-FR-maxime",
29
+ "de-DE-josephine",
30
+ "en-UK-hugo",
31
+ "en-US-samantha",
32
+ "de-DE-erna",
33
+ "zh-CN-baolin",
34
+ "pt-BR-isadora",
35
+ "it-IT-vincenzo",
36
+ "en-US-terrell",
37
+ "en-US-denzel",
38
+ "en-UK-heidi",
39
+ "en-US-miles",
40
+ "en-US-abigail",
41
+ "fr-FR-justine",
42
+ "it-IT-greta",
43
+ "en-AU-shane",
44
+ "en-UK-peter",
45
+ "nl-NL-famke",
46
+ "en-AU-ivy",
47
+ "nl-NL-dirk",
48
+ "fr-FR-axel",
49
+ "es-ES-carla",
50
+ "en-US-claire",
51
+ "ko-KR-jangmi",
52
+ "ko-KR-sanghoon",
53
+ "it-IT-vera",
54
+ "hi-IN-rahul",
55
+ "es-ES-elvira",
56
+ "es-ES-enrique",
57
+ "en-UK-aiden",
58
+ "en-US-ronnie",
59
+ "en-UK-amber",
60
+ "hi-IN-shweta",
61
+ "hi-IN-amit",
62
+ "en-AU-jimm",
63
+ "en-UK-pearl",
64
+ "pt-BR-ben\xEDcio",
65
+ "en-UK-freddie",
66
+ "en-US-ryan",
67
+ "pt-BR-eloa",
68
+ "en-US-charlotte",
69
+ "de-DE-lia",
70
+ "en-US-natalie",
71
+ "en-US-michelle",
72
+ "en-US-phoebe",
73
+ "es-ES-carmen",
74
+ "en-US-caleb",
75
+ "en-US-iris",
76
+ "en-UK-harrison",
77
+ "en-US-marcus",
78
+ "en-US-josie",
79
+ "en-US-daisy",
80
+ "en-US-charles",
81
+ "en-UK-reggie",
82
+ "en-US-julia",
83
+ "en-SCOTT-emily",
84
+ "en-US-dylan",
85
+ "es-MX-valeria",
86
+ "en-IN-eashwar",
87
+ "en-AU-evelyn",
88
+ "de-DE-lara",
89
+ "en-US-evander",
90
+ "en-SCOTT-rory",
91
+ "ta-IN-iniya",
92
+ "en-AU-leyton",
93
+ "fr-FR-louise",
94
+ "zh-CN-wei",
95
+ "ko-KR-gyeong",
96
+ "de-DE-matthias",
97
+ "en-IN-rohan",
98
+ "en-US-delilah",
99
+ "bn-IN-abhik",
100
+ "en-US-angela",
101
+ "en-US-naomi",
102
+ "es-MX-carlos",
103
+ "nl-NL-merel",
104
+ "en-US-alicia",
105
+ "en-IN-alia",
106
+ "zh-CN-jiao",
107
+ "en-US-june",
108
+ "en-AU-ashton",
109
+ "en-UK-finley",
110
+ "pl-PL-blazej",
111
+ "zh-CN-zhang",
112
+ "en-AU-kylie",
113
+ "en-US-jayden",
114
+ "en-IN-aarav",
115
+ "de-DE-bj\xF6rn",
116
+ "bn-IN-ishani",
117
+ "zh-CN-yuxan",
118
+ "fr-FR-louis",
119
+ "ko-KR-jong-su",
120
+ "en-AU-harper",
121
+ "en-UK-ruby",
122
+ "en-US-ken",
123
+ "ta-IN-mani",
124
+ "de-DE-ralf",
125
+ "en-UK-jaxon",
126
+ "en-US-river",
127
+ "en-IN-priya",
128
+ "en-UK-theo",
129
+ "en-UK-katie",
130
+ "pl-PL-jacek",
131
+ "it-IT-lorenzo",
132
+ "hi-IN-shaan",
133
+ "en-US-amara",
134
+ "en-UK-mason",
135
+ "en-IN-surya",
136
+ "en-US-finn",
137
+ "pt-BR-gustavo",
138
+ "hi-IN-kabir",
139
+ "es-ES-javier",
140
+ "en-AU-mitch",
141
+ "pt-BR-heitor",
142
+ "en-US-edmund",
143
+ "hi-IN-ayushi",
144
+ "pl-PL-kasia",
145
+ "es-MX-luisa",
146
+ "zh-CN-tao",
147
+ "en-US-molly"
148
+ ];
149
+
150
+ // src/index.ts
151
+ var MurfVoice = class extends MastraVoice {
152
+ client;
153
+ defaultVoice;
154
+ properties;
155
+ constructor({ speechModel, speaker } = {}) {
156
+ super({
157
+ speechModel: {
158
+ name: speechModel?.name ?? "GEN2",
159
+ apiKey: speechModel?.apiKey ?? process.env.MURF_API_KEY
160
+ },
161
+ speaker: speaker ?? MURF_VOICES[0]
162
+ });
163
+ const apiKey = this.speechModel?.apiKey;
164
+ if (!apiKey) {
165
+ throw new Error("MURF_API_KEY is not set");
166
+ }
167
+ this.properties = {
168
+ ...speechModel?.properties
169
+ };
170
+ this.client = ky.create({
171
+ prefixUrl: "https://api.murf.ai",
172
+ headers: {
173
+ "api-key": apiKey
174
+ }
175
+ });
176
+ this.defaultVoice = speaker ?? MURF_VOICES[0];
177
+ }
178
+ async streamToString(stream) {
179
+ const chunks = [];
180
+ for await (const chunk of stream) {
181
+ chunks.push(Buffer.from(chunk));
182
+ }
183
+ return Buffer.concat(chunks).toString("utf-8");
184
+ }
185
+ async speak(input, options) {
186
+ const text = typeof input === "string" ? input : await this.streamToString(input);
187
+ return this.traced(async () => {
188
+ const response = await this.client.post("v1/speech/generate", {
189
+ json: {
190
+ voiceId: options?.speaker || this.defaultVoice,
191
+ text,
192
+ modelVersion: this.speechModel?.name,
193
+ ...this.properties,
194
+ ...options?.properties
195
+ }
196
+ }).json();
197
+ const stream = new PassThrough();
198
+ const audioResponse = await fetch(response.audioFile);
199
+ if (!audioResponse.body) {
200
+ throw new Error("No response body received");
201
+ }
202
+ const reader = audioResponse.body.getReader();
203
+ (async () => {
204
+ try {
205
+ while (true) {
206
+ const { done, value } = await reader.read();
207
+ if (done) {
208
+ stream.end();
209
+ break;
210
+ }
211
+ stream.write(value);
212
+ }
213
+ } catch (error) {
214
+ stream.destroy(error);
215
+ }
216
+ })().catch((error) => {
217
+ stream.destroy(error);
218
+ });
219
+ return stream;
220
+ }, "voice.murf.speak")();
221
+ }
222
+ async listen(_input, _options) {
223
+ throw new Error("Murf does not support speech recognition");
224
+ }
225
+ async getSpeakers() {
226
+ return this.traced(async () => {
227
+ return MURF_VOICES.map((voice) => ({
228
+ voiceId: voice,
229
+ name: voice,
230
+ language: voice.split("-")[0],
231
+ gender: "neutral"
232
+ }));
233
+ }, "voice.murf.getSpeakers")();
234
+ }
235
+ };
236
+
237
+ export { MurfVoice };
@@ -0,0 +1,6 @@
1
+ import { createConfig } from '@internal/lint/eslint';
2
+
3
+ const config = await createConfig();
4
+
5
+ /** @type {import("eslint").Linter.Config[]} */
6
+ export default [...config];
package/package.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "@mastra/voice-murf",
3
+ "version": "0.0.0-storage-20250225005900",
4
+ "description": "Mastra Murf voice integration",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": {
11
+ "types": "./dist/index.d.ts",
12
+ "default": "./dist/index.js"
13
+ }
14
+ },
15
+ "./package.json": "./package.json"
16
+ },
17
+ "dependencies": {
18
+ "ky": "^1.7.4",
19
+ "zod": "^3.24.1",
20
+ "@mastra/core": "^0.0.0-storage-20250225005900"
21
+ },
22
+ "devDependencies": {
23
+ "@microsoft/api-extractor": "^7.49.2",
24
+ "@types/node": "^22.13.1",
25
+ "tsup": "^8.0.1",
26
+ "typescript": "^5.7.3",
27
+ "eslint": "^9.20.1",
28
+ "vitest": "^2.1.8",
29
+ "@internal/lint": "0.0.0"
30
+ },
31
+ "scripts": {
32
+ "build": "tsup src/index.ts --format esm --experimental-dts --clean --treeshake",
33
+ "build:watch": "pnpm build --watch",
34
+ "test": "vitest run",
35
+ "lint": "eslint ."
36
+ }
37
+ }
@@ -0,0 +1,97 @@
1
+ import { mkdirSync } from 'fs';
2
+ import path, { join } from 'path';
3
+ import { Readable } from 'stream';
4
+ import { describe, expect, it, beforeAll } from 'vitest';
5
+
6
+ import { writeFile, stat as fsStat } from 'fs/promises';
7
+
8
+ import { MurfVoice } from './index';
9
+
10
+ describe('MurfVoice', () => {
11
+ const voice = new MurfVoice({
12
+ speechModel: {
13
+ name: 'GEN2',
14
+ },
15
+ speaker: 'en-US-natalie',
16
+ });
17
+
18
+ const outputDir = path.join(process.cwd(), 'test-outputs');
19
+ beforeAll(() => {
20
+ // Create output directory if it doesn't exist
21
+ try {
22
+ mkdirSync(outputDir, { recursive: true });
23
+ } catch (err) {
24
+ console.error(`Failed to create output directory: ${err}`);
25
+ }
26
+ });
27
+
28
+ it('should list available speakers', async () => {
29
+ const speakers = await voice.getSpeakers();
30
+ expect(speakers.length).toBeGreaterThan(0);
31
+ expect(speakers[0]).toHaveProperty('voiceId');
32
+ });
33
+
34
+ it('should generate audio from text', async () => {
35
+ const audioStream = await voice.speak('Hello world!!!');
36
+ expect(audioStream).toHaveProperty('pipe');
37
+
38
+ // Collect the audio data
39
+ const chunks: Buffer[] = [];
40
+ for await (const chunk of audioStream) {
41
+ chunks.push(Buffer.from(chunk));
42
+ }
43
+ const audioBuffer = Buffer.concat(chunks);
44
+ expect(audioBuffer.length).toBeGreaterThan(0);
45
+
46
+ // Write the audio to a file
47
+ const outputPath = join(outputDir, 'test-audio.mp3');
48
+ await writeFile(outputPath, audioBuffer);
49
+ });
50
+
51
+ it('should handle stream input', async () => {
52
+ // Create a readable stream from text
53
+ const textStream = Readable.from(['Hello', ' from', ' stream', ' input!']);
54
+
55
+ const audioStream = await voice.speak(textStream);
56
+ expect(audioStream).toHaveProperty('pipe');
57
+
58
+ // Write the audio to a file using pipe
59
+ const outputPath = join(outputDir, 'test-audio-stream.mp3');
60
+
61
+ const chunks: Buffer[] = [];
62
+ for await (const chunk of audioStream) {
63
+ chunks.push(Buffer.from(chunk));
64
+ }
65
+ const audioBuffer = Buffer.concat(chunks);
66
+ await writeFile(outputPath, audioBuffer);
67
+ const stats = await fsStat(outputPath);
68
+ expect(stats.size).toBeGreaterThan(0);
69
+ });
70
+
71
+ it('should work with default configuration', async () => {
72
+ // Create instance with no args
73
+ const defaultVoice = new MurfVoice();
74
+
75
+ // Should use default model name and get API key from env
76
+ const audioStream = await defaultVoice.speak('Testing default configuration');
77
+ expect(audioStream).toHaveProperty('pipe');
78
+
79
+ const chunks: Buffer[] = [];
80
+ for await (const chunk of audioStream) {
81
+ chunks.push(Buffer.from(chunk));
82
+ }
83
+ const audioBuffer = Buffer.concat(chunks);
84
+
85
+ await writeFile(join(outputDir, 'murf-default-config-output.mp3'), audioBuffer);
86
+ expect(audioBuffer.length).toBeGreaterThan(0);
87
+
88
+ // Verify default speaker was used
89
+ const speakers = await defaultVoice.getSpeakers();
90
+ expect(speakers.length).toBeGreaterThan(0);
91
+ });
92
+
93
+ it('should throw error for speech recognition', async () => {
94
+ const audioStream = Readable.from(Buffer.from('dummy audio data'));
95
+ await expect(voice.listen(audioStream)).rejects.toThrow('Murf does not support speech recognition');
96
+ });
97
+ });
package/src/index.ts ADDED
@@ -0,0 +1,159 @@
1
+ import { MastraVoice } from '@mastra/core/voice';
2
+ import ky from 'ky';
3
+ import { PassThrough } from 'stream';
4
+
5
+ import { MURF_VOICES } from './voices';
6
+ import type { MurfVoiceId } from './voices';
7
+
8
+ type MurfConfig = {
9
+ name: 'GEN1' | 'GEN2';
10
+ apiKey?: string;
11
+ properties?: Omit<SpeechCreateParams, 'modelVersion' | 'voiceId' | 'text'>;
12
+ };
13
+
14
+ type SpeechCreateParams = {
15
+ voiceId: MurfVoiceId;
16
+ text: string;
17
+ modelVersion: 'GEN1' | 'GEN2';
18
+ style?: string;
19
+ rate?: number;
20
+ pitch?: number;
21
+ sampleRate?: 8000 | 24000 | 44100 | 48000;
22
+ format?: 'MP3' | 'WAV' | 'FLAC' | 'ALAW' | 'ULAW';
23
+ channelType?: 'STEREO' | 'MONO';
24
+ pronunciationDictionary?: Record<string, string>;
25
+ encodeAsBase64?: boolean;
26
+ variation?: number;
27
+ audioDuration?: number;
28
+ multiNativeLocale?: string;
29
+ };
30
+
31
+ type SpeechCreateResponse = {
32
+ audioFile: string;
33
+ audioLengthInSeconds: number;
34
+ consumedCharacterCount: number;
35
+ encodedAudio: string;
36
+ remainingCharacterCount: number;
37
+ warning: string;
38
+ wordDurations: {
39
+ endMs: number;
40
+ pitchScaleMaximum: number;
41
+ pitchScaleMinimum: number;
42
+ sourceWordIndex: number;
43
+ startMs: number;
44
+ word: string;
45
+ }[];
46
+ };
47
+
48
+ export class MurfVoice extends MastraVoice {
49
+ private client: typeof ky;
50
+ private defaultVoice: MurfVoiceId;
51
+ private properties: Omit<SpeechCreateParams, 'modelVersion' | 'voiceId' | 'text'>;
52
+
53
+ constructor({ speechModel, speaker }: { speechModel?: MurfConfig; speaker?: string } = {}) {
54
+ super({
55
+ speechModel: {
56
+ name: speechModel?.name ?? 'GEN2',
57
+ apiKey: speechModel?.apiKey ?? process.env.MURF_API_KEY,
58
+ },
59
+ speaker: speaker ?? MURF_VOICES[0],
60
+ });
61
+
62
+ const apiKey = this.speechModel?.apiKey;
63
+ if (!apiKey) {
64
+ throw new Error('MURF_API_KEY is not set');
65
+ }
66
+
67
+ this.properties = {
68
+ ...speechModel?.properties,
69
+ };
70
+
71
+ this.client = ky.create({
72
+ prefixUrl: 'https://api.murf.ai',
73
+ headers: {
74
+ 'api-key': apiKey,
75
+ },
76
+ });
77
+
78
+ this.defaultVoice = (speaker as MurfVoiceId) ?? MURF_VOICES[0];
79
+ }
80
+
81
+ private async streamToString(stream: NodeJS.ReadableStream): Promise<string> {
82
+ const chunks: Buffer[] = [];
83
+ for await (const chunk of stream) {
84
+ chunks.push(Buffer.from(chunk));
85
+ }
86
+ return Buffer.concat(chunks).toString('utf-8');
87
+ }
88
+
89
+ async speak(
90
+ input: string | NodeJS.ReadableStream,
91
+ options?: { speaker?: string; properties?: Omit<SpeechCreateParams, 'modelVersion' | 'voiceId' | 'text'> },
92
+ ): Promise<NodeJS.ReadableStream> {
93
+ const text = typeof input === 'string' ? input : await this.streamToString(input);
94
+
95
+ return this.traced(async () => {
96
+ const response = await this.client
97
+ .post('v1/speech/generate', {
98
+ json: {
99
+ voiceId: (options?.speaker || this.defaultVoice) as MurfVoiceId,
100
+ text,
101
+ modelVersion: this.speechModel?.name,
102
+ ...this.properties,
103
+ ...options?.properties,
104
+ },
105
+ })
106
+ .json<SpeechCreateResponse>();
107
+
108
+ // Create a PassThrough stream for the audio
109
+ const stream = new PassThrough();
110
+
111
+ // Get the audio file as a stream
112
+ const audioResponse = await fetch(response.audioFile);
113
+ if (!audioResponse.body) {
114
+ throw new Error('No response body received');
115
+ }
116
+
117
+ // Process the stream
118
+ const reader = audioResponse.body.getReader();
119
+ (async () => {
120
+ try {
121
+ while (true) {
122
+ const { done, value } = await reader.read();
123
+ if (done) {
124
+ stream.end();
125
+ break;
126
+ }
127
+ stream.write(value);
128
+ }
129
+ } catch (error) {
130
+ stream.destroy(error as Error);
131
+ }
132
+ })().catch(error => {
133
+ stream.destroy(error as Error);
134
+ });
135
+
136
+ return stream;
137
+ }, 'voice.murf.speak')();
138
+ }
139
+
140
+ async listen(
141
+ _input: NodeJS.ReadableStream,
142
+ _options?: Record<string, unknown>,
143
+ ): Promise<string | NodeJS.ReadableStream> {
144
+ throw new Error('Murf does not support speech recognition');
145
+ }
146
+
147
+ async getSpeakers() {
148
+ return this.traced(async () => {
149
+ return MURF_VOICES.map(voice => ({
150
+ voiceId: voice,
151
+ name: voice,
152
+ language: voice.split('-')[0],
153
+ gender: 'neutral',
154
+ }));
155
+ }, 'voice.murf.getSpeakers')();
156
+ }
157
+ }
158
+
159
+ export type { MurfConfig, MurfVoiceId };
package/src/voices.ts ADDED
@@ -0,0 +1,146 @@
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 ADDED
@@ -0,0 +1,5 @@
1
+ {
2
+ "extends": "../../tsconfig.node.json",
3
+ "include": ["src/**/*"],
4
+ "exclude": ["node_modules", "**/*.test.ts"]
5
+ }
@@ -0,0 +1,8 @@
1
+ import { defineConfig } from 'vitest/config';
2
+
3
+ export default defineConfig({
4
+ test: {
5
+ include: ['src/**/*.test.ts'],
6
+ environment: 'node',
7
+ },
8
+ });