Skip to content

Commit 2013524

Browse files
authored
chore: update files
1 parent f668702 commit 2013524

9 files changed

Lines changed: 407 additions & 146 deletions

File tree

‎README.md‎

Lines changed: 44 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -12,39 +12,33 @@
1212
<a href="https://pepy.tech/project/rapidtts"><img src="https://static.pepy.tech/personalized-badge/rapidtts?style=flat-square&period=total&units=abbreviation&left_color=grey&right_color=blue&left_text=Downloads"></a>
1313
<a href="https://semver.org/"><img alt="SemVer" src="https://img.shields.io/badge/semver-2.0-3D9970?style=flat-square"></a>
1414
<a href="https://github.com/psf/black"><img alt="Code style: black" src="https://img.shields.io/badge/code%20style-black-000000?style=flat-square"></a>
15-
1615
</div>
1716

1817
## 简介
1918

20-
RapidTTS 是一个轻量级文本转语音工具,面向本地快速推理。当前默认后端是 Kokoro ONNX。
19+
RapidTTS 是一个轻量级文本转语音工具,面向本地快速推理。当前默认后端是 `kokoro_onnx`,同时支持 `melo_onnx`。
2120

2221
## 特性
2322

2423
- 支持 Kokoro ONNX 和 MeloTTS ONNX 推理
2524
- 支持中文、英文和中英混合文本
26-
- 支持查询每个模型的语言和音色能力
27-
- 默认模型自动下载,并使用 SHA256 校验
28-
- 提供命令行工具:下载模型、检查安装、文本合成
29-
- 提供 Python API,便于集成到应用中
25+
- 支持查询模型语言、默认参数和音色能力
26+
- 模型文件可自动下载,并使用 SHA256 校验
27+
- 同时提供 Python API 和命令行工具
3028

3129
## 安装
3230

31+
默认推荐安装 Kokoro ONNX 后端:
32+
3333
```bash
3434
pip install "rapidtts[kokoro]"
3535
```
3636

37-
如果只安装核心包,可以使用 `pip install rapidtts`;运行具体后端前需要安装对应 extra。
37+
其他安装方式见 [安装说明](docs/installation.md)。
3838

3939
## 快速使用
4040

41-
命令行合成:
42-
43-
```bash
44-
rapidtts text "你好,RapidTTS" outputs/1.wav
45-
```
46-
47-
Python 调用:
41+
### Python API
4842

4943
```python
5044
from rapidtts import RapidTTS, SynthesisRequest
@@ -54,27 +48,50 @@ resp = tts.synthesize(SynthesisRequest(text="你好,RapidTTS"))
5448
resp.save("outputs/1.wav")
5549
```
5650

57-
查看模型支持的语言和音色:
51+
指定模型和音色:
52+
53+
```python
54+
from rapidtts import RapidTTS, SynthesisRequest, TTSModel
55+
56+
tts = RapidTTS(model=TTSModel.KOKORO_ONNX)
57+
resp = tts.synthesize(
58+
SynthesisRequest(
59+
text="你好,RapidTTS",
60+
voice="zm_009",
61+
)
62+
)
63+
resp.save("outputs/zm_009.wav")
64+
```
65+
66+
更多示例见 [Python API](docs/python_api.md)。
67+
68+
### 命令行
69+
70+
```bash
71+
rapidtts text "你好,RapidTTS" outputs/1.wav
72+
```
73+
74+
指定模型:
5875

5976
```bash
60-
rapidtts info kokoro_onnx
61-
rapidtts voices kokoro_onnx
77+
rapidtts text "你好,RapidTTS" outputs/kokoro.wav --model kokoro_onnx
6278
```
6379

64-
## 支持的模型和语言
80+
指定模型和音色:
81+
82+
```bash
83+
rapidtts text "你好,RapidTTS" outputs/zm_009.wav --model kokoro_onnx --voice zm_009
84+
```
6585

66-
|模型名称|支持语言|备注|
67-
|:---|:---|:---|
68-
|`kokoro_onnx`|中英混合|默认后端,支持多音色|
69-
|`melo_onnx`|中英混合|可选后端,安装 `rapidtts[melo]`|
86+
更多命令见 [命令行用法](docs/cli.md)。
7087

7188
## 文档
7289

73-
- [安装说明](docs/installation.md)
74-
- [命令行用法](docs/cli.md)
75-
- [Python API](docs/python_api.md)
76-
- [模型文件](docs/models.md)
77-
- [开发说明](docs/development.md)
90+
- [安装说明](docs/installation.md):安装 extra、检查依赖和模型文件
91+
- [Python API](docs/python_api.md):在代码中指定模型、音色、语言、语速和模型目录
92+
- [命令行用法](docs/cli.md):下载模型、检查安装、查询能力、合成音频
93+
- [模型信息](docs/models.md):支持的模型、语言、音色规则和模型文件
94+
- [开发说明](docs/development.md):测试、文本归一化和项目结构
7895

7996
## 致谢
8097

‎docs/cli.md‎

Lines changed: 62 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,70 @@
11
# 命令行用法
22

3-
RapidTTS 安装后会提供 `rapidtts` 命令。
3+
RapidTTS 安装后会提供 `rapidtts` 命令。CLI 适合下载模型、检查环境、查看模型能力,以及从文本生成音频文件。
44

55
## 命令速查
66

77
```bash
8-
rapidtts download [kokoro_onnx] [--save-dir DIR] [--no-progress] [--quiet]
9-
rapidtts check [kokoro_onnx] [--model-dir DIR] [--init-backend] [--quiet]
10-
rapidtts info [kokoro_onnx] [--model-dir DIR] [--quiet]
11-
rapidtts voices [kokoro_onnx] [--model-dir DIR] [--quiet]
12-
rapidtts text TEXT OUTPUT [--model kokoro_onnx] [--model-dir DIR] [--language ZH|EN|ZH_MIX_EN] [--speed SPEED] [--sample-rate SAMPLE_RATE] [--quiet]
8+
rapidtts download [MODEL] [--save-dir DIR] [--no-progress] [--quiet]
9+
rapidtts check [MODEL] [--model-dir DIR] [--init-backend] [--quiet]
10+
rapidtts info [MODEL] [--model-dir DIR] [--quiet]
11+
rapidtts voices [MODEL] [--model-dir DIR] [--quiet]
12+
rapidtts text TEXT OUTPUT [--model MODEL] [--model-dir DIR] [--language ZH|EN|ZH_MIX_EN] [--voice VOICE] [--speed SPEED] [--sample-rate SAMPLE_RATE] [--quiet]
1313
```
1414

15-
## 检查安装
15+
`MODEL` 可选:
16+
17+
- `kokoro_onnx`:默认后端
18+
- `melo_onnx`:MeloTTS ONNX 后端
19+
20+
## 生成音频
21+
22+
最小示例:
1623

1724
```bash
18-
rapidtts check
25+
rapidtts text "你好,RapidTTS" outputs/1.wav
1926
```
2027

21-
检查自定义模型目录:
28+
指定模型:
2229

2330
```bash
24-
rapidtts check kokoro_onnx --model-dir /path/to/kokoro_onnx
31+
rapidtts text "你好,RapidTTS" outputs/kokoro.wav --model kokoro_onnx
32+
rapidtts text "你好,RapidTTS" outputs/melo.wav --model melo_onnx
2533
```
2634

27-
同时初始化后端:
35+
指定语言:
2836

2937
```bash
30-
rapidtts check --init-backend
38+
rapidtts text "hello world" outputs/en.wav --language EN
39+
rapidtts text "你好,RapidTTS" outputs/zh.wav --language ZH
40+
rapidtts text "我在学习machine learning" outputs/mix.wav --language ZH_MIX_EN
41+
```
42+
43+
指定音色:
44+
45+
```bash
46+
rapidtts voices kokoro_onnx
47+
rapidtts text "你好,RapidTTS" outputs/zm_009.wav --model kokoro_onnx --voice zm_009
48+
```
49+
50+
`--voice` 对应 Python API 中的 `SynthesisRequest.voice`。
51+
52+
MeloTTS ONNX 当前只暴露 `zf_001`:
53+
54+
```bash
55+
rapidtts text "你好,RapidTTS" outputs/melo_zf_001.wav --model melo_onnx --voice zf_001
56+
```
57+
58+
指定语速和采样率:
59+
60+
```bash
61+
rapidtts text "你好,RapidTTS" outputs/fast.wav --speed 1.2 --sample-rate 16000
62+
```
63+
64+
使用自定义模型目录:
65+
66+
```bash
67+
rapidtts text "你好,RapidTTS" outputs/1.wav --model kokoro_onnx --model-dir /path/to/kokoro_onnx
3168
```
3269

3370
## 查看模型能力
@@ -44,16 +81,9 @@ rapidtts info kokoro_onnx
4481
rapidtts voices kokoro_onnx
4582
```
4683

47-
Kokoro ONNX 是默认后端,建议安装:
84+
查看 MeloTTS ONNX:
4885

4986
```bash
50-
pip install "rapidtts[kokoro]"
51-
```
52-
53-
MeloTTS 后端需要额外依赖:
54-
55-
```bash
56-
pip install "rapidtts[melo]"
5787
rapidtts info melo_onnx
5888
rapidtts voices melo_onnx
5989
```
@@ -78,37 +108,35 @@ rapidtts download kokoro_onnx --save-dir /path/to/kokoro_onnx
78108
rapidtts download kokoro_onnx --no-progress
79109
```
80110

81-
关闭日志:
82-
83-
```bash
84-
rapidtts download kokoro_onnx --quiet
85-
```
111+
## 检查安装
86112

87-
## 文本合成
113+
检查默认模型和依赖:
88114

89115
```bash
90-
rapidtts text "你好,RapidTTS" outputs/1.wav
116+
rapidtts check
91117
```
92118

93-
指定语言:
119+
检查指定模型:
94120

95121
```bash
96-
rapidtts text "hello world" outputs/en.wav --language EN
122+
rapidtts check melo_onnx
97123
```
98124

99-
指定语速和采样率:
125+
检查自定义模型目录:
100126

101127
```bash
102-
rapidtts text "你好,RapidTTS" outputs/1.wav --speed 1.2 --sample-rate 16000
128+
rapidtts check kokoro_onnx --model-dir /path/to/kokoro_onnx
103129
```
104130

105-
使用自定义模型目录:
131+
同时初始化后端:
106132

107133
```bash
108-
rapidtts text "你好,RapidTTS" outputs/1.wav --model-dir /path/to/melotts_zh_mix_en_onnx
134+
rapidtts check kokoro_onnx --init-backend
109135
```
110136

111-
关闭 RapidTTS 日志:
137+
## 关闭日志
138+
139+
所有子命令都支持 `--quiet`:
112140

113141
```bash
114142
rapidtts text "你好,RapidTTS" outputs/1.wav --quiet

‎docs/installation.md‎

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,25 @@
11
# 安装说明
22

3+
默认推荐安装 Kokoro ONNX 后端:
4+
35
```bash
46
pip install "rapidtts[kokoro]"
57
```
68

7-
`pip install rapidtts` 只安装核心依赖。使用具体后端时建议安装对应 extra:
9+
## 安装选项
810

911
```bash
10-
pip install "rapidtts[kokoro]" # 默认 Kokoro ONNX 后端
11-
pip install "rapidtts[melo]" # MeloTTS 后端
12-
pip install "rapidtts[all]" # 所有后端
12+
pip install rapidtts # 只安装核心依赖
13+
pip install "rapidtts[kokoro]" # 安装默认 Kokoro ONNX 后端
14+
pip install "rapidtts[melo]" # 安装 MeloTTS ONNX 后端
15+
pip install "rapidtts[all]" # 安装全部后端依赖
1316
```
1417

18+
只安装 `rapidtts` 时不会安装具体后端的额外依赖。运行某个后端前,请安装对应 extra。
19+
1520
## 检查安装
1621

17-
安装完成后可以运行:
22+
安装完成后运行:
1823

1924
```bash
2025
rapidtts check
@@ -23,23 +28,39 @@ rapidtts check
2328
该命令会检查:
2429

2530
- RapidTTS 包是否可以正常导入
26-
- 关键依赖是否存在
31+
- 当前模型所需依赖是否存在
2732
- `config.yaml` 和 `models.yaml` 是否可解析
28-
- 默认模型文件是否存在,SHA256 是否正确
33+
- 模型文件是否存在,SHA256 是否正确
2934

3035
如果还希望验证后端能否初始化:
3136

3237
```bash
3338
rapidtts check --init-backend
3439
```
3540

36-
如果模型文件缺失,先执行:
41+
## 下载模型
42+
43+
如果模型文件缺失,可以手动下载:
3744

3845
```bash
3946
rapidtts download kokoro_onnx
4047
```
4148

42-
如果需要使用 MeloTTS 后端,额外安装:
49+
下载到自定义目录:
50+
51+
```bash
52+
rapidtts download kokoro_onnx --save-dir /path/to/kokoro_onnx
53+
```
54+
55+
检查自定义目录:
56+
57+
```bash
58+
rapidtts check kokoro_onnx --model-dir /path/to/kokoro_onnx
59+
```
60+
61+
## MeloTTS ONNX
62+
63+
使用 MeloTTS ONNX 时安装对应 extra:
4364

4465
```bash
4566
pip install "rapidtts[melo]"

0 commit comments

Comments
 (0)