文本转语音工具 - 支持脚本解析、情绪标记和后处理,基于 Edge TTS
仓库地址: https://github.com/wlzh/skills 版本: v3.6.0
文本转语音工具 - 默认 MiniMax TTS,支持切换 Kokoro TTS 和 Edge TTS,保留播客脚本解析、情绪标记和后处理。
# 基本用法
python3 ~/.claude/skills/text-to-speech/scripts/text_to_speech.py <文本文件>
# 设置 MiniMax API Key(只在本机环境变量中设置,不写入配置文件)
export MINIMAX_API_KEY="你的本机 key"
# 指定输出文件
python3 ~/.claude/skills/text-to-speech/scripts/text_to_speech.py script.txt -o output.mp3
# 切换回 Kokoro 或 Edge
python3 ~/.claude/skills/text-to-speech/scripts/text_to_speech.py script.txt --engine kokoro
python3 ~/.claude/skills/text-to-speech/scripts/text_to_speech.py script.txt --engine edge
Chinese (Mandarin)_Reliable_Executive(可靠高管)tts_engine 可配置为 minimax、kokoro 或 edge自动移除以下内容:
(00:00) - 时间戳[BGM渐入:...] - 背景音乐注释(主播声音:...) - 导演指示(停顿 1秒) - 动作指示(语速放慢,加重语气) - 情绪标记**文本** - Markdown 加粗标记只保留实际要朗读的文字。
Chinese (Mandarin)_Reliable_Executive - 可靠高管,男声,稳重可信,当前默认Chinese (Mandarin)_Sincere_Adult - 真诚成年,男声,自然真诚Chinese (Mandarin)_Radio_Host - 电台主持,男声,自然主持感Chinese (Mandarin)_Gentle_Youth - 温柔青年,男声,年轻柔和Chinese (Mandarin)_Unrestrained_Young_Man - 不羁青年,男声,轻松活跃male-qn-jingying - 精英青年,男声,清晰专业,旧默认zh-CN-YunyangNeural - 新闻播音(沉稳专业)⭐ 默认zh-CN-YunxiNeural - 年轻活力zh-CN-YunjianNeural - 成熟稳重zh-CN-YunfengNeural - 新闻播音zh-CN-YunhaoNeural - 广告配音zh-CN-YunzeNeural - 年轻阳光zh-CN-XiaoxiaoNeural - 温柔亲切zh-CN-XiaoyiNeural - 活泼开朗zh-CN-XiaochenNeural - 知性优雅zh-CN-XiaohanNeural - 严肃正式zh-CN-XiaomengNeural - 少女可爱zh-CN-XiaomoNeural - 温暖治愈zh-CN-XiaoqiuNeural - 叙事讲述zh-CN-XiaoruiNeural - 平和自然zh-CN-XiaoshuangNeural - 儿童声音zh-CN-XiaoxuanNeural - 温柔细腻zh-CN-XiaoyanNeural - 新闻播音zh-CN-XiaoyouNeural - 儿童声音usage: text_to_speech.py [-h] [-o OUTPUT] [-c CONFIG] [-v VOICE]
[--engine {minimax,edge,kokoro}]
[--rate RATE] [--pitch PITCH] [--volume VOLUME]
[--speed SPEED] [--context CONTEXT]
[--delivery-profile DELIVERY_PROFILE]
[--post-process] [--list-voices]
input
参数:
input 输入文本文件路径(或使用 - 从标准输入读取)
-o, --output 输出音频文件路径
-c, --config 配置文件路径
-e, --engine TTS 引擎(minimax / kokoro / edge)
-v, --voice 声音类型(如 zh-CN-YunyangNeural)
--rate 语速调整(Edge,如 +20% 或 -10%)
--pitch 音调调整(Edge 或 MiniMax)
--volume 音量调整(Edge 或 MiniMax)
--speed 语速(MiniMax/Kokoro,如 1.0)
--context MiniMax 专属语境档;默认自动识别,Edge/Kokoro 忽略
--delivery-profile MiniMax 整期表达档;默认 friendly_tutorial
--subtitle-output MiniMax 专属:保存经过校验的词级时间戳 JSON
--post-process 启用后处理(voice-changer)
--list-voices 列出所有可用的声音
python3 ~/.claude/skills/text-to-speech/scripts/text_to_speech.py podcast_script.txt
输入脚本:
(00:00) [BGM渐入:深沉的电子低音]
(主播声音:稳重,中速)
大家好,这里是AI前沿播客。
(停顿 1秒)
今天我们要聊的话题,关乎一场正在发生的剧变。
实际朗读:
大家好,这里是AI前沿播客。
今天我们要聊的话题,关乎一场正在发生的剧变。
python3 ~/.claude/skills/text-to-speech/scripts/text_to_speech.py \
script.txt \
-o output.mp3 \
--speed 1.0
python3 ~/.claude/skills/text-to-speech/scripts/text_to_speech.py \
script.txt \
--engine edge \
-v zh-CN-XiaoxiaoNeural \
--rate "+10%"
python3 ~/.claude/skills/text-to-speech/scripts/text_to_speech.py \
script.txt \
--post-process
会先生成语音,然后调用 voice-changer 进行变声处理。
echo "你好,世界!欢迎使用 Text-to-Speech。" | \
python3 ~/.claude/skills/text-to-speech/scripts/text_to_speech.py -
python3 ~/.claude/skills/text-to-speech/scripts/text_to_speech.py --list-voices
python3 scripts/minimax_voice_clone.py inspect --sample /path/to/source.m4a
python3 scripts/minimax_voice_clone.py quote \
--voice-id DuankuNarrator20260801 \
--text "大家好,欢迎来到纯棉短裤。"
克隆创建不立即收费,首次用新音色执行 TTS 才收取克隆费。激活命令必须提交报价 ID 和精确金额。本机音色档保存在 ~/.config/duanku/minimax-voice.json,权限固定为 0600。
克隆音色与 --delivery-profile 均为 MiniMax 专属能力。tts_engine 或 --engine 选择 Edge/Kokoro 时,不读取本机克隆 profile,也不执行克隆样本和激活状态门禁。
编辑 config/tts_config.json 自定义设置:
{
"tts_engine": "minimax",
"minimax_tts": {
"api_key_env": "MINIMAX_API_KEY",
"endpoint": "https://api.minimaxi.com/v1/t2a_v2",
"model": "speech-2.8-hd",
"voice_id": "Chinese (Mandarin)_Reliable_Executive",
"voice_name": "可靠高管",
"speed": 1.0,
"context_adaptation": {
"enabled": true,
"default_context": "explanation",
"profiles": {
"explanation": {"speed_multiplier": 0.96, "volume_multiplier": 1.0, "pitch_offset": 0},
"instruction": {"speed_multiplier": 0.93, "volume_multiplier": 1.02, "pitch_offset": 0},
"warning": {"speed_multiplier": 0.9, "volume_multiplier": 1.08, "pitch_offset": -1},
"call_to_action": {"speed_multiplier": 1.0, "volume_multiplier": 1.05, "pitch_offset": 1}
}
},
"format": "mp3"
},
"kokoro_tts": {
"api_url": "http://localhost:8880/v1/audio/speech",
"voice": "zm_009",
"speed": 1.0
},
"edge_tts": {
"voice": "zh-CN-YunyangNeural",
"rate": "+0%",
"pitch": "+0Hz",
"volume": "+0%"
},
"script_parsing": {
"enabled": true,
"remove_timestamps": true,
"remove_bgm_notes": true,
"remove_stage_directions": true,
"remove_markdown": true
},
"post_processing": {
"enabled": false,
"voice_changer": {
"enabled": false,
"voice_type": "female_1"
}
}
}
密钥不要写入配置文件。默认只读取本机环境变量:
export MINIMAX_API_KEY="你的本机 key"
# MiniMax 默认引擎不需要额外 Python 包,只需要环境变量
export MINIMAX_API_KEY="你的本机 key"
# 如需使用 Edge TTS
pip install edge-tts
# 如需使用 Kokoro TTS,启动本地 Docker 服务
cd /Users/m/document/QNSZ/project/kokoro-tts && ./start.sh
# 验证安装
python3 ~/.claude/skills/text-to-speech/scripts/text_to_speech.py --list-voices
<原文件名>_tts.mp3<原文件名>_tts_voice_changed.mp3MINIMAX_API_KEY 环境变量问题: 网络连接失败
问题: MiniMax 报缺少 Key
MINIMAX_API_KEY 环境变量config/tts_config.json问题: 声音不自然
问题: 后处理失败
Chinese (Mandarin)_Reliable_Executive--contextmale-qn-jingying(精英青年),语速 1.0MINIMAX_API_KEY 环境变量,防止密钥入库tts_engine 或 --engine 切换查看 SKILL.md 获取完整文档。
MIT
Generate or edit images via Gemini 3 Pro Image (Nano Banana Pro).
Batch-generate images via OpenAI Images API. Random prompt sampler + `index.html` gallery.
Generate spectrograms and feature-panel visualizations from audio with the songsee CLI.
Extract frames or short clips from videos using ffmpeg.
Search GIF providers with CLI/TUI, download results, and extract stills/sheets.
Category:media-generate