Skip to content

Commit 1ac7839

Browse files
committedAug 14, 2021
initial action
1 parent 78563fb commit 1ac7839

File tree

6 files changed

+153
-1
lines changed

6 files changed

+153
-1
lines changed
 

‎.github/workflows/test.yml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- uses: privapps/TTS-Mandarin@main
13+
with:
14+
text: '雄起'
15+
voice: '18'
16+
content: 'out.mp3'
17+
- run: ls -l

‎Dockerfile

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FROM ghcr.io/privapps/tts-mandarin:docker
2+
3+
COPY action.sh /
4+
COPY prepare.py /
5+
6+
RUN chmod +x /action.sh
7+
8+
CMD ["/action.sh"]
9+

‎README.md

+89-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,89 @@
1-
# TTS-Manderin
1+
# TTS-Mandarin
2+
3+
# What
4+
5+
提供中文文字转语音(Text To Speech / TTS) 的库/软件 这是拥有最基本 [mandarin-tts](https://github.com/ranchlai/mandarin-tts) 功能的 衍生 包括
6+
7+
### Github Action
8+
```
9+
jobs:
10+
job:
11+
steps:
12+
- uses: privapps/TTS-Mandarin@main
13+
with:
14+
text: '需要转换的文字'
15+
voice: '13'
16+
content: '输出mp3的路径'
17+
```
18+
see [action.yml](action.yml)
19+
### Docker Image Tool
20+
```bash
21+
echo "需要转换的文字" > __input__.txt
22+
echo 17 > __voice__.txt
23+
docker run --rm -v $(pwd):/workspace ghcr.io/privapps/tts-mandarin:docker
24+
25+
# output wav is at __out__.wav
26+
```
27+
28+
29+
# Why
30+
31+
因为TTSKIT作者删除了项目,之前 [ttskit](https://github.com/privapps/docker-ttskit) 完全不能用,我找到这个替代版本,基于 [mandarin-tts](https://github.com/ranchlai/mandarin-tts) 。这里把所有打包好了,可以拿起来马上用
32+
33+
注: 只支持中文, 阿拉伯数字, 英文统统不行
34+
35+
`吃葡萄不吐葡萄皮儿,不吃葡萄倒吐葡萄皮儿。床前明月光,一阵美人香。不知春梦里,枉自硬帮帮。`
36+
37+
| Voice ID | URL | |
38+
| --- | --- |--- |
39+
| 0 | https://github.com/privapps/TTS-Manderin/raw/sample/0.mp3 | |
40+
| 1 | https://github.com/privapps/TTS-Manderin/raw/sample/1.mp3 | |
41+
| 2 | https://github.com/privapps/TTS-Manderin/raw/sample/2.mp3 | |
42+
| 3 | https://github.com/privapps/TTS-Manderin/raw/sample/3.mp3 | |
43+
| 4 | https://github.com/privapps/TTS-Manderin/raw/sample/4.mp3 | |
44+
| 5 | https://github.com/privapps/TTS-Manderin/raw/sample/5.mp3 | |
45+
| 6 | https://github.com/privapps/TTS-Manderin/raw/sample/6.mp3 | |
46+
| 7 | https://github.com/privapps/TTS-Manderin/raw/sample/7.mp3 | |
47+
| 8 | https://github.com/privapps/TTS-Manderin/raw/sample/8.mp3 | |
48+
| 9 | https://github.com/privapps/TTS-Manderin/raw/sample/9.mp3 | |
49+
| 10 | https://github.com/privapps/TTS-Manderin/raw/sample/10.mp3 | M |
50+
| 11 | https://github.com/privapps/TTS-Manderin/raw/sample/11.mp3 | |
51+
| 12 | https://github.com/privapps/TTS-Manderin/raw/sample/12.mp3 | |
52+
| 13 | https://github.com/privapps/TTS-Manderin/raw/sample/13.mp3 | |
53+
| 14 | https://github.com/privapps/TTS-Manderin/raw/sample/14.mp3 | |
54+
| 15 | https://github.com/privapps/TTS-Manderin/raw/sample/15.mp3 | M |
55+
| 16 | https://github.com/privapps/TTS-Manderin/raw/sample/16.mp3 | |
56+
| 17 | https://github.com/privapps/TTS-Manderin/raw/sample/17.mp3 | |
57+
| 18 | https://github.com/privapps/TTS-Manderin/raw/sample/18.mp3 | |
58+
| 19 | https://github.com/privapps/TTS-Manderin/raw/sample/19.mp3 | |
59+
| 20 | https://github.com/privapps/TTS-Manderin/raw/sample/20.mp3 | |
60+
| 21 | https://github.com/privapps/TTS-Manderin/raw/sample/21.mp3 | M |
61+
| 22 | https://github.com/privapps/TTS-Manderin/raw/sample/22.mp3 | |
62+
| 23 | https://github.com/privapps/TTS-Manderin/raw/sample/23.mp3 | M |
63+
| 24 | https://github.com/privapps/TTS-Manderin/raw/sample/24.mp3 | |
64+
| 25 | https://github.com/privapps/TTS-Manderin/raw/sample/25.mp3 | M |
65+
| 26 | https://github.com/privapps/TTS-Manderin/raw/sample/26.mp3 | |
66+
| 27 | https://github.com/privapps/TTS-Manderin/raw/sample/27.mp3 | |
67+
| 28 | https://github.com/privapps/TTS-Manderin/raw/sample/28.mp3 | |
68+
| 29 | https://github.com/privapps/TTS-Manderin/raw/sample/29.mp3 | |
69+
| 30 | https://github.com/privapps/TTS-Manderin/raw/sample/30.mp3 | |
70+
| 31 | https://github.com/privapps/TTS-Manderin/raw/sample/31.mp3 | |
71+
| 32 | https://github.com/privapps/TTS-Manderin/raw/sample/32.mp3 | M |
72+
| 33 | https://github.com/privapps/TTS-Manderin/raw/sample/33.mp3 | |
73+
| 34 | https://github.com/privapps/TTS-Manderin/raw/sample/34.mp3 | |
74+
| 35 | https://github.com/privapps/TTS-Manderin/raw/sample/35.mp3 | |
75+
| 36 | https://github.com/privapps/TTS-Manderin/raw/sample/36.mp3 | |
76+
| 37 | https://github.com/privapps/TTS-Manderin/raw/sample/37.mp3 | |
77+
| 38 | https://github.com/privapps/TTS-Manderin/raw/sample/38.mp3 | |
78+
| 39 | https://github.com/privapps/TTS-Manderin/raw/sample/39.mp3 | |
79+
| 40 | https://github.com/privapps/TTS-Manderin/raw/sample/40.mp3 | M |
80+
| 41 | https://github.com/privapps/TTS-Manderin/raw/sample/41.mp3 | |
81+
| 42 | https://github.com/privapps/TTS-Manderin/raw/sample/42.mp3 | |
82+
| 43 | https://github.com/privapps/TTS-Manderin/raw/sample/43.mp3 | |
83+
| 44 | https://github.com/privapps/TTS-Manderin/raw/sample/44.mp3 | |
84+
| 45 | https://github.com/privapps/TTS-Manderin/raw/sample/45.mp3 | |
85+
| 46 | https://github.com/privapps/TTS-Manderin/raw/sample/46.mp3 | M |
86+
| 47 | https://github.com/privapps/TTS-Manderin/raw/sample/47.mp3 | |
87+
| 48 | https://github.com/privapps/TTS-Manderin/raw/sample/48.mp3 | M |
88+
| 49 | https://github.com/privapps/TTS-Manderin/raw/sample/49.mp3 | |
89+
| 50 | https://github.com/privapps/TTS-Manderin/raw/sample/50.mp3 | |

‎action.sh

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
3+
OUT_PATH=$(pwd)/$INPUT_CONTENT
4+
cd ~ ; ln -sf /root/checkpoints
5+
cd /
6+
python /prepare.py
7+
bash -c /docker_run.sh
8+
echo $WORKDIR/__out__.mp3 $INPUT_CONTENT
9+
mv $WORKDIR/__out__.mp3 $OUT_PATH

‎action.yml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# action.yml
2+
name: 'TTS-Mandarin'
3+
description: 'Generate Mandarin Speech From Text'
4+
inputs:
5+
text: # id of input
6+
description: 'What text?'
7+
required: true
8+
default: 'World'
9+
voice: # id of input
10+
description: 'What Voice'
11+
required: false
12+
default: '22'
13+
content: # id of output
14+
required: false
15+
description: 'path that wave binary save to'
16+
default: './__out__.mp3'
17+
runs:
18+
using: 'docker'
19+
image: 'Dockerfile'
20+
branding:
21+
icon: 'speaker'
22+
color: 'red'
23+

‎prepare.py

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import os
2+
3+
with open('/workspace/__input__.txt', 'wt') as f:
4+
f.write(os.environ['INPUT_TEXT'])
5+
with open('/workspace/__voice__.txt', 'wt') as f:
6+
f.write(os.environ['INPUT_VOICE'])

0 commit comments

Comments
 (0)