Files
Ubuntu 32b43f85bd a
2026-07-03 16:58:28 +08:00

90 lines
1.8 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# TTS Streamer - 多语言文本转音频流
实时将文本转换为音频,通过 HTTP 流媒体远程收听。
## 功能特性
- ✅ **多语言支持**:中文、英文、日文
- ✅ **流式播放**:边转换边播放,无需等待
- ✅ **远程收听**:浏览器或播放器直接访问 URL
- ✅ **批量转换**:支持文件夹批量处理
- ✅ **轻量简洁**:基于 edge-tts,免费高质量
## 快速开始
### 1. 安装依赖
```bash
# Python 3.8+
pip install edge-tts
# 可选:HTTP 服务器
pip install flask
```
### 2. 测试转换
```bash
# 英文
python scripts/tts_convert.py articles/hello_en.txt --lang en
# 中文
python scripts/tts_convert.py articles/hello_zh.txt --lang zh
# 日文
python scripts/tts_convert.py articles/hello_jp.txt --lang jp
```
### 3. 启动流服务
```bash
# 单文件流式播放
python scripts/stream_server.py articles/hello_en.txt --port 8080
# 然后在浏览器或播放器打开:
# http://你的IP:8080/stream
```
## 语言代码
| 语言 | 代码 | 默认语音 |
|------|------|---------|
| 中文 | `zh` | 晓晓 (Xiaoxiao) |
| 英文 | `en` | Aria |
| 日文 | `jp` | Nanami |
## 目录结构
```
tts-streamer/
├── README.md
├── articles/ # 放文本文件
├── output/ # 输出音频文件
├── scripts/ # 工具脚本
│ ├── tts_convert.py # 转换脚本
│ ├── stream_server.py # 流服务
│ └── batch_convert.py # 批量转换
└── web/ # Web 控制界面
```
## 高级用法
### 批量转换
```bash
python scripts/batch_convert.py articles/ --output output/
```
### 内网穿透(无公网 IP)
```bash
# 使用 cloudflare tunnel
cloudflared tunnel --url http://localhost:8080
```
## 依赖
- Python 3.8+
- edge-tts (微软 Edge 语音)
- flask (可选,用于 Web 控制)