Edge-TTS Skill
Overview
Generate high-quality text-to-speech audio using Microsoft Edge's neural TTS service via the node-edge-tts npm package. Supports multiple languages, voices, adjustable speed/pitch, and subtitle generation.
Quick Start
When you detect TTS intent from triggers or user request:
- 1. Call the tts tool (Clawdbot built-in) to convert text to speech
- The tool returns a MEDIA: path
- Clawdbot routes the audio to the current channel
CODEBLOCK0
Trigger Detection
Recognize "tts" keyword as TTS requests. The skill automatically filters out TTS-related keywords from text before conversion to avoid converting the trigger words themselves to audio.
Advanced Customization
Using the Node.js Scripts
For more control, use the bundled scripts directly:
TTS Converter
CODEBLOCK1
Options:
- -
--voice, -v: Voice name (default: en-US-AriaNeural) - INLINECODE1 : Language code (e.g., en-US, es-ES)
- INLINECODE2 : Output format (default: audio-24khz-48kbitrate-mono-mp3)
- INLINECODE3 : Pitch adjustment (e.g., +10%, -20%, default)
- INLINECODE4 : Rate adjustment (e.g., +10%, -20%, default)
- INLINECODE5 : Volume adjustment (e.g., +0%, -10%, default)
- INLINECODE6 : Save subtitles as JSON file
- INLINECODE7 : Output file path (default: tts_output.mp3)
- INLINECODE8 : Proxy URL (e.g., http://localhost:7890)
- INLINECODE9 : Request timeout in milliseconds (default: 10000)
- INLINECODE10 : List available voices
Configuration Manager
CODEBLOCK2
Voice Selection
Common voices (use --list-voices for full list):
English:
- -
en-US-MichelleNeural (female, natural, default) - INLINECODE13 (female, natural)
- INLINECODE14 (male, natural)
- INLINECODE15 (female, British)
- INLINECODE16 (male, British)
Other Languages:
- -
es-ES-ElviraNeural (Spanish, Spain) - INLINECODE18 (French)
- INLINECODE19 (German)
- INLINECODE20 (Japanese)
- INLINECODE21 (Chinese)
- INLINECODE22 (Arabic)
Rate Guidelines
Rate values use percentage format:
- -
"default": Normal speed - INLINECODE24 to
"-10%": Slow, clear (tutorials, stories, accessibility) - INLINECODE26 to
"+20%": Slightly fast (summaries) - INLINECODE28 to
"+50%": Fast (news, efficiency)
Output Formats
Choose audio quality based on use case:
- -
audio-24khz-48kbitrate-mono-mp3: Standard quality (voice notes, messages) - INLINECODE31 : High quality (presentations, content)
- INLINECODE32 : Highest quality (professional audio, music)
Resources
scripts/tts-converter.js
Main TTS conversion script using node-edge-tts. Generates audio files with customizable voice, rate, volume, pitch, and format. Supports subtitle generation and voice listing.
scripts/config-manager.js
Manages persistent user preferences for TTS settings (voice, language, format, pitch, rate, volume). Stores config in
~/.tts-config.json.
scripts/package.json
NPM package configuration with node-edge-tts dependency.
references/nodeedgetts_guide.md
Complete documentation for node-edge-tts npm package including:
- - Full voice list by language
- Prosody options (rate, pitch, volume)
- Usage examples (CLI and Module)
- Subtitle generation
- Output formats
- Best practices and limitations
Voice Testing
Test different voices and preview audio quality at: https://tts.travisvn.com/
Refer to this when you need specific voice details or advanced features.
Installation
To use the bundled scripts:
CODEBLOCK3
This installs:
- -
node-edge-tts - TTS library - INLINECODE35 - CLI argument parsing
Workflow
- 1. Detect intent: Check for "tts" trigger or keyword in user message
- Choose method: Use built-in
tts tool for simple requests, or scripts/tts-converter.js for customization - Generate audio: Convert the target text (message, search results, summary)
- Return to user: The tts tool returns a MEDIA: path; Clawdbot handles delivery
Testing
Basic Test
Run the test script to verify TTS functionality:
cd /home/user/clawd/skills/public/edge-tts/scripts
npm test
This generates a test audio file and verifies the TTS service is working.
Voice Testing
Test different voices and preview audio quality at: https://tts.travisvn.com/
Integration Test
Use the built-in
tts tool for quick testing:
CODEBLOCK5
Configuration Test
Verify configuration persistence:
CODEBLOCK6
Troubleshooting
- - Test connectivity: Run
npm test to check if TTS service is accessible - Check voice availability: Use
node tts-converter.js --list-voices to see available voices - Verify proxy settings: If using proxy, test with INLINECODE41
- Check audio output: The test should generate
test-output.mp3 in the scripts directory
Notes
- - node-edge-tts uses Microsoft Edge's online TTS service (updated, working authentication)
- No API key needed (free service)
- Output is MP3 format by default
- Requires internet connection
- Supports subtitle generation (JSON format with word-level timing)
- Temporary File Handling: By default, audio files are saved to the system's temporary directory (
/tmp/edge-tts-temp/ on Unix, C:\Users\<user>\AppData\Local\Temp\edge-tts-temp\ on Windows) with unique filenames (e.g., tts_1234567890_abc123.mp3). Files are not automatically deleted - the calling application (Clawdbot) should handle cleanup after use. You can specify a custom output path with the --output option if permanent storage is needed. - TTS keyword filtering: The skill automatically filters out TTS-related keywords (tts, TTS, text-to-speech) from text before conversion to avoid converting the trigger words themselves to audio
- For repeated preferences, use
config-manager.js to set defaults - Default voice:
en-US-MichelleNeural (female, natural) - Neural voices (ending in
Neural) provide higher quality than Standard voices
技能名称: edge-tts-cn
详细描述:
Edge-TTS 技能
概述
通过 node-edge-tts npm 包,使用微软 Edge 的神经 TTS 服务生成高质量文本转语音音频。支持多种语言、语音、可调节速度/音调以及字幕生成。
快速开始
当你从触发器或用户请求中检测到 TTS 意图时:
- 1. 调用 tts 工具(Clawdbot 内置)将文本转换为语音
- 该工具返回一个 MEDIA: 路径
- Clawdbot 将音频路由到当前频道
javascript
// 示例:内置 tts 工具的使用
tts(你要转换为语音的文本)
// 返回:MEDIA: /path/to/audio.mp3
触发器检测
将 tts 关键词识别为 TTS 请求。该技能会在转换前自动从文本中过滤掉 TTS 相关关键词,以避免将触发词本身转换为音频。
高级自定义
使用 Node.js 脚本
如需更多控制,可直接使用捆绑脚本:
TTS 转换器
bash
cd scripts
npm install
node tts-converter.js 你的文本 --voice en-US-AriaNeural --rate +10% --output output.mp3
选项:
- - --voice, -v:语音名称(默认:en-US-AriaNeural)
- --lang, -l:语言代码(例如:en-US、es-ES)
- --format, -o:输出格式(默认:audio-24khz-48kbitrate-mono-mp3)
- --pitch:音调调整(例如:+10%、-20%、default)
- --rate, -r:语速调整(例如:+10%、-20%、default)
- --volume:音量调整(例如:+0%、-10%、default)
- --save-subtitles, -s:将字幕保存为 JSON 文件
- --output, -f:输出文件路径(默认:tts_output.mp3)
- --proxy, -p:代理 URL(例如:http://localhost:7890)
- --timeout:请求超时时间(毫秒,默认:10000)
- --list-voices, -L:列出可用的语音
配置管理器
bash
cd scripts
npm install
node config-manager.js --set-voice en-US-AriaNeural
node config-manager.js --set-rate +10%
node config-manager.js --get
node config-manager.js --reset
语音选择
常用语音(使用 --list-voices 查看完整列表):
英语:
- - en-US-MichelleNeural(女声,自然,默认)
- en-US-AriaNeural(女声,自然)
- en-US-GuyNeural(男声,自然)
- en-GB-SoniaNeural(女声,英式)
- en-GB-RyanNeural(男声,英式)
其他语言:
- - es-ES-ElviraNeural(西班牙语,西班牙)
- fr-FR-DeniseNeural(法语)
- de-DE-KatjaNeural(德语)
- ja-JP-NanamiNeural(日语)
- zh-CN-XiaoxiaoNeural(中文)
- ar-SA-ZariyahNeural(阿拉伯语)
语速指南
语速值使用百分比格式:
- - default:正常速度
- -20% 到 -10%:慢速、清晰(教程、故事、无障碍)
- +10% 到 +20%:稍快(摘要)
- +30% 到 +50%:快速(新闻、效率)
输出格式
根据使用场景选择音频质量:
- - audio-24khz-48kbitrate-mono-mp3:标准质量(语音笔记、消息)
- audio-24khz-96kbitrate-mono-mp3:高质量(演示、内容)
- audio-48khz-96kbitrate-stereo-mp3:最高质量(专业音频、音乐)
资源
scripts/tts-converter.js
使用 node-edge-tts 的主要 TTS 转换脚本。生成可自定义语音、语速、音量、音调和格式的音频文件。支持字幕生成和语音列表功能。
scripts/config-manager.js
管理 TTS 设置的持久化用户偏好(语音、语言、格式、音调、语速、音量)。配置存储在 ~/.tts-config.json 中。
scripts/package.json
包含 node-edge-tts 依赖的 NPM 包配置。
references/nodeedgetts_guide.md
node-edge-tts npm 包的完整文档,包括:
- - 按语言分类的完整语音列表
- 韵律选项(语速、音调、音量)
- 使用示例(CLI 和模块)
- 字幕生成
- 输出格式
- 最佳实践和限制
语音测试
在以下网址测试不同语音并预览音频质量:https://tts.travisvn.com/
当你需要特定语音详情或高级功能时,请参考此资源。
安装
要使用捆绑脚本:
bash
cd /home/user/clawd/skills/public/tts-skill/scripts
npm install
这将安装:
- - node-edge-tts - TTS 库
- commander - CLI 参数解析
工作流程
- 1. 检测意图:检查用户消息中是否有 tts 触发词或关键词
- 选择方法:简单请求使用内置 tts 工具,自定义需求使用 scripts/tts-converter.js
- 生成音频:转换目标文本(消息、搜索结果、摘要)
- 返回给用户:tts 工具返回 MEDIA: 路径;Clawdbot 负责投递
测试
基本测试
运行测试脚本以验证 TTS 功能:
bash
cd /home/user/clawd/skills/public/edge-tts/scripts
npm test
这将生成一个测试音频文件并验证 TTS 服务是否正常工作。
语音测试
在以下网址测试不同语音并预览音频质量:https://tts.travisvn.com/
集成测试
使用内置 tts 工具进行快速测试:
javascript
// 示例:使用默认设置测试 TTS
tts(这是对 TTS 功能的测试。)
配置测试
验证配置持久化:
bash
cd /home/user/clawd/skills/public/edge-tts/scripts
node config-manager.js --get
node config-manager.js --set-voice en-US-GuyNeural
node config-manager.js --get
故障排除
- - 测试连接:运行 npm test 检查 TTS 服务是否可访问
- 检查语音可用性:使用 node tts-converter.js --list-voices 查看可用语音
- 验证代理设置:如果使用代理,用 node tts-converter.js test --proxy http://localhost:7890 测试
- 检查音频输出:测试应在 scripts 目录中生成 test-output.mp3
注意事项
- - node-edge-tts 使用微软 Edge 的在线 TTS 服务(已更新,认证有效)
- 无需 API 密钥(免费服务)
- 默认输出为 MP3 格式
- 需要互联网连接
- 支持字幕生成(JSON 格式,包含单词级时间戳)
- 临时文件处理:默认情况下,音频文件保存到系统的临时目录(Unix 上为 /tmp/edge-tts-temp/,Windows 上为 C:\Users\\AppData\Local\Temp\edge-tts-temp\),文件名唯一(例如 tts1234567890abc123.mp3)。文件不会自动删除——调用应用程序(Clawdbot)应在使用后负责清理。如果需要永久存储,可以使用 --output 选项指定自定义输出路径。
- TTS 关键词过滤:该技能会在转换前自动从文本中过滤掉 TTS 相关关键词(tts、TTS、text-to-speech),以避免将触发词本身转换为音频
- 对于重复使用的偏好,使用 config-manager.js 设置默认值
- 默认语音:en-US-MichelleNeural(女声,自然)
- 神经语音(以 Neural 结尾)比标准语音质量更高