@elizaos/plugin-edge-tts 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,95 @@
1
+ # @elizaos/plugin-edge-tts
2
+
3
+ Free text-to-speech plugin for ElizaOS using Microsoft Edge TTS. No API key required.
4
+
5
+ ## Features
6
+
7
+ - **Free**: No API key or payment required
8
+ - **High Quality**: Uses Microsoft's neural TTS voices (same as Edge browser)
9
+ - **Multiple Languages**: Supports 40+ languages with natural-sounding voices
10
+ - **Configurable**: Adjustable rate, pitch, and volume
11
+ - **OpenAI Compatible**: Maps OpenAI voice names (alloy, nova, etc.) to Edge TTS voices
12
+
13
+ ## Installation
14
+
15
+ ```bash
16
+ npm install @elizaos/plugin-edge-tts
17
+ ```
18
+
19
+ ## Usage
20
+
21
+ ### As ElizaOS Plugin
22
+
23
+ ```typescript
24
+ import { edgeTTSPlugin } from "@elizaos/plugin-edge-tts";
25
+
26
+ const runtime = new AgentRuntime({
27
+ plugins: [edgeTTSPlugin],
28
+ // ... other config
29
+ });
30
+
31
+ // Use via runtime
32
+ const audio = await runtime.useModel(ModelType.TEXT_TO_SPEECH, "Hello world!");
33
+ ```
34
+
35
+ ### Environment Variables
36
+
37
+ All configuration is optional:
38
+
39
+ | Variable | Default | Description |
40
+ |----------|---------|-------------|
41
+ | `EDGE_TTS_VOICE` | `en-US-MichelleNeural` | Voice ID |
42
+ | `EDGE_TTS_LANG` | `en-US` | Language code |
43
+ | `EDGE_TTS_OUTPUT_FORMAT` | `audio-24khz-48kbitrate-mono-mp3` | Output format |
44
+ | `EDGE_TTS_RATE` | - | Rate adjustment (e.g., `+10%`, `-5%`) |
45
+ | `EDGE_TTS_PITCH` | - | Pitch adjustment (e.g., `+5Hz`, `-10Hz`) |
46
+ | `EDGE_TTS_VOLUME` | - | Volume adjustment (e.g., `+20%`, `-10%`) |
47
+ | `EDGE_TTS_PROXY` | - | HTTP proxy URL |
48
+ | `EDGE_TTS_TIMEOUT_MS` | `30000` | Request timeout |
49
+
50
+ ## Popular Voices
51
+
52
+ ### English (US)
53
+ - `en-US-MichelleNeural` - Female (default)
54
+ - `en-US-GuyNeural` - Male
55
+ - `en-US-JennyNeural` - Female
56
+ - `en-US-AriaNeural` - Female
57
+ - `en-US-DavisNeural` - Male
58
+ - `en-US-ChristopherNeural` - Male
59
+
60
+ ### English (UK)
61
+ - `en-GB-SoniaNeural` - Female
62
+ - `en-GB-RyanNeural` - Male
63
+
64
+ ### Other Languages
65
+ - `de-DE-KatjaNeural` - German Female
66
+ - `fr-FR-DeniseNeural` - French Female
67
+ - `es-ES-ElviraNeural` - Spanish Female
68
+ - `ja-JP-NanamiNeural` - Japanese Female
69
+ - `zh-CN-XiaoxiaoNeural` - Chinese Female
70
+ - `ko-KR-SunHiNeural` - Korean Female
71
+
72
+ ## OpenAI Voice Mapping
73
+
74
+ For compatibility with OpenAI's TTS API, the following voice names are mapped:
75
+
76
+ | OpenAI Voice | Edge TTS Voice |
77
+ |--------------|----------------|
78
+ | `alloy` | `en-US-GuyNeural` |
79
+ | `echo` | `en-US-ChristopherNeural` |
80
+ | `fable` | `en-GB-RyanNeural` |
81
+ | `onyx` | `en-US-DavisNeural` |
82
+ | `nova` | `en-US-JennyNeural` |
83
+ | `shimmer` | `en-US-AriaNeural` |
84
+
85
+ ## Browser Support
86
+
87
+ Edge TTS is **not available in browser environments** because it requires:
88
+ - Node.js file system access
89
+ - WebSocket connections that browsers don't support for this service
90
+
91
+ For browser TTS, use `@elizaos/plugin-elevenlabs` or `@elizaos/plugin-openai` instead.
92
+
93
+ ## License
94
+
95
+ MIT
@@ -0,0 +1,3 @@
1
+ import{logger as f}from"@elizaos/core";var j={name:"edge-tts",description:"Edge TTS plugin (browser stub - not available in browser environments)",models:{},tests:[]};if(typeof window<"u")f.warn("[EdgeTTS] Edge TTS is not available in browser environments. Use @elizaos/plugin-elevenlabs or @elizaos/plugin-openai for browser TTS.");var v=j;export{j as edgeTTSPlugin,v as default};
2
+
3
+ //# debugId=A1DF4939E5621A8064756E2164756E21
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/index.browser.ts"],
4
+ "sourcesContent": [
5
+ "/**\n * Browser entry point for @elizaos/plugin-edge-tts\n *\n * Edge TTS is not available in browser environments because it requires\n * Node.js file system access and WebSocket connections that browsers don't support.\n *\n * For browser TTS, use @elizaos/plugin-elevenlabs or @elizaos/plugin-openai instead.\n */\nimport { type Plugin, logger } from \"@elizaos/core\";\n\nexport const edgeTTSPlugin: Plugin = {\n name: \"edge-tts\",\n description:\n \"Edge TTS plugin (browser stub - not available in browser environments)\",\n models: {},\n tests: [],\n};\n\n// Log warning when imported in browser\nif (typeof window !== \"undefined\") {\n logger.warn(\n \"[EdgeTTS] Edge TTS is not available in browser environments. \" +\n \"Use @elizaos/plugin-elevenlabs or @elizaos/plugin-openai for browser TTS.\",\n );\n}\n\nexport default edgeTTSPlugin;\n"
6
+ ],
7
+ "mappings": "AAQA,iBAAsB,sBAEf,IAAM,EAAwB,CACnC,KAAM,WACN,YACE,yEACF,OAAQ,CAAC,EACT,MAAO,CAAC,CACV,EAGA,GAAI,OAAO,OAAW,IACpB,EAAO,KACL,wIAEF,EAGF,IAAe",
8
+ "debugId": "A1DF4939E5621A8064756E2164756E21",
9
+ "names": []
10
+ }
@@ -0,0 +1,2 @@
1
+ export * from '../index';
2
+ export { default } from '../index';
@@ -0,0 +1,2 @@
1
+ export * from '../index';
2
+ export { default } from '../index';
@@ -0,0 +1,260 @@
1
+ var __create = Object.create;
2
+ var __getProtoOf = Object.getPrototypeOf;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __toESM = (mod, isNodeMode, target) => {
8
+ target = mod != null ? __create(__getProtoOf(mod)) : {};
9
+ const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
10
+ for (let key of __getOwnPropNames(mod))
11
+ if (!__hasOwnProp.call(to, key))
12
+ __defProp(to, key, {
13
+ get: () => mod[key],
14
+ enumerable: true
15
+ });
16
+ return to;
17
+ };
18
+ var __moduleCache = /* @__PURE__ */ new WeakMap;
19
+ var __toCommonJS = (from) => {
20
+ var entry = __moduleCache.get(from), desc;
21
+ if (entry)
22
+ return entry;
23
+ entry = __defProp({}, "__esModule", { value: true });
24
+ if (from && typeof from === "object" || typeof from === "function")
25
+ __getOwnPropNames(from).map((key) => !__hasOwnProp.call(entry, key) && __defProp(entry, key, {
26
+ get: () => from[key],
27
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
28
+ }));
29
+ __moduleCache.set(from, entry);
30
+ return entry;
31
+ };
32
+ var __export = (target, all) => {
33
+ for (var name in all)
34
+ __defProp(target, name, {
35
+ get: all[name],
36
+ enumerable: true,
37
+ configurable: true,
38
+ set: (newValue) => all[name] = () => newValue
39
+ });
40
+ };
41
+
42
+ // src/index.node.ts
43
+ var exports_index_node = {};
44
+ __export(exports_index_node, {
45
+ edgeTTSPlugin: () => edgeTTSPlugin,
46
+ default: () => src_default,
47
+ _test: () => _test
48
+ });
49
+ module.exports = __toCommonJS(exports_index_node);
50
+
51
+ // src/index.ts
52
+ var import_core = require("@elizaos/core");
53
+ var import_node_edge_tts = require("node-edge-tts");
54
+ var import_node_fs = require("node:fs");
55
+ var import_node_os = require("node:os");
56
+ var import_node_path = __toESM(require("node:path"));
57
+ var DEFAULT_VOICE = "en-US-MichelleNeural";
58
+ var DEFAULT_LANG = "en-US";
59
+ var DEFAULT_OUTPUT_FORMAT = "audio-24khz-48kbitrate-mono-mp3";
60
+ var DEFAULT_TIMEOUT_MS = 30000;
61
+ var VOICE_PRESETS = {
62
+ alloy: "en-US-GuyNeural",
63
+ echo: "en-US-ChristopherNeural",
64
+ fable: "en-GB-RyanNeural",
65
+ onyx: "en-US-DavisNeural",
66
+ nova: "en-US-JennyNeural",
67
+ shimmer: "en-US-AriaNeural"
68
+ };
69
+ function getSetting(runtime, key, fallback) {
70
+ const envValue = typeof process !== "undefined" && process.env ? process.env[key] : undefined;
71
+ return runtime.getSetting(key) ?? envValue ?? fallback;
72
+ }
73
+ function getEdgeTTSSettings(runtime) {
74
+ const timeoutStr = getSetting(runtime, "EDGE_TTS_TIMEOUT_MS");
75
+ return {
76
+ voice: getSetting(runtime, "EDGE_TTS_VOICE", DEFAULT_VOICE) ?? DEFAULT_VOICE,
77
+ lang: getSetting(runtime, "EDGE_TTS_LANG", DEFAULT_LANG) ?? DEFAULT_LANG,
78
+ outputFormat: getSetting(runtime, "EDGE_TTS_OUTPUT_FORMAT", DEFAULT_OUTPUT_FORMAT) ?? DEFAULT_OUTPUT_FORMAT,
79
+ rate: getSetting(runtime, "EDGE_TTS_RATE"),
80
+ pitch: getSetting(runtime, "EDGE_TTS_PITCH"),
81
+ volume: getSetting(runtime, "EDGE_TTS_VOLUME"),
82
+ proxy: getSetting(runtime, "EDGE_TTS_PROXY"),
83
+ timeoutMs: timeoutStr ? Number.parseInt(timeoutStr, 10) : DEFAULT_TIMEOUT_MS
84
+ };
85
+ }
86
+ function resolveVoice(voice, defaultVoice) {
87
+ if (!voice)
88
+ return defaultVoice;
89
+ const preset = VOICE_PRESETS[voice.toLowerCase()];
90
+ if (preset)
91
+ return preset;
92
+ return voice;
93
+ }
94
+ function speedToRate(speed) {
95
+ if (speed === undefined || speed === 1)
96
+ return;
97
+ const percentage = Math.round((speed - 1) * 100);
98
+ return percentage >= 0 ? `+${percentage}%` : `${percentage}%`;
99
+ }
100
+ function inferExtension(outputFormat) {
101
+ const normalized = outputFormat.toLowerCase();
102
+ if (normalized.includes("webm"))
103
+ return ".webm";
104
+ if (normalized.includes("ogg"))
105
+ return ".ogg";
106
+ if (normalized.includes("opus"))
107
+ return ".opus";
108
+ if (normalized.includes("wav") || normalized.includes("riff") || normalized.includes("pcm")) {
109
+ return ".wav";
110
+ }
111
+ return ".mp3";
112
+ }
113
+ async function generateSpeech(settings, params) {
114
+ const voice = resolveVoice(params.voice, settings.voice);
115
+ const lang = params.lang ?? settings.lang;
116
+ const outputFormat = params.outputFormat ?? settings.outputFormat;
117
+ const rate = params.rate ?? speedToRate(params.speed) ?? settings.rate;
118
+ const pitch = params.pitch ?? settings.pitch;
119
+ const volume = params.volume ?? settings.volume;
120
+ import_core.logger.debug(`[EdgeTTS] Generating speech with voice: ${voice}, lang: ${lang}`);
121
+ const tts = new import_node_edge_tts.EdgeTTS({
122
+ voice,
123
+ lang,
124
+ outputFormat,
125
+ saveSubtitles: false,
126
+ proxy: settings.proxy,
127
+ rate,
128
+ pitch,
129
+ volume,
130
+ timeout: settings.timeoutMs
131
+ });
132
+ const tempDir = import_node_fs.mkdtempSync(import_node_path.default.join(import_node_os.tmpdir(), "edge-tts-"));
133
+ const extension = inferExtension(outputFormat);
134
+ const outputPath = import_node_path.default.join(tempDir, `speech${extension}`);
135
+ try {
136
+ await tts.ttsPromise(params.text, outputPath);
137
+ const audioBuffer = import_node_fs.readFileSync(outputPath);
138
+ return audioBuffer;
139
+ } finally {
140
+ try {
141
+ import_node_fs.rmSync(tempDir, { recursive: true, force: true });
142
+ } catch {}
143
+ }
144
+ }
145
+ var edgeTTSPlugin = {
146
+ name: "edge-tts",
147
+ description: "Free text-to-speech synthesis using Microsoft Edge TTS - no API key required, high-quality neural voices",
148
+ models: {
149
+ [import_core.ModelType.TEXT_TO_SPEECH]: async (runtime, input) => {
150
+ const params = typeof input === "string" ? { text: input } : input;
151
+ const settings = getEdgeTTSSettings(runtime);
152
+ import_core.logger.log(`[EdgeTTS] Using TEXT_TO_SPEECH with voice: ${settings.voice}`);
153
+ if (!params.text || params.text.trim().length === 0) {
154
+ throw new Error("TEXT_TO_SPEECH requires non-empty text");
155
+ }
156
+ if (params.text.length > 5000) {
157
+ throw new Error("TEXT_TO_SPEECH text exceeds 5000 character limit");
158
+ }
159
+ try {
160
+ const audioBuffer = await generateSpeech(settings, params);
161
+ return audioBuffer;
162
+ } catch (error) {
163
+ const msg = error instanceof Error ? error.message : String(error);
164
+ import_core.logger.error(`EdgeTTS model error: ${msg}`);
165
+ throw error instanceof Error ? error : new Error(msg);
166
+ }
167
+ }
168
+ },
169
+ tests: [
170
+ {
171
+ name: "test edge tts",
172
+ tests: [
173
+ {
174
+ name: "Edge TTS settings validation",
175
+ fn: async (runtime) => {
176
+ const settings = getEdgeTTSSettings(runtime);
177
+ if (!settings.voice) {
178
+ throw new Error("Missing voice configuration");
179
+ }
180
+ if (!settings.lang) {
181
+ throw new Error("Missing language configuration");
182
+ }
183
+ if (!settings.outputFormat) {
184
+ throw new Error("Missing output format configuration");
185
+ }
186
+ import_core.logger.success("Edge TTS settings validated successfully");
187
+ }
188
+ },
189
+ {
190
+ name: "Edge TTS voice preset mapping",
191
+ fn: async (_runtime) => {
192
+ const testCases = [
193
+ { input: "alloy", expected: "en-US-GuyNeural" },
194
+ { input: "nova", expected: "en-US-JennyNeural" },
195
+ { input: "shimmer", expected: "en-US-AriaNeural" },
196
+ {
197
+ input: "en-US-MichelleNeural",
198
+ expected: "en-US-MichelleNeural"
199
+ }
200
+ ];
201
+ for (const tc of testCases) {
202
+ const result = resolveVoice(tc.input, DEFAULT_VOICE);
203
+ if (result !== tc.expected) {
204
+ throw new Error(`Voice preset mapping failed: ${tc.input} -> ${result}, expected ${tc.expected}`);
205
+ }
206
+ }
207
+ import_core.logger.success("Voice preset mapping validated successfully");
208
+ }
209
+ },
210
+ {
211
+ name: "Edge TTS speed to rate conversion",
212
+ fn: async (_runtime) => {
213
+ const testCases = [
214
+ { speed: 1, expected: undefined },
215
+ { speed: 1.5, expected: "+50%" },
216
+ { speed: 0.75, expected: "-25%" },
217
+ { speed: 2, expected: "+100%" }
218
+ ];
219
+ for (const tc of testCases) {
220
+ const result = speedToRate(tc.speed);
221
+ if (result !== tc.expected) {
222
+ throw new Error(`Speed conversion failed: ${tc.speed} -> ${result}, expected ${tc.expected}`);
223
+ }
224
+ }
225
+ import_core.logger.success("Speed to rate conversion validated successfully");
226
+ }
227
+ },
228
+ {
229
+ name: "Edge TTS generation (live test)",
230
+ fn: async (runtime) => {
231
+ const testText = "Hello, this is a test of Edge TTS.";
232
+ try {
233
+ const audioBuffer = await runtime.useModel(import_core.ModelType.TEXT_TO_SPEECH, testText);
234
+ if (!audioBuffer || audioBuffer.length === 0) {
235
+ throw new Error("Received empty audio buffer");
236
+ }
237
+ import_core.logger.success(`Edge TTS generation successful: ${audioBuffer.length} bytes`);
238
+ } catch (error) {
239
+ const msg = error instanceof Error ? error.message : String(error);
240
+ if (msg.includes("ENOTFOUND") || msg.includes("network")) {
241
+ import_core.logger.warn(`Edge TTS live test skipped (network unavailable): ${msg}`);
242
+ return;
243
+ }
244
+ throw error;
245
+ }
246
+ }
247
+ }
248
+ ]
249
+ }
250
+ ]
251
+ };
252
+ var src_default = edgeTTSPlugin;
253
+ var _test = {
254
+ resolveVoice,
255
+ speedToRate,
256
+ inferExtension,
257
+ getEdgeTTSSettings
258
+ };
259
+
260
+ //# debugId=6DA30A60C438586E64756E2164756E21
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/index.ts"],
4
+ "sourcesContent": [
5
+ "import {\n type IAgentRuntime,\n ModelType,\n type Plugin,\n logger,\n} from \"@elizaos/core\";\nimport { EdgeTTS } from \"node-edge-tts\";\nimport { mkdtempSync, rmSync, readFileSync } from \"node:fs\";\nimport { tmpdir } from \"node:os\";\nimport path from \"node:path\";\n\n/**\n * Edge TTS voice settings configuration\n */\ninterface EdgeTTSSettings {\n voice: string;\n lang: string;\n outputFormat: string;\n rate?: string;\n pitch?: string;\n volume?: string;\n proxy?: string;\n timeoutMs: number;\n}\n\n/**\n * Extended TTS params with Edge-specific options\n */\ninterface EdgeTTSParams {\n text: string;\n voice?: string;\n speed?: number;\n /** Edge TTS specific: language code */\n lang?: string;\n /** Edge TTS specific: output format */\n outputFormat?: string;\n /** Edge TTS specific: rate adjustment (e.g., +10%, -5%) */\n rate?: string;\n /** Edge TTS specific: pitch adjustment (e.g., +5Hz, -10Hz) */\n pitch?: string;\n /** Edge TTS specific: volume adjustment (e.g., +20%, -10%) */\n volume?: string;\n}\n\n// Default voice configurations\nconst DEFAULT_VOICE = \"en-US-MichelleNeural\";\nconst DEFAULT_LANG = \"en-US\";\nconst DEFAULT_OUTPUT_FORMAT = \"audio-24khz-48kbitrate-mono-mp3\";\nconst DEFAULT_TIMEOUT_MS = 30000;\n\n// Voice presets mapping common voice names to Edge TTS voices\nconst VOICE_PRESETS: Record<string, string> = {\n // Generic voices (map to good defaults)\n alloy: \"en-US-GuyNeural\",\n echo: \"en-US-ChristopherNeural\",\n fable: \"en-GB-RyanNeural\",\n onyx: \"en-US-DavisNeural\",\n nova: \"en-US-JennyNeural\",\n shimmer: \"en-US-AriaNeural\",\n // Direct Edge TTS voice names pass through\n};\n\nfunction getSetting(\n runtime: IAgentRuntime,\n key: string,\n fallback?: string,\n): string | undefined {\n const envValue =\n typeof process !== \"undefined\" &&\n (process as { env?: Record<string, string> }).env\n ? (process as { env: Record<string, string> }).env[key]\n : undefined;\n return (\n (runtime.getSetting(key) as string | undefined) ?? envValue ?? fallback\n );\n}\n\nfunction getEdgeTTSSettings(runtime: IAgentRuntime): EdgeTTSSettings {\n const timeoutStr = getSetting(runtime, \"EDGE_TTS_TIMEOUT_MS\");\n return {\n voice:\n getSetting(runtime, \"EDGE_TTS_VOICE\", DEFAULT_VOICE) ?? DEFAULT_VOICE,\n lang: getSetting(runtime, \"EDGE_TTS_LANG\", DEFAULT_LANG) ?? DEFAULT_LANG,\n outputFormat:\n getSetting(runtime, \"EDGE_TTS_OUTPUT_FORMAT\", DEFAULT_OUTPUT_FORMAT) ??\n DEFAULT_OUTPUT_FORMAT,\n rate: getSetting(runtime, \"EDGE_TTS_RATE\"),\n pitch: getSetting(runtime, \"EDGE_TTS_PITCH\"),\n volume: getSetting(runtime, \"EDGE_TTS_VOLUME\"),\n proxy: getSetting(runtime, \"EDGE_TTS_PROXY\"),\n timeoutMs: timeoutStr\n ? Number.parseInt(timeoutStr, 10)\n : DEFAULT_TIMEOUT_MS,\n };\n}\n\n/**\n * Resolve voice name - handles OpenAI-style voice names and Edge TTS voice IDs\n */\nfunction resolveVoice(voice: string | undefined, defaultVoice: string): string {\n if (!voice) return defaultVoice;\n\n // Check if it's a preset name\n const preset = VOICE_PRESETS[voice.toLowerCase()];\n if (preset) return preset;\n\n // Assume it's a direct Edge TTS voice ID\n return voice;\n}\n\n/**\n * Convert speed multiplier to Edge TTS rate string\n * speed: 1.0 = normal, 0.5 = half speed, 2.0 = double speed\n */\nfunction speedToRate(speed: number | undefined): string | undefined {\n if (speed === undefined || speed === 1.0) return undefined;\n const percentage = Math.round((speed - 1) * 100);\n return percentage >= 0 ? `+${percentage}%` : `${percentage}%`;\n}\n\n/**\n * Infer file extension from Edge TTS output format\n */\nfunction inferExtension(outputFormat: string): string {\n const normalized = outputFormat.toLowerCase();\n if (normalized.includes(\"webm\")) return \".webm\";\n if (normalized.includes(\"ogg\")) return \".ogg\";\n if (normalized.includes(\"opus\")) return \".opus\";\n if (\n normalized.includes(\"wav\") ||\n normalized.includes(\"riff\") ||\n normalized.includes(\"pcm\")\n ) {\n return \".wav\";\n }\n return \".mp3\";\n}\n\n/**\n * Generate speech using Microsoft Edge TTS\n */\nasync function generateSpeech(\n settings: EdgeTTSSettings,\n params: EdgeTTSParams,\n): Promise<Buffer> {\n const voice = resolveVoice(params.voice, settings.voice);\n const lang = params.lang ?? settings.lang;\n const outputFormat = params.outputFormat ?? settings.outputFormat;\n const rate = params.rate ?? speedToRate(params.speed) ?? settings.rate;\n const pitch = params.pitch ?? settings.pitch;\n const volume = params.volume ?? settings.volume;\n\n logger.debug(\n `[EdgeTTS] Generating speech with voice: ${voice}, lang: ${lang}`,\n );\n\n const tts = new EdgeTTS({\n voice,\n lang,\n outputFormat,\n saveSubtitles: false,\n proxy: settings.proxy,\n rate,\n pitch,\n volume,\n timeout: settings.timeoutMs,\n });\n\n // Create temp directory for output\n const tempDir = mkdtempSync(path.join(tmpdir(), \"edge-tts-\"));\n const extension = inferExtension(outputFormat);\n const outputPath = path.join(tempDir, `speech${extension}`);\n\n try {\n await tts.ttsPromise(params.text, outputPath);\n const audioBuffer = readFileSync(outputPath);\n return audioBuffer;\n } finally {\n // Cleanup temp directory\n try {\n rmSync(tempDir, { recursive: true, force: true });\n } catch {\n // Ignore cleanup errors\n }\n }\n}\n\n/**\n * Edge TTS Plugin for ElizaOS\n *\n * Provides free text-to-speech synthesis using Microsoft Edge's TTS service.\n * No API key required - uses the same TTS engine as Microsoft Edge browser.\n *\n * Features:\n * - High-quality neural voices\n * - Multiple languages and locales\n * - Adjustable rate, pitch, and volume\n * - No API key or payment required\n *\n * Optional environment variables:\n * - EDGE_TTS_VOICE: Voice ID (default: en-US-MichelleNeural)\n * - EDGE_TTS_LANG: Language code (default: en-US)\n * - EDGE_TTS_OUTPUT_FORMAT: Output format (default: audio-24khz-48kbitrate-mono-mp3)\n * - EDGE_TTS_RATE: Speech rate adjustment (e.g., +10%, -5%)\n * - EDGE_TTS_PITCH: Pitch adjustment (e.g., +5Hz, -10Hz)\n * - EDGE_TTS_VOLUME: Volume adjustment (e.g., +20%, -10%)\n * - EDGE_TTS_PROXY: HTTP proxy URL\n * - EDGE_TTS_TIMEOUT_MS: Request timeout (default: 30000)\n *\n * Popular voices:\n * - en-US-MichelleNeural (female, US English)\n * - en-US-GuyNeural (male, US English)\n * - en-US-JennyNeural (female, US English)\n * - en-US-AriaNeural (female, US English)\n * - en-GB-SoniaNeural (female, UK English)\n * - en-GB-RyanNeural (male, UK English)\n * - de-DE-KatjaNeural (female, German)\n * - fr-FR-DeniseNeural (female, French)\n * - es-ES-ElviraNeural (female, Spanish)\n * - ja-JP-NanamiNeural (female, Japanese)\n * - zh-CN-XiaoxiaoNeural (female, Chinese)\n */\nexport const edgeTTSPlugin: Plugin = {\n name: \"edge-tts\",\n description:\n \"Free text-to-speech synthesis using Microsoft Edge TTS - no API key required, high-quality neural voices\",\n models: {\n [ModelType.TEXT_TO_SPEECH]: async (\n runtime: IAgentRuntime,\n input: string | EdgeTTSParams,\n ): Promise<Buffer | ArrayBuffer | Uint8Array> => {\n const params: EdgeTTSParams =\n typeof input === \"string\" ? { text: input } : input;\n const settings = getEdgeTTSSettings(runtime);\n\n logger.log(\n `[EdgeTTS] Using TEXT_TO_SPEECH with voice: ${settings.voice}`,\n );\n\n if (!params.text || params.text.trim().length === 0) {\n throw new Error(\"TEXT_TO_SPEECH requires non-empty text\");\n }\n\n // Edge TTS has a practical limit around 5000 characters\n if (params.text.length > 5000) {\n throw new Error(\"TEXT_TO_SPEECH text exceeds 5000 character limit\");\n }\n\n try {\n const audioBuffer = await generateSpeech(settings, params);\n return audioBuffer;\n } catch (error: unknown) {\n const msg = error instanceof Error ? error.message : String(error);\n logger.error(`EdgeTTS model error: ${msg}`);\n throw error instanceof Error ? error : new Error(msg);\n }\n },\n },\n tests: [\n {\n name: \"test edge tts\",\n tests: [\n {\n name: \"Edge TTS settings validation\",\n fn: async (runtime: IAgentRuntime) => {\n const settings = getEdgeTTSSettings(runtime);\n\n if (!settings.voice) {\n throw new Error(\"Missing voice configuration\");\n }\n\n if (!settings.lang) {\n throw new Error(\"Missing language configuration\");\n }\n\n if (!settings.outputFormat) {\n throw new Error(\"Missing output format configuration\");\n }\n\n logger.success(\"Edge TTS settings validated successfully\");\n },\n },\n {\n name: \"Edge TTS voice preset mapping\",\n fn: async (_runtime: IAgentRuntime) => {\n // Test that OpenAI-style voice names map correctly\n const testCases = [\n { input: \"alloy\", expected: \"en-US-GuyNeural\" },\n { input: \"nova\", expected: \"en-US-JennyNeural\" },\n { input: \"shimmer\", expected: \"en-US-AriaNeural\" },\n {\n input: \"en-US-MichelleNeural\",\n expected: \"en-US-MichelleNeural\",\n },\n ];\n\n for (const tc of testCases) {\n const result = resolveVoice(tc.input, DEFAULT_VOICE);\n if (result !== tc.expected) {\n throw new Error(\n `Voice preset mapping failed: ${tc.input} -> ${result}, expected ${tc.expected}`,\n );\n }\n }\n\n logger.success(\"Voice preset mapping validated successfully\");\n },\n },\n {\n name: \"Edge TTS speed to rate conversion\",\n fn: async (_runtime: IAgentRuntime) => {\n const testCases = [\n { speed: 1.0, expected: undefined },\n { speed: 1.5, expected: \"+50%\" },\n { speed: 0.75, expected: \"-25%\" },\n { speed: 2.0, expected: \"+100%\" },\n ];\n\n for (const tc of testCases) {\n const result = speedToRate(tc.speed);\n if (result !== tc.expected) {\n throw new Error(\n `Speed conversion failed: ${tc.speed} -> ${result}, expected ${tc.expected}`,\n );\n }\n }\n\n logger.success(\"Speed to rate conversion validated successfully\");\n },\n },\n {\n name: \"Edge TTS generation (live test)\",\n fn: async (runtime: IAgentRuntime) => {\n const testText = \"Hello, this is a test of Edge TTS.\";\n\n try {\n const audioBuffer = (await runtime.useModel(\n ModelType.TEXT_TO_SPEECH,\n testText,\n )) as Buffer | Uint8Array;\n\n if (!audioBuffer || audioBuffer.length === 0) {\n throw new Error(\"Received empty audio buffer\");\n }\n\n logger.success(\n `Edge TTS generation successful: ${audioBuffer.length} bytes`,\n );\n } catch (error: unknown) {\n const msg =\n error instanceof Error ? error.message : String(error);\n // Edge TTS might fail in CI environments without network\n if (msg.includes(\"ENOTFOUND\") || msg.includes(\"network\")) {\n logger.warn(\n `Edge TTS live test skipped (network unavailable): ${msg}`,\n );\n return;\n }\n throw error;\n }\n },\n },\n ],\n },\n ],\n};\n\nexport default edgeTTSPlugin;\n\n// Re-export types\nexport type { EdgeTTSSettings, EdgeTTSParams };\n\n// Export helper functions for testing\nexport const _test = {\n resolveVoice,\n speedToRate,\n inferExtension,\n getEdgeTTSSettings,\n};\n"
6
+ ],
7
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKO,IALP;AAMwB,IAAxB;AACkD,IA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iDAAiD;AAAA;AAAA,QAEpE;AAAA,QACA;AAAA,UACE,MAAM;AAAA,UACN,IAAI,OAAO,YAA2B;AAAA,YACpC,MAAM,WAAW;AAAA,YAEjB,IAAI;AAAA,cACF,MAAM,cAAe,MAAM,QAAQ,SACjC,sBAAU,gBACV,QACF;AAAA,cAEA,IAAI,CAAC,eAAe,YAAY,WAAW,GAAG;AAAA,gBAC5C,MAAM,IAAI,MAAM,6BAA6B;AAAA,cAC/C;AAAA,cAEA,mBAAO,QACL,mCAAmC,YAAY,cACjD;AAAA,cACA,OAAO,OAAgB;AAAA,cACvB,MAAM,MACJ,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AAAA,cAEvD,IAAI,IAAI,SAAS,WAAW,KAAK,IAAI,SAAS,SAAS,GAAG;AAAA,gBACxD,mBAAO,KACL,qDAAqD,KACvD;AAAA,gBACA;AAAA,cACF;AAAA,cACA,MAAM;AAAA;AAAA;AAAA,QAGZ;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;AAEA,IAAe;AAMR,IAAM,QAAQ;AAAA,EACnB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;",
8
+ "debugId": "6DA30A60C438586E64756E2164756E21",
9
+ "names": []
10
+ }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Browser entry point for @elizaos/plugin-edge-tts
3
+ *
4
+ * Edge TTS is not available in browser environments because it requires
5
+ * Node.js file system access and WebSocket connections that browsers don't support.
6
+ *
7
+ * For browser TTS, use @elizaos/plugin-elevenlabs or @elizaos/plugin-openai instead.
8
+ */
9
+ import { type Plugin } from "@elizaos/core";
10
+ export declare const edgeTTSPlugin: Plugin;
11
+ export default edgeTTSPlugin;
@@ -0,0 +1,90 @@
1
+ import { type IAgentRuntime, type Plugin } from "@elizaos/core";
2
+ /**
3
+ * Edge TTS voice settings configuration
4
+ */
5
+ interface EdgeTTSSettings {
6
+ voice: string;
7
+ lang: string;
8
+ outputFormat: string;
9
+ rate?: string;
10
+ pitch?: string;
11
+ volume?: string;
12
+ proxy?: string;
13
+ timeoutMs: number;
14
+ }
15
+ /**
16
+ * Extended TTS params with Edge-specific options
17
+ */
18
+ interface EdgeTTSParams {
19
+ text: string;
20
+ voice?: string;
21
+ speed?: number;
22
+ /** Edge TTS specific: language code */
23
+ lang?: string;
24
+ /** Edge TTS specific: output format */
25
+ outputFormat?: string;
26
+ /** Edge TTS specific: rate adjustment (e.g., +10%, -5%) */
27
+ rate?: string;
28
+ /** Edge TTS specific: pitch adjustment (e.g., +5Hz, -10Hz) */
29
+ pitch?: string;
30
+ /** Edge TTS specific: volume adjustment (e.g., +20%, -10%) */
31
+ volume?: string;
32
+ }
33
+ declare function getEdgeTTSSettings(runtime: IAgentRuntime): EdgeTTSSettings;
34
+ /**
35
+ * Resolve voice name - handles OpenAI-style voice names and Edge TTS voice IDs
36
+ */
37
+ declare function resolveVoice(voice: string | undefined, defaultVoice: string): string;
38
+ /**
39
+ * Convert speed multiplier to Edge TTS rate string
40
+ * speed: 1.0 = normal, 0.5 = half speed, 2.0 = double speed
41
+ */
42
+ declare function speedToRate(speed: number | undefined): string | undefined;
43
+ /**
44
+ * Infer file extension from Edge TTS output format
45
+ */
46
+ declare function inferExtension(outputFormat: string): string;
47
+ /**
48
+ * Edge TTS Plugin for ElizaOS
49
+ *
50
+ * Provides free text-to-speech synthesis using Microsoft Edge's TTS service.
51
+ * No API key required - uses the same TTS engine as Microsoft Edge browser.
52
+ *
53
+ * Features:
54
+ * - High-quality neural voices
55
+ * - Multiple languages and locales
56
+ * - Adjustable rate, pitch, and volume
57
+ * - No API key or payment required
58
+ *
59
+ * Optional environment variables:
60
+ * - EDGE_TTS_VOICE: Voice ID (default: en-US-MichelleNeural)
61
+ * - EDGE_TTS_LANG: Language code (default: en-US)
62
+ * - EDGE_TTS_OUTPUT_FORMAT: Output format (default: audio-24khz-48kbitrate-mono-mp3)
63
+ * - EDGE_TTS_RATE: Speech rate adjustment (e.g., +10%, -5%)
64
+ * - EDGE_TTS_PITCH: Pitch adjustment (e.g., +5Hz, -10Hz)
65
+ * - EDGE_TTS_VOLUME: Volume adjustment (e.g., +20%, -10%)
66
+ * - EDGE_TTS_PROXY: HTTP proxy URL
67
+ * - EDGE_TTS_TIMEOUT_MS: Request timeout (default: 30000)
68
+ *
69
+ * Popular voices:
70
+ * - en-US-MichelleNeural (female, US English)
71
+ * - en-US-GuyNeural (male, US English)
72
+ * - en-US-JennyNeural (female, US English)
73
+ * - en-US-AriaNeural (female, US English)
74
+ * - en-GB-SoniaNeural (female, UK English)
75
+ * - en-GB-RyanNeural (male, UK English)
76
+ * - de-DE-KatjaNeural (female, German)
77
+ * - fr-FR-DeniseNeural (female, French)
78
+ * - es-ES-ElviraNeural (female, Spanish)
79
+ * - ja-JP-NanamiNeural (female, Japanese)
80
+ * - zh-CN-XiaoxiaoNeural (female, Chinese)
81
+ */
82
+ export declare const edgeTTSPlugin: Plugin;
83
+ export default edgeTTSPlugin;
84
+ export type { EdgeTTSSettings, EdgeTTSParams };
85
+ export declare const _test: {
86
+ resolveVoice: typeof resolveVoice;
87
+ speedToRate: typeof speedToRate;
88
+ inferExtension: typeof inferExtension;
89
+ getEdgeTTSSettings: typeof getEdgeTTSSettings;
90
+ };
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Node.js entry point for @elizaos/plugin-edge-tts
3
+ * Edge TTS requires Node.js for file system access
4
+ */
5
+ export * from "./index";
6
+ export { default } from "./index";
@@ -0,0 +1,2 @@
1
+ export * from '../index';
2
+ export { default } from '../index';
@@ -0,0 +1,218 @@
1
+ // src/index.ts
2
+ import {
3
+ ModelType,
4
+ logger
5
+ } from "@elizaos/core";
6
+ import { EdgeTTS } from "node-edge-tts";
7
+ import { mkdtempSync, rmSync, readFileSync } from "node:fs";
8
+ import { tmpdir } from "node:os";
9
+ import path from "node:path";
10
+ var DEFAULT_VOICE = "en-US-MichelleNeural";
11
+ var DEFAULT_LANG = "en-US";
12
+ var DEFAULT_OUTPUT_FORMAT = "audio-24khz-48kbitrate-mono-mp3";
13
+ var DEFAULT_TIMEOUT_MS = 30000;
14
+ var VOICE_PRESETS = {
15
+ alloy: "en-US-GuyNeural",
16
+ echo: "en-US-ChristopherNeural",
17
+ fable: "en-GB-RyanNeural",
18
+ onyx: "en-US-DavisNeural",
19
+ nova: "en-US-JennyNeural",
20
+ shimmer: "en-US-AriaNeural"
21
+ };
22
+ function getSetting(runtime, key, fallback) {
23
+ const envValue = typeof process !== "undefined" && process.env ? process.env[key] : undefined;
24
+ return runtime.getSetting(key) ?? envValue ?? fallback;
25
+ }
26
+ function getEdgeTTSSettings(runtime) {
27
+ const timeoutStr = getSetting(runtime, "EDGE_TTS_TIMEOUT_MS");
28
+ return {
29
+ voice: getSetting(runtime, "EDGE_TTS_VOICE", DEFAULT_VOICE) ?? DEFAULT_VOICE,
30
+ lang: getSetting(runtime, "EDGE_TTS_LANG", DEFAULT_LANG) ?? DEFAULT_LANG,
31
+ outputFormat: getSetting(runtime, "EDGE_TTS_OUTPUT_FORMAT", DEFAULT_OUTPUT_FORMAT) ?? DEFAULT_OUTPUT_FORMAT,
32
+ rate: getSetting(runtime, "EDGE_TTS_RATE"),
33
+ pitch: getSetting(runtime, "EDGE_TTS_PITCH"),
34
+ volume: getSetting(runtime, "EDGE_TTS_VOLUME"),
35
+ proxy: getSetting(runtime, "EDGE_TTS_PROXY"),
36
+ timeoutMs: timeoutStr ? Number.parseInt(timeoutStr, 10) : DEFAULT_TIMEOUT_MS
37
+ };
38
+ }
39
+ function resolveVoice(voice, defaultVoice) {
40
+ if (!voice)
41
+ return defaultVoice;
42
+ const preset = VOICE_PRESETS[voice.toLowerCase()];
43
+ if (preset)
44
+ return preset;
45
+ return voice;
46
+ }
47
+ function speedToRate(speed) {
48
+ if (speed === undefined || speed === 1)
49
+ return;
50
+ const percentage = Math.round((speed - 1) * 100);
51
+ return percentage >= 0 ? `+${percentage}%` : `${percentage}%`;
52
+ }
53
+ function inferExtension(outputFormat) {
54
+ const normalized = outputFormat.toLowerCase();
55
+ if (normalized.includes("webm"))
56
+ return ".webm";
57
+ if (normalized.includes("ogg"))
58
+ return ".ogg";
59
+ if (normalized.includes("opus"))
60
+ return ".opus";
61
+ if (normalized.includes("wav") || normalized.includes("riff") || normalized.includes("pcm")) {
62
+ return ".wav";
63
+ }
64
+ return ".mp3";
65
+ }
66
+ async function generateSpeech(settings, params) {
67
+ const voice = resolveVoice(params.voice, settings.voice);
68
+ const lang = params.lang ?? settings.lang;
69
+ const outputFormat = params.outputFormat ?? settings.outputFormat;
70
+ const rate = params.rate ?? speedToRate(params.speed) ?? settings.rate;
71
+ const pitch = params.pitch ?? settings.pitch;
72
+ const volume = params.volume ?? settings.volume;
73
+ logger.debug(`[EdgeTTS] Generating speech with voice: ${voice}, lang: ${lang}`);
74
+ const tts = new EdgeTTS({
75
+ voice,
76
+ lang,
77
+ outputFormat,
78
+ saveSubtitles: false,
79
+ proxy: settings.proxy,
80
+ rate,
81
+ pitch,
82
+ volume,
83
+ timeout: settings.timeoutMs
84
+ });
85
+ const tempDir = mkdtempSync(path.join(tmpdir(), "edge-tts-"));
86
+ const extension = inferExtension(outputFormat);
87
+ const outputPath = path.join(tempDir, `speech${extension}`);
88
+ try {
89
+ await tts.ttsPromise(params.text, outputPath);
90
+ const audioBuffer = readFileSync(outputPath);
91
+ return audioBuffer;
92
+ } finally {
93
+ try {
94
+ rmSync(tempDir, { recursive: true, force: true });
95
+ } catch {}
96
+ }
97
+ }
98
+ var edgeTTSPlugin = {
99
+ name: "edge-tts",
100
+ description: "Free text-to-speech synthesis using Microsoft Edge TTS - no API key required, high-quality neural voices",
101
+ models: {
102
+ [ModelType.TEXT_TO_SPEECH]: async (runtime, input) => {
103
+ const params = typeof input === "string" ? { text: input } : input;
104
+ const settings = getEdgeTTSSettings(runtime);
105
+ logger.log(`[EdgeTTS] Using TEXT_TO_SPEECH with voice: ${settings.voice}`);
106
+ if (!params.text || params.text.trim().length === 0) {
107
+ throw new Error("TEXT_TO_SPEECH requires non-empty text");
108
+ }
109
+ if (params.text.length > 5000) {
110
+ throw new Error("TEXT_TO_SPEECH text exceeds 5000 character limit");
111
+ }
112
+ try {
113
+ const audioBuffer = await generateSpeech(settings, params);
114
+ return audioBuffer;
115
+ } catch (error) {
116
+ const msg = error instanceof Error ? error.message : String(error);
117
+ logger.error(`EdgeTTS model error: ${msg}`);
118
+ throw error instanceof Error ? error : new Error(msg);
119
+ }
120
+ }
121
+ },
122
+ tests: [
123
+ {
124
+ name: "test edge tts",
125
+ tests: [
126
+ {
127
+ name: "Edge TTS settings validation",
128
+ fn: async (runtime) => {
129
+ const settings = getEdgeTTSSettings(runtime);
130
+ if (!settings.voice) {
131
+ throw new Error("Missing voice configuration");
132
+ }
133
+ if (!settings.lang) {
134
+ throw new Error("Missing language configuration");
135
+ }
136
+ if (!settings.outputFormat) {
137
+ throw new Error("Missing output format configuration");
138
+ }
139
+ logger.success("Edge TTS settings validated successfully");
140
+ }
141
+ },
142
+ {
143
+ name: "Edge TTS voice preset mapping",
144
+ fn: async (_runtime) => {
145
+ const testCases = [
146
+ { input: "alloy", expected: "en-US-GuyNeural" },
147
+ { input: "nova", expected: "en-US-JennyNeural" },
148
+ { input: "shimmer", expected: "en-US-AriaNeural" },
149
+ {
150
+ input: "en-US-MichelleNeural",
151
+ expected: "en-US-MichelleNeural"
152
+ }
153
+ ];
154
+ for (const tc of testCases) {
155
+ const result = resolveVoice(tc.input, DEFAULT_VOICE);
156
+ if (result !== tc.expected) {
157
+ throw new Error(`Voice preset mapping failed: ${tc.input} -> ${result}, expected ${tc.expected}`);
158
+ }
159
+ }
160
+ logger.success("Voice preset mapping validated successfully");
161
+ }
162
+ },
163
+ {
164
+ name: "Edge TTS speed to rate conversion",
165
+ fn: async (_runtime) => {
166
+ const testCases = [
167
+ { speed: 1, expected: undefined },
168
+ { speed: 1.5, expected: "+50%" },
169
+ { speed: 0.75, expected: "-25%" },
170
+ { speed: 2, expected: "+100%" }
171
+ ];
172
+ for (const tc of testCases) {
173
+ const result = speedToRate(tc.speed);
174
+ if (result !== tc.expected) {
175
+ throw new Error(`Speed conversion failed: ${tc.speed} -> ${result}, expected ${tc.expected}`);
176
+ }
177
+ }
178
+ logger.success("Speed to rate conversion validated successfully");
179
+ }
180
+ },
181
+ {
182
+ name: "Edge TTS generation (live test)",
183
+ fn: async (runtime) => {
184
+ const testText = "Hello, this is a test of Edge TTS.";
185
+ try {
186
+ const audioBuffer = await runtime.useModel(ModelType.TEXT_TO_SPEECH, testText);
187
+ if (!audioBuffer || audioBuffer.length === 0) {
188
+ throw new Error("Received empty audio buffer");
189
+ }
190
+ logger.success(`Edge TTS generation successful: ${audioBuffer.length} bytes`);
191
+ } catch (error) {
192
+ const msg = error instanceof Error ? error.message : String(error);
193
+ if (msg.includes("ENOTFOUND") || msg.includes("network")) {
194
+ logger.warn(`Edge TTS live test skipped (network unavailable): ${msg}`);
195
+ return;
196
+ }
197
+ throw error;
198
+ }
199
+ }
200
+ }
201
+ ]
202
+ }
203
+ ]
204
+ };
205
+ var src_default = edgeTTSPlugin;
206
+ var _test = {
207
+ resolveVoice,
208
+ speedToRate,
209
+ inferExtension,
210
+ getEdgeTTSSettings
211
+ };
212
+ export {
213
+ edgeTTSPlugin,
214
+ src_default as default,
215
+ _test
216
+ };
217
+
218
+ //# debugId=28C367D7AB4B82D264756E2164756E21
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/index.ts"],
4
+ "sourcesContent": [
5
+ "import {\n type IAgentRuntime,\n ModelType,\n type Plugin,\n logger,\n} from \"@elizaos/core\";\nimport { EdgeTTS } from \"node-edge-tts\";\nimport { mkdtempSync, rmSync, readFileSync } from \"node:fs\";\nimport { tmpdir } from \"node:os\";\nimport path from \"node:path\";\n\n/**\n * Edge TTS voice settings configuration\n */\ninterface EdgeTTSSettings {\n voice: string;\n lang: string;\n outputFormat: string;\n rate?: string;\n pitch?: string;\n volume?: string;\n proxy?: string;\n timeoutMs: number;\n}\n\n/**\n * Extended TTS params with Edge-specific options\n */\ninterface EdgeTTSParams {\n text: string;\n voice?: string;\n speed?: number;\n /** Edge TTS specific: language code */\n lang?: string;\n /** Edge TTS specific: output format */\n outputFormat?: string;\n /** Edge TTS specific: rate adjustment (e.g., +10%, -5%) */\n rate?: string;\n /** Edge TTS specific: pitch adjustment (e.g., +5Hz, -10Hz) */\n pitch?: string;\n /** Edge TTS specific: volume adjustment (e.g., +20%, -10%) */\n volume?: string;\n}\n\n// Default voice configurations\nconst DEFAULT_VOICE = \"en-US-MichelleNeural\";\nconst DEFAULT_LANG = \"en-US\";\nconst DEFAULT_OUTPUT_FORMAT = \"audio-24khz-48kbitrate-mono-mp3\";\nconst DEFAULT_TIMEOUT_MS = 30000;\n\n// Voice presets mapping common voice names to Edge TTS voices\nconst VOICE_PRESETS: Record<string, string> = {\n // Generic voices (map to good defaults)\n alloy: \"en-US-GuyNeural\",\n echo: \"en-US-ChristopherNeural\",\n fable: \"en-GB-RyanNeural\",\n onyx: \"en-US-DavisNeural\",\n nova: \"en-US-JennyNeural\",\n shimmer: \"en-US-AriaNeural\",\n // Direct Edge TTS voice names pass through\n};\n\nfunction getSetting(\n runtime: IAgentRuntime,\n key: string,\n fallback?: string,\n): string | undefined {\n const envValue =\n typeof process !== \"undefined\" &&\n (process as { env?: Record<string, string> }).env\n ? (process as { env: Record<string, string> }).env[key]\n : undefined;\n return (\n (runtime.getSetting(key) as string | undefined) ?? envValue ?? fallback\n );\n}\n\nfunction getEdgeTTSSettings(runtime: IAgentRuntime): EdgeTTSSettings {\n const timeoutStr = getSetting(runtime, \"EDGE_TTS_TIMEOUT_MS\");\n return {\n voice:\n getSetting(runtime, \"EDGE_TTS_VOICE\", DEFAULT_VOICE) ?? DEFAULT_VOICE,\n lang: getSetting(runtime, \"EDGE_TTS_LANG\", DEFAULT_LANG) ?? DEFAULT_LANG,\n outputFormat:\n getSetting(runtime, \"EDGE_TTS_OUTPUT_FORMAT\", DEFAULT_OUTPUT_FORMAT) ??\n DEFAULT_OUTPUT_FORMAT,\n rate: getSetting(runtime, \"EDGE_TTS_RATE\"),\n pitch: getSetting(runtime, \"EDGE_TTS_PITCH\"),\n volume: getSetting(runtime, \"EDGE_TTS_VOLUME\"),\n proxy: getSetting(runtime, \"EDGE_TTS_PROXY\"),\n timeoutMs: timeoutStr\n ? Number.parseInt(timeoutStr, 10)\n : DEFAULT_TIMEOUT_MS,\n };\n}\n\n/**\n * Resolve voice name - handles OpenAI-style voice names and Edge TTS voice IDs\n */\nfunction resolveVoice(voice: string | undefined, defaultVoice: string): string {\n if (!voice) return defaultVoice;\n\n // Check if it's a preset name\n const preset = VOICE_PRESETS[voice.toLowerCase()];\n if (preset) return preset;\n\n // Assume it's a direct Edge TTS voice ID\n return voice;\n}\n\n/**\n * Convert speed multiplier to Edge TTS rate string\n * speed: 1.0 = normal, 0.5 = half speed, 2.0 = double speed\n */\nfunction speedToRate(speed: number | undefined): string | undefined {\n if (speed === undefined || speed === 1.0) return undefined;\n const percentage = Math.round((speed - 1) * 100);\n return percentage >= 0 ? `+${percentage}%` : `${percentage}%`;\n}\n\n/**\n * Infer file extension from Edge TTS output format\n */\nfunction inferExtension(outputFormat: string): string {\n const normalized = outputFormat.toLowerCase();\n if (normalized.includes(\"webm\")) return \".webm\";\n if (normalized.includes(\"ogg\")) return \".ogg\";\n if (normalized.includes(\"opus\")) return \".opus\";\n if (\n normalized.includes(\"wav\") ||\n normalized.includes(\"riff\") ||\n normalized.includes(\"pcm\")\n ) {\n return \".wav\";\n }\n return \".mp3\";\n}\n\n/**\n * Generate speech using Microsoft Edge TTS\n */\nasync function generateSpeech(\n settings: EdgeTTSSettings,\n params: EdgeTTSParams,\n): Promise<Buffer> {\n const voice = resolveVoice(params.voice, settings.voice);\n const lang = params.lang ?? settings.lang;\n const outputFormat = params.outputFormat ?? settings.outputFormat;\n const rate = params.rate ?? speedToRate(params.speed) ?? settings.rate;\n const pitch = params.pitch ?? settings.pitch;\n const volume = params.volume ?? settings.volume;\n\n logger.debug(\n `[EdgeTTS] Generating speech with voice: ${voice}, lang: ${lang}`,\n );\n\n const tts = new EdgeTTS({\n voice,\n lang,\n outputFormat,\n saveSubtitles: false,\n proxy: settings.proxy,\n rate,\n pitch,\n volume,\n timeout: settings.timeoutMs,\n });\n\n // Create temp directory for output\n const tempDir = mkdtempSync(path.join(tmpdir(), \"edge-tts-\"));\n const extension = inferExtension(outputFormat);\n const outputPath = path.join(tempDir, `speech${extension}`);\n\n try {\n await tts.ttsPromise(params.text, outputPath);\n const audioBuffer = readFileSync(outputPath);\n return audioBuffer;\n } finally {\n // Cleanup temp directory\n try {\n rmSync(tempDir, { recursive: true, force: true });\n } catch {\n // Ignore cleanup errors\n }\n }\n}\n\n/**\n * Edge TTS Plugin for ElizaOS\n *\n * Provides free text-to-speech synthesis using Microsoft Edge's TTS service.\n * No API key required - uses the same TTS engine as Microsoft Edge browser.\n *\n * Features:\n * - High-quality neural voices\n * - Multiple languages and locales\n * - Adjustable rate, pitch, and volume\n * - No API key or payment required\n *\n * Optional environment variables:\n * - EDGE_TTS_VOICE: Voice ID (default: en-US-MichelleNeural)\n * - EDGE_TTS_LANG: Language code (default: en-US)\n * - EDGE_TTS_OUTPUT_FORMAT: Output format (default: audio-24khz-48kbitrate-mono-mp3)\n * - EDGE_TTS_RATE: Speech rate adjustment (e.g., +10%, -5%)\n * - EDGE_TTS_PITCH: Pitch adjustment (e.g., +5Hz, -10Hz)\n * - EDGE_TTS_VOLUME: Volume adjustment (e.g., +20%, -10%)\n * - EDGE_TTS_PROXY: HTTP proxy URL\n * - EDGE_TTS_TIMEOUT_MS: Request timeout (default: 30000)\n *\n * Popular voices:\n * - en-US-MichelleNeural (female, US English)\n * - en-US-GuyNeural (male, US English)\n * - en-US-JennyNeural (female, US English)\n * - en-US-AriaNeural (female, US English)\n * - en-GB-SoniaNeural (female, UK English)\n * - en-GB-RyanNeural (male, UK English)\n * - de-DE-KatjaNeural (female, German)\n * - fr-FR-DeniseNeural (female, French)\n * - es-ES-ElviraNeural (female, Spanish)\n * - ja-JP-NanamiNeural (female, Japanese)\n * - zh-CN-XiaoxiaoNeural (female, Chinese)\n */\nexport const edgeTTSPlugin: Plugin = {\n name: \"edge-tts\",\n description:\n \"Free text-to-speech synthesis using Microsoft Edge TTS - no API key required, high-quality neural voices\",\n models: {\n [ModelType.TEXT_TO_SPEECH]: async (\n runtime: IAgentRuntime,\n input: string | EdgeTTSParams,\n ): Promise<Buffer | ArrayBuffer | Uint8Array> => {\n const params: EdgeTTSParams =\n typeof input === \"string\" ? { text: input } : input;\n const settings = getEdgeTTSSettings(runtime);\n\n logger.log(\n `[EdgeTTS] Using TEXT_TO_SPEECH with voice: ${settings.voice}`,\n );\n\n if (!params.text || params.text.trim().length === 0) {\n throw new Error(\"TEXT_TO_SPEECH requires non-empty text\");\n }\n\n // Edge TTS has a practical limit around 5000 characters\n if (params.text.length > 5000) {\n throw new Error(\"TEXT_TO_SPEECH text exceeds 5000 character limit\");\n }\n\n try {\n const audioBuffer = await generateSpeech(settings, params);\n return audioBuffer;\n } catch (error: unknown) {\n const msg = error instanceof Error ? error.message : String(error);\n logger.error(`EdgeTTS model error: ${msg}`);\n throw error instanceof Error ? error : new Error(msg);\n }\n },\n },\n tests: [\n {\n name: \"test edge tts\",\n tests: [\n {\n name: \"Edge TTS settings validation\",\n fn: async (runtime: IAgentRuntime) => {\n const settings = getEdgeTTSSettings(runtime);\n\n if (!settings.voice) {\n throw new Error(\"Missing voice configuration\");\n }\n\n if (!settings.lang) {\n throw new Error(\"Missing language configuration\");\n }\n\n if (!settings.outputFormat) {\n throw new Error(\"Missing output format configuration\");\n }\n\n logger.success(\"Edge TTS settings validated successfully\");\n },\n },\n {\n name: \"Edge TTS voice preset mapping\",\n fn: async (_runtime: IAgentRuntime) => {\n // Test that OpenAI-style voice names map correctly\n const testCases = [\n { input: \"alloy\", expected: \"en-US-GuyNeural\" },\n { input: \"nova\", expected: \"en-US-JennyNeural\" },\n { input: \"shimmer\", expected: \"en-US-AriaNeural\" },\n {\n input: \"en-US-MichelleNeural\",\n expected: \"en-US-MichelleNeural\",\n },\n ];\n\n for (const tc of testCases) {\n const result = resolveVoice(tc.input, DEFAULT_VOICE);\n if (result !== tc.expected) {\n throw new Error(\n `Voice preset mapping failed: ${tc.input} -> ${result}, expected ${tc.expected}`,\n );\n }\n }\n\n logger.success(\"Voice preset mapping validated successfully\");\n },\n },\n {\n name: \"Edge TTS speed to rate conversion\",\n fn: async (_runtime: IAgentRuntime) => {\n const testCases = [\n { speed: 1.0, expected: undefined },\n { speed: 1.5, expected: \"+50%\" },\n { speed: 0.75, expected: \"-25%\" },\n { speed: 2.0, expected: \"+100%\" },\n ];\n\n for (const tc of testCases) {\n const result = speedToRate(tc.speed);\n if (result !== tc.expected) {\n throw new Error(\n `Speed conversion failed: ${tc.speed} -> ${result}, expected ${tc.expected}`,\n );\n }\n }\n\n logger.success(\"Speed to rate conversion validated successfully\");\n },\n },\n {\n name: \"Edge TTS generation (live test)\",\n fn: async (runtime: IAgentRuntime) => {\n const testText = \"Hello, this is a test of Edge TTS.\";\n\n try {\n const audioBuffer = (await runtime.useModel(\n ModelType.TEXT_TO_SPEECH,\n testText,\n )) as Buffer | Uint8Array;\n\n if (!audioBuffer || audioBuffer.length === 0) {\n throw new Error(\"Received empty audio buffer\");\n }\n\n logger.success(\n `Edge TTS generation successful: ${audioBuffer.length} bytes`,\n );\n } catch (error: unknown) {\n const msg =\n error instanceof Error ? error.message : String(error);\n // Edge TTS might fail in CI environments without network\n if (msg.includes(\"ENOTFOUND\") || msg.includes(\"network\")) {\n logger.warn(\n `Edge TTS live test skipped (network unavailable): ${msg}`,\n );\n return;\n }\n throw error;\n }\n },\n },\n ],\n },\n ],\n};\n\nexport default edgeTTSPlugin;\n\n// Re-export types\nexport type { EdgeTTSSettings, EdgeTTSParams };\n\n// Export helper functions for testing\nexport const _test = {\n resolveVoice,\n speedToRate,\n inferExtension,\n getEdgeTTSSettings,\n};\n"
6
+ ],
7
+ "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Q,iDAAiD;AAAA;AAAA,QAEpE;AAAA,QACA;AAAA,UACE,MAAM;AAAA,UACN,IAAI,OAAO,YAA2B;AAAA,YACpC,MAAM,WAAW;AAAA,YAEjB,IAAI;AAAA,cACF,MAAM,cAAe,MAAM,QAAQ,SACjC,UAAU,gBACV,QACF;AAAA,cAEA,IAAI,CAAC,eAAe,YAAY,WAAW,GAAG;AAAA,gBAC5C,MAAM,IAAI,MAAM,6BAA6B;AAAA,cAC/C;AAAA,cAEA,OAAO,QACL,mCAAmC,YAAY,cACjD;AAAA,cACA,OAAO,OAAgB;AAAA,cACvB,MAAM,MACJ,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AAAA,cAEvD,IAAI,IAAI,SAAS,WAAW,KAAK,IAAI,SAAS,SAAS,GAAG;AAAA,gBACxD,OAAO,KACL,qDAAqD,KACvD;AAAA,gBACA;AAAA,cACF;AAAA,cACA,MAAM;AAAA;AAAA;AAAA,QAGZ;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;AAEA,IAAe;AAMR,IAAM,QAAQ;AAAA,EACnB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;",
8
+ "debugId": "28C367D7AB4B82D264756E2164756E21",
9
+ "names": []
10
+ }
package/package.json ADDED
@@ -0,0 +1,136 @@
1
+ {
2
+ "name": "@elizaos/plugin-edge-tts",
3
+ "version": "1.0.0",
4
+ "type": "module",
5
+ "main": "dist/cjs/index.node.cjs",
6
+ "module": "dist/node/index.node.js",
7
+ "types": "dist/index.d.ts",
8
+ "browser": "dist/browser/index.browser.js",
9
+ "sideEffects": false,
10
+ "description": "Free text-to-speech using Microsoft Edge TTS - no API key required",
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "git+https://github.com/elizaos/eliza.git"
14
+ },
15
+ "exports": {
16
+ "./package.json": "./package.json",
17
+ ".": {
18
+ "types": "./dist/index.d.ts",
19
+ "browser": {
20
+ "types": "./dist/browser/index.d.ts",
21
+ "import": "./dist/browser/index.browser.js",
22
+ "default": "./dist/browser/index.browser.js"
23
+ },
24
+ "node": {
25
+ "types": "./dist/node/index.d.ts",
26
+ "import": "./dist/node/index.node.js",
27
+ "require": "./dist/cjs/index.node.cjs",
28
+ "default": "./dist/node/index.node.js"
29
+ },
30
+ "default": "./dist/node/index.node.js"
31
+ },
32
+ "./node": {
33
+ "types": "./dist/node/index.d.ts",
34
+ "import": "./dist/node/index.node.js",
35
+ "default": "./dist/node/index.node.js"
36
+ },
37
+ "./browser": {
38
+ "types": "./dist/browser/index.d.ts",
39
+ "import": "./dist/browser/index.browser.js",
40
+ "default": "./dist/browser/index.browser.js"
41
+ }
42
+ },
43
+ "files": [
44
+ "dist"
45
+ ],
46
+ "dependencies": {
47
+ "@elizaos/core": "workspace:*",
48
+ "node-edge-tts": "^1.0.7"
49
+ },
50
+ "devDependencies": {
51
+ "@types/bun": "^1.2.22",
52
+ "@types/node": "^24.5.2",
53
+ "prettier": "3.6.2",
54
+ "typescript": "^5.9.2"
55
+ },
56
+ "scripts": {
57
+ "build": "bun run build.ts",
58
+ "dev": "bun --hot build.ts",
59
+ "test": "elizaos test",
60
+ "clean": "rm -rf dist .turbo node_modules .turbo-tsconfig.json tsconfig.tsbuildinfo",
61
+ "format": "prettier --write ./src",
62
+ "format:check": "prettier --check ./src",
63
+ "lint": "prettier --write ./src"
64
+ },
65
+ "publishConfig": {
66
+ "access": "public"
67
+ },
68
+ "agentConfig": {
69
+ "pluginType": "elizaos:plugin:1.0.0",
70
+ "pluginParameters": {
71
+ "EDGE_TTS_VOICE": {
72
+ "type": "string",
73
+ "description": "Voice ID to use for synthesis (e.g., en-US-MichelleNeural, en-GB-SoniaNeural)",
74
+ "required": false,
75
+ "default": "en-US-MichelleNeural",
76
+ "sensitive": false
77
+ },
78
+ "EDGE_TTS_LANG": {
79
+ "type": "string",
80
+ "description": "Language code for synthesis (e.g., en-US, en-GB, de-DE)",
81
+ "required": false,
82
+ "default": "en-US",
83
+ "sensitive": false
84
+ },
85
+ "EDGE_TTS_OUTPUT_FORMAT": {
86
+ "type": "string",
87
+ "description": "Output format for audio (e.g., audio-24khz-48kbitrate-mono-mp3, audio-48khz-96kbitrate-mono-mp3)",
88
+ "required": false,
89
+ "default": "audio-24khz-48kbitrate-mono-mp3",
90
+ "sensitive": false
91
+ },
92
+ "EDGE_TTS_RATE": {
93
+ "type": "string",
94
+ "description": "Speech rate adjustment (e.g., +0%, -10%, +20%)",
95
+ "required": false,
96
+ "sensitive": false
97
+ },
98
+ "EDGE_TTS_PITCH": {
99
+ "type": "string",
100
+ "description": "Voice pitch adjustment (e.g., +0Hz, -10Hz, +5Hz)",
101
+ "required": false,
102
+ "sensitive": false
103
+ },
104
+ "EDGE_TTS_VOLUME": {
105
+ "type": "string",
106
+ "description": "Volume adjustment (e.g., +0%, -10%, +20%)",
107
+ "required": false,
108
+ "sensitive": false
109
+ },
110
+ "EDGE_TTS_PROXY": {
111
+ "type": "string",
112
+ "description": "HTTP proxy URL for requests",
113
+ "required": false,
114
+ "sensitive": false
115
+ },
116
+ "EDGE_TTS_TIMEOUT_MS": {
117
+ "type": "number",
118
+ "description": "Request timeout in milliseconds",
119
+ "required": false,
120
+ "default": "30000",
121
+ "sensitive": false
122
+ }
123
+ }
124
+ },
125
+ "milaidy": {
126
+ "platforms": [
127
+ "browser",
128
+ "node"
129
+ ],
130
+ "runtime": "both",
131
+ "platformDetails": {
132
+ "browser": "Browser-compatible build available via exports.browser",
133
+ "node": "Node.js build available via exports.node"
134
+ }
135
+ }
136
+ }