Mimo-TTS CLI
基于 MiMo-TTS API 的命令行文本转语音工具。
功能特性
- 文本转语音合成
- 支持多种音色(9 种)
- 自动语气转换(根据标点符号)
- 支持流式输出
- 直接播放音频
- 保存到文件
- CLI 美化输出
下载安装
预编译二进制
从 Releases 下载对应平台的二进制:
| 平台 | 文件名 |
|---|---|
| Linux x86_64 | mimo-tts-linux-amd64 |
| Linux ARM64 | mimo-tts-linux-arm64 |
| macOS Intel | mimo-tts-darwin-amd64 |
| macOS Apple Silicon | mimo-tts-darwin-arm64 |
| Windows x86_64 | mimo-tts-windows-amd64.exe |
# Linux/macOS
chmod +x mimo-tts-*
sudo mv mimo-tts-* /usr/local/bin/mimo-tts
# Windows
# 将 .exe 文件放到任意目录,添加到 PATH
快速开始
1. 配置 API Key
# 方式一:交互式配置
mimo-tts onboard
# 方式二:命令行配置
mimo-tts config set --api-key YOUR_API_KEY
获取 API Key:https://platform.xiaomimimo.com/
2. 语音合成
# 直接播放
mimo-tts --text "你好世界" --play
# 保存到文件
mimo-tts --text "你好世界" --output hello.wav
# 输出到 stdout(二进制流)
mimo-tts --text "你好世界" > hello.wav
使用方法
基本用法
# 文本转语音
mimo-tts --text "要合成的文本" --play
# 从文件读取
mimo-tts --file text.txt --play
参数说明
| 参数 | 简写 | 说明 | 默认值 |
|---|---|---|---|
--text |
-t |
要合成的文本 | - |
--file |
-f |
从文件读取文本 | - |
--voice |
-v |
音色名称 | mimo_default |
--style |
- | 风格描述 | - |
--output |
-o |
输出到文件 | - |
--play |
- | 直接播放 | false |
--stream |
- | 流式输出 (PCM16) | false |
可用音色
mimo_default - MiMo默认
冰糖 - 甜美清脆的女声
茉莉 - 温柔知性的女声
苏打 - 阳光活力的男声
白桦 - 沉稳大气的男声
Mia - 英文女声
Chloe - 英文女声
Milo - 英文男声
Dean - 英文男声
列出所有音色:
mimo-tts voices
风格描述
使用 --style 参数指定语音风格:
mimo-tts --text "你好" --style "开心" --play
mimo-tts --text "你好" --style "东北话" --play
mimo-tts --text "你好" --style "唱歌" --play
自动语气转换
工具会自动根据文本中的标点符号添加语气:
!→ 添加 [激动] 语气?→ 添加 [疑惑] 语气。→ 添加 [平静] 语气(默认)
示例:
mimo-tts --text "你好吗?" --play # 自动添加疑惑语气
mimo-tts --text "太棒了!" --play # 自动添加激动语气
流式输出
使用 --stream 参数进行流式输出:
# 流式输出到文件
mimo-tts --text "你好" --stream --output output.pcm
# 流式播放
mimo-tts --text "你好" --stream --play
注意:流式输出格式为 PCM16(原始音频),无 WAV 头。
配置管理
# 查看当前配置
mimo-tts show-config
# 设置 API Key
mimo-tts config set --api-key YOUR_KEY
# 设置默认音色
mimo-tts config set --voice 茉莉
配置文件
配置文件位于:~/.config/tts/config.toml
api_key = "YOUR_API_KEY"
default_voice = "mimo_default"
开发编译
环境要求
- Rust 1.70+
- Cargo
编译
# Debug 构建
cargo build
# Release 构建
cargo build --release
# 运行
cargo run -- --text "你好" --play
测试
# 运行测试
cargo test
# 运行特定测试
cargo test tone
项目结构
src/
├── main.rs # 主入口
├── cli.rs # CLI 参数定义
├── api.rs # API 调用
├── config.rs # 配置管理
├── tone.rs # 语气转换
└── ui.rs # UI 美化
退出码
| 码 | 说明 |
|---|---|
| 0 | 成功 |
| 1 | 参数错误 |
| 2 | 配置错误 |
| 3 | API 调用失败 |
| 4 | 文件操作失败 |
相关链接
- MiMo 开放平台:https://platform.xiaomimimo.com/
- GitHub:https://github.com/titor/mimo-tts
Description
Languages
Rust
100%