@mastra/voice-murf 0.0.0-commonjs-20250227130920

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