Skip to content
This repository was archived by the owner on Dec 24, 2021. It is now read-only.

Commit 0531928

Browse files
committed
try action
1 parent 75efd0f commit 0531928

File tree

4 files changed

+52
-11
lines changed

4 files changed

+52
-11
lines changed

.github/workflows/test.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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/docker-ttskit@main
13+
with:
14+
text: '1'
15+
content: './out.wav'
16+
- run: ls -l

Dockerfile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
FROM privapps/ttskit:0.1.6_base
22

3+
WORKDIR /workspace
4+
35
COPY run.sh /
46
COPY run.py /
5-
RUN mkdir -p $WORKDIR ; chmod a+rwx $WORKDIR run.sh
67

7-
ENTRYPOINT ["/run.sh"]
8+
RUN mkdir -p $WORKDIR ; chmod a+rwx $WORKDIR /run.sh
9+
10+
ENTRYPOINT ["python","/run.py"]

action.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# action.yml
2+
name: 'TTSKIT'
3+
description: 'Generate Chinese Mandarin voice 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: '24'
13+
content: # id of output
14+
required: false
15+
description: 'path that wave binary save to'
16+
default: './__out__.wav'
17+
runs:
18+
using: 'docker'
19+
image: 'Dockerfile'
20+
args:
21+
- ${{ inputs.text }}
22+
- ${{ inputs.voice }}

run.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,22 @@
55
# File: /workspace/__voice__.txt is optional with number only, which indicate which voice to use
66
# File: /workspace/__out__.wav is the one will be generated
77
##############################################
8-
import ttskit, sys
8+
import ttskit, sys, os
9+
10+
text = os.environ["INPUT_TEXT"]
11+
voice = os.environ["INPUT_VOICE"]
12+
wave_path = os.environ["INPUT_CONTENT"]
913

1014
def getVoice(default_val = 24) -> int:
1115
try:
12-
with open('/workspace/__voice__.txt', 'rt') as f:
13-
lines = f.readlines()
14-
num = int(''.join(lines))
16+
num = int(voice)
1517
return num if num > 0 and num <= 30 else default_val
1618
return num
1719
except Exception:
1820
return default_val
1921

20-
with open('/workspace/__input__.txt', 'rt') as f:
21-
lines = f.readlines()
22-
wav=ttskit.tts(' '.join(lines),audio=str(getVoice()))
22+
23+
wav=ttskit.tts(text,audio=str(getVoice()))
2324

24-
file_name='/workspace/__out__.wav'
25-
with open(file_name, "wb") as f:
25+
with open(wave_path, "wb") as f:
2626
f.write(wav)

0 commit comments

Comments
 (0)