@elizaos/plugin-edge-tts 2.0.0-alpha.11 → 2.0.0-alpha.12
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 +2 -2
- package/dist/browser/index.browser.js.map +2 -2
- package/dist/cjs/index.node.cjs +4 -5
- package/dist/cjs/index.node.js.map +3 -3
- package/dist/index.d.ts +1 -90
- package/dist/node/index.node.js +5 -9
- package/dist/node/index.node.js.map +3 -3
- package/package.json +12 -12
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @elizaos/plugin-edge-tts
|
|
2
2
|
|
|
3
|
-
Free text-to-speech plugin for
|
|
3
|
+
Free text-to-speech plugin for ElizaOS using Microsoft Edge TTS. No API key required.
|
|
4
4
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
@@ -18,7 +18,7 @@ npm install @elizaos/plugin-edge-tts
|
|
|
18
18
|
|
|
19
19
|
## Usage
|
|
20
20
|
|
|
21
|
-
### As
|
|
21
|
+
### As ElizaOS Plugin
|
|
22
22
|
|
|
23
23
|
```typescript
|
|
24
24
|
import { edgeTTSPlugin } from "@elizaos/plugin-edge-tts";
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.browser.ts"],
|
|
4
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
|
|
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 { logger, type Plugin } from \"@elizaos/core\";\n\nexport const edgeTTSPlugin: Plugin = {\n name: \"edge-tts\",\n description: \"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
6
|
],
|
|
7
|
-
"mappings": "AAQA,
|
|
7
|
+
"mappings": "AAQA,iBAAS,sBAEF,IAAM,EAAwB,CACnC,KAAM,WACN,YAAa,yEACb,OAAQ,CAAC,EACT,MAAO,CAAC,CACV,EAGA,GAAI,OAAO,OAAW,IACpB,EAAO,KACL,wIAEF,EAGF,IAAe",
|
|
8
8
|
"debugId": "A1DF4939E5621A8064756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
package/dist/cjs/index.node.cjs
CHANGED
|
@@ -64,17 +64,17 @@ var __export = (target, all) => {
|
|
|
64
64
|
var exports_index_node = {};
|
|
65
65
|
__export(exports_index_node, {
|
|
66
66
|
edgeTTSPlugin: () => edgeTTSPlugin,
|
|
67
|
-
default: () =>
|
|
67
|
+
default: () => import__.default,
|
|
68
68
|
_test: () => _test
|
|
69
69
|
});
|
|
70
70
|
module.exports = __toCommonJS(exports_index_node);
|
|
71
71
|
|
|
72
72
|
// src/index.ts
|
|
73
|
-
var import_core = require("@elizaos/core");
|
|
74
|
-
var import_node_edge_tts = require("node-edge-tts");
|
|
75
73
|
var import_node_fs = require("node:fs");
|
|
76
74
|
var import_node_os = require("node:os");
|
|
77
75
|
var import_node_path = __toESM(require("node:path"));
|
|
76
|
+
var import_core = require("@elizaos/core");
|
|
77
|
+
var import_node_edge_tts = require("node-edge-tts");
|
|
78
78
|
var DEFAULT_VOICE = "en-US-MichelleNeural";
|
|
79
79
|
var DEFAULT_LANG = "en-US";
|
|
80
80
|
var DEFAULT_OUTPUT_FORMAT = "audio-24khz-48kbitrate-mono-mp3";
|
|
@@ -270,7 +270,6 @@ var edgeTTSPlugin = {
|
|
|
270
270
|
}
|
|
271
271
|
]
|
|
272
272
|
};
|
|
273
|
-
var src_default = edgeTTSPlugin;
|
|
274
273
|
var _test = {
|
|
275
274
|
resolveVoice,
|
|
276
275
|
speedToRate,
|
|
@@ -278,4 +277,4 @@ var _test = {
|
|
|
278
277
|
getEdgeTTSSettings
|
|
279
278
|
};
|
|
280
279
|
|
|
281
|
-
//# debugId=
|
|
280
|
+
//# debugId=A5679EFA1B131FAF64756E2164756E21
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.ts"],
|
|
4
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"
|
|
5
|
+
"import { mkdtempSync, readFileSync, rmSync } from \"node:fs\";\nimport { tmpdir } from \"node:os\";\nimport path from \"node:path\";\nimport { type IAgentRuntime, logger, ModelType, type Plugin } from \"@elizaos/core\";\nimport { EdgeTTS } from \"node-edge-tts\";\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(runtime: IAgentRuntime, key: string, fallback?: string): string | undefined {\n const envValue =\n typeof process !== \"undefined\" && (process as { env?: Record<string, string> }).env\n ? (process as { env: Record<string, string> }).env[key]\n : undefined;\n return (runtime.getSetting(key) as string | undefined) ?? envValue ?? fallback;\n}\n\nfunction getEdgeTTSSettings(runtime: IAgentRuntime): EdgeTTSSettings {\n const timeoutStr = getSetting(runtime, \"EDGE_TTS_TIMEOUT_MS\");\n return {\n voice: 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) ?? 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 ? Number.parseInt(timeoutStr, 10) : 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 (normalized.includes(\"wav\") || normalized.includes(\"riff\") || normalized.includes(\"pcm\")) {\n return \".wav\";\n }\n return \".mp3\";\n}\n\n/**\n * Generate speech using Microsoft Edge TTS\n */\nasync function generateSpeech(settings: EdgeTTSSettings, params: EdgeTTSParams): 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(`[EdgeTTS] Generating speech with voice: ${voice}, lang: ${lang}`);\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 = typeof input === \"string\" ? { text: input } : input;\n const settings = getEdgeTTSSettings(runtime);\n\n logger.log(`[EdgeTTS] Using TEXT_TO_SPEECH with voice: ${settings.voice}`);\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(ModelType.TEXT_TO_SPEECH, testText)) as\n | Buffer\n | Uint8Array;\n\n if (!audioBuffer || audioBuffer.length === 0) {\n throw new Error(\"Received empty audio buffer\");\n }\n\n logger.success(`Edge TTS generation successful: ${audioBuffer.length} bytes`);\n } catch (error: unknown) {\n const msg = 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(`Edge TTS live test skipped (network unavailable): ${msg}`);\n return;\n }\n throw error;\n }\n },\n },\n ],\n },\n ],\n};\n\nexport default edgeTTSPlugin;\n\n// Re-export types\nexport type { EdgeTTSParams, EdgeTTSSettings };\n\n// Export helper functions for testing\nexport const _test = {\n resolveVoice,\n speedToRate,\n inferExtension,\n getEdgeTTSSettings,\n};\n"
|
|
6
6
|
],
|
|
7
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
8
|
-
"debugId": "
|
|
7
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAk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,GAAG,UACpE;AAAA,cACF;AAAA,YACF;AAAA,YAEA,mBAAO,QAAQ,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,SAAS,sBAAU,gBAAgB,QAAQ;AAAA,cAI9E,IAAI,CAAC,eAAe,YAAY,WAAW,GAAG;AAAA,gBAC5C,MAAM,IAAI,MAAM,6BAA6B;AAAA,cAC/C;AAAA,cAEA,mBAAO,QAAQ,mCAAmC,YAAY,cAAc;AAAA,cAC5E,OAAO,OAAgB;AAAA,cACvB,MAAM,MAAM,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AAAA,cAEjE,IAAI,IAAI,SAAS,WAAW,KAAK,IAAI,SAAS,SAAS,GAAG;AAAA,gBACxD,mBAAO,KAAK,qDAAqD,KAAK;AAAA,gBACtE;AAAA,cACF;AAAA,cACA,MAAM;AAAA;AAAA;AAAA,QAGZ;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;AAQO,IAAM,QAAQ;AAAA,EACnB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;",
|
|
8
|
+
"debugId": "A5679EFA1B131FAF64756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,90 +1 @@
|
|
|
1
|
-
|
|
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
|
-
};
|
|
1
|
+
export * from "@elizaos/core";
|
package/dist/node/index.node.js
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
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";
|
|
2
|
+
import { mkdtempSync, readFileSync, rmSync } from "node:fs";
|
|
8
3
|
import { tmpdir } from "node:os";
|
|
9
4
|
import path from "node:path";
|
|
5
|
+
import { logger, ModelType } from "@elizaos/core";
|
|
6
|
+
import { EdgeTTS } from "node-edge-tts";
|
|
10
7
|
var DEFAULT_VOICE = "en-US-MichelleNeural";
|
|
11
8
|
var DEFAULT_LANG = "en-US";
|
|
12
9
|
var DEFAULT_OUTPUT_FORMAT = "audio-24khz-48kbitrate-mono-mp3";
|
|
@@ -202,7 +199,6 @@ var edgeTTSPlugin = {
|
|
|
202
199
|
}
|
|
203
200
|
]
|
|
204
201
|
};
|
|
205
|
-
var src_default = edgeTTSPlugin;
|
|
206
202
|
var _test = {
|
|
207
203
|
resolveVoice,
|
|
208
204
|
speedToRate,
|
|
@@ -211,8 +207,8 @@ var _test = {
|
|
|
211
207
|
};
|
|
212
208
|
export {
|
|
213
209
|
edgeTTSPlugin,
|
|
214
|
-
|
|
210
|
+
default2 as default,
|
|
215
211
|
_test
|
|
216
212
|
};
|
|
217
213
|
|
|
218
|
-
//# debugId=
|
|
214
|
+
//# debugId=155C5D65D68CA0DA64756E2164756E21
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.ts"],
|
|
4
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"
|
|
5
|
+
"import { mkdtempSync, readFileSync, rmSync } from \"node:fs\";\nimport { tmpdir } from \"node:os\";\nimport path from \"node:path\";\nimport { type IAgentRuntime, logger, ModelType, type Plugin } from \"@elizaos/core\";\nimport { EdgeTTS } from \"node-edge-tts\";\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(runtime: IAgentRuntime, key: string, fallback?: string): string | undefined {\n const envValue =\n typeof process !== \"undefined\" && (process as { env?: Record<string, string> }).env\n ? (process as { env: Record<string, string> }).env[key]\n : undefined;\n return (runtime.getSetting(key) as string | undefined) ?? envValue ?? fallback;\n}\n\nfunction getEdgeTTSSettings(runtime: IAgentRuntime): EdgeTTSSettings {\n const timeoutStr = getSetting(runtime, \"EDGE_TTS_TIMEOUT_MS\");\n return {\n voice: 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) ?? 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 ? Number.parseInt(timeoutStr, 10) : 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 (normalized.includes(\"wav\") || normalized.includes(\"riff\") || normalized.includes(\"pcm\")) {\n return \".wav\";\n }\n return \".mp3\";\n}\n\n/**\n * Generate speech using Microsoft Edge TTS\n */\nasync function generateSpeech(settings: EdgeTTSSettings, params: EdgeTTSParams): 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(`[EdgeTTS] Generating speech with voice: ${voice}, lang: ${lang}`);\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 = typeof input === \"string\" ? { text: input } : input;\n const settings = getEdgeTTSSettings(runtime);\n\n logger.log(`[EdgeTTS] Using TEXT_TO_SPEECH with voice: ${settings.voice}`);\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(ModelType.TEXT_TO_SPEECH, testText)) as\n | Buffer\n | Uint8Array;\n\n if (!audioBuffer || audioBuffer.length === 0) {\n throw new Error(\"Received empty audio buffer\");\n }\n\n logger.success(`Edge TTS generation successful: ${audioBuffer.length} bytes`);\n } catch (error: unknown) {\n const msg = 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(`Edge TTS live test skipped (network unavailable): ${msg}`);\n return;\n }\n throw error;\n }\n },\n },\n ],\n },\n ],\n};\n\nexport default edgeTTSPlugin;\n\n// Re-export types\nexport type { EdgeTTSParams, EdgeTTSSettings };\n\n// Export helper functions for testing\nexport const _test = {\n resolveVoice,\n speedToRate,\n inferExtension,\n getEdgeTTSSettings,\n};\n"
|
|
6
6
|
],
|
|
7
|
-
"mappings": ";AAAA;
|
|
8
|
-
"debugId": "
|
|
7
|
+
"mappings": ";AAAA;AACA;AACA;AACA;AACA;AAoCA,IAAM,gBAAgB;AACtB,IAAM,eAAe;AACrB,IAAM,wBAAwB;AAC9B,IAAM,qBAAqB;AAG3B,IAAM,gBAAwC;AAAA,EAE5C,OAAO;AAAA,EACP,MAAM;AAAA,EACN,OAAO;AAAA,EACP,MAAM;AAAA,EACN,MAAM;AAAA,EACN,SAAS;AAEX;AAEA,SAAS,UAAU,CAAC,SAAwB,KAAa,UAAuC;AAAA,EAC9F,MAAM,WACJ,OAAO,YAAY,eAAgB,QAA6C,MAC3E,QAA4C,IAAI,OACjD;AAAA,EACN,OAAQ,QAAQ,WAAW,GAAG,KAA4B,YAAY;AAAA;AAGxE,SAAS,kBAAkB,CAAC,SAAyC;AAAA,EACnE,MAAM,aAAa,WAAW,SAAS,qBAAqB;AAAA,EAC5D,OAAO;AAAA,IACL,OAAO,WAAW,SAAS,kBAAkB,aAAa,KAAK;AAAA,IAC/D,MAAM,WAAW,SAAS,iBAAiB,YAAY,KAAK;AAAA,IAC5D,cACE,WAAW,SAAS,0BAA0B,qBAAqB,KAAK;AAAA,IAC1E,MAAM,WAAW,SAAS,eAAe;AAAA,IACzC,OAAO,WAAW,SAAS,gBAAgB;AAAA,IAC3C,QAAQ,WAAW,SAAS,iB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": []
|
|
10
10
|
}
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elizaos/plugin-edge-tts",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.12",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/cjs/index.node.cjs",
|
|
6
6
|
"module": "dist/node/index.node.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
8
|
"browser": "dist/browser/index.browser.js",
|
|
9
|
+
"sideEffects": false,
|
|
9
10
|
"description": "Free text-to-speech using Microsoft Edge TTS - no API key required",
|
|
10
11
|
"repository": {
|
|
11
12
|
"type": "git",
|
|
@@ -43,23 +44,25 @@
|
|
|
43
44
|
"dist"
|
|
44
45
|
],
|
|
45
46
|
"dependencies": {
|
|
47
|
+
"@elizaos/core": "2.0.0-alpha.114",
|
|
46
48
|
"node-edge-tts": "^1.0.7"
|
|
47
49
|
},
|
|
48
50
|
"devDependencies": {
|
|
49
51
|
"@types/bun": "^1.2.22",
|
|
50
52
|
"@types/node": "^24.5.2",
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"typescript": "^5.9.2"
|
|
53
|
+
"typescript": "^5.9.2",
|
|
54
|
+
"@biomejs/biome": "^2.3.11"
|
|
54
55
|
},
|
|
55
56
|
"scripts": {
|
|
56
57
|
"build": "bun run build.ts",
|
|
57
58
|
"dev": "bun --hot build.ts",
|
|
58
|
-
"test": "
|
|
59
|
+
"test": "npx -y vitest@4.0.18 run --passWithNoTests",
|
|
59
60
|
"clean": "rm -rf dist .turbo node_modules .turbo-tsconfig.json tsconfig.tsbuildinfo",
|
|
60
|
-
"format": "
|
|
61
|
-
"format:check": "
|
|
62
|
-
"lint": "
|
|
61
|
+
"format": "bunx @biomejs/biome format --write .",
|
|
62
|
+
"format:check": "bunx @biomejs/biome format .",
|
|
63
|
+
"lint": "bunx @biomejs/biome check --write --unsafe .",
|
|
64
|
+
"lint:check": "bunx @biomejs/biome check .",
|
|
65
|
+
"typecheck": "tsc --noEmit"
|
|
63
66
|
},
|
|
64
67
|
"publishConfig": {
|
|
65
68
|
"access": "public"
|
|
@@ -121,7 +124,7 @@
|
|
|
121
124
|
}
|
|
122
125
|
}
|
|
123
126
|
},
|
|
124
|
-
"
|
|
127
|
+
"milady": {
|
|
125
128
|
"platforms": [
|
|
126
129
|
"browser",
|
|
127
130
|
"node"
|
|
@@ -131,8 +134,5 @@
|
|
|
131
134
|
"browser": "Browser-compatible build available via exports.browser",
|
|
132
135
|
"node": "Node.js build available via exports.node"
|
|
133
136
|
}
|
|
134
|
-
},
|
|
135
|
-
"peerDependencies": {
|
|
136
|
-
"@elizaos/core": "alpha"
|
|
137
137
|
}
|
|
138
138
|
}
|