From 5ca7103b128971698b938d0a9fa66575c540693b Mon Sep 17 00:00:00 2001 From: femshima <49227365+femshima@users.noreply.github.com> Date: Thu, 23 Nov 2023 21:46:01 +0900 Subject: [PATCH 1/7] add code for model downloading --- Dockerfile | 13 +++++++++++++ src/synthesis/index.ts | 7 ++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index a9c60d71..db273a39 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,10 +15,23 @@ RUN npm ci COPY ./src/ ./src/ RUN npm run build +FROM node:18 AS model-fetch + +WORKDIR /app +RUN wget https://github.com/jpreprocess/jpreprocess/releases/download/v0.6.1/naist-jdic-jpreprocess.tar.gz \ + && tar xzf naist-jdic-jpreprocess.tar.gz \ + && rm naist-jdic-jpreprocess.tar.gz +RUN wget http://downloads.sourceforge.net/open-jtalk/hts_voice_nitech_jp_atr503_m001-1.05.tar.gz \ + && tar xzf hts_voice_nitech_jp_atr503_m001-1.05.tar.gz \ + && mv hts_voice_nitech_jp_atr503_m001-1.05/* ./ \ + && rm hts_voice_nitech_jp_atr503_m001-1.05.tar.gz \ + && rmdir hts_voice_nitech_jp_atr503_m001-1.05 + FROM gcr.io/distroless/nodejs18-debian12:nonroot AS runner WORKDIR /app ENV NODE_ENV=production COPY ./package.json ./ COPY --from=builder /app/dist/ ./dist/ COPY --from=deps /app/node_modules/ ./node_modules/ +COPY --from=model-fetch /app/ ./model/ CMD ["dist/main.js"] diff --git a/src/synthesis/index.ts b/src/synthesis/index.ts index f8ec8c78..0b627df0 100644 --- a/src/synthesis/index.ts +++ b/src/synthesis/index.ts @@ -1,10 +1,7 @@ import { Synthesizer } from "./synthesizer"; import WorkerSynthesizer from "./worker-synthesizer"; -if (!process.env.DICTIONARY || !process.env.MODEL) { - throw new Error("Dictionary and model must be specified."); -} export const synthesizer: Synthesizer = new WorkerSynthesizer( - process.env.DICTIONARY, - process.env.MODEL, + process.env.DICTIONARY ?? "/app/model/naist-jdic", + process.env.MODEL ?? "/app/model/nitech_jp_atr503_m001.htsvoice", ); From 3b71029e41ae9f0233a3ecc2b1d2676c503a255c Mon Sep 17 00:00:00 2001 From: femshima <49227365+femshima@users.noreply.github.com> Date: Thu, 23 Nov 2023 21:48:49 +0900 Subject: [PATCH 2/7] fix readme --- README.md | 38 ++++++-------------------------------- 1 file changed, 6 insertions(+), 32 deletions(-) diff --git a/README.md b/README.md index 50d377bc..1b6f20e7 100644 --- a/README.md +++ b/README.md @@ -8,39 +8,13 @@ Discord.js Japan User Group向けの読み上げボットです. `DISCORD_TOKEN=`の後に続けて,[Discord Developer Portal](https://discord.com/developers/applications) から取得したトークンを記述してください. -次に,`model`ディレクトリを作成し,ダウンロードした辞書と音声モデルを置いてください. -辞書は -[naist-jdic-jpreprocess.tar.gz](https://github.com/jpreprocess/jpreprocess/releases/download/v0.6.1/naist-jdic-jpreprocess.tar.gz), -モデルは -[hts_voice_nitech_jp_atr503_m001-1.05.tar.gz](http://downloads.sourceforge.net/open-jtalk/hts_voice_nitech_jp_atr503_m001-1.05.tar.gz) -をお勧めします. -いずれもダウンロードした後解凍が必要です. +次のコマンドを実行すると,ボットが起動します(Dockerがインストールされていることが必要です). -それぞれ次の図のように,パスが`model/naist-jdic`,`model/nitech_jp_atr503_m001.htsvoice`となるように配置してください. -``` -(project-root) -┣ model -┃ ┣ naist-jdic -┃ ┃ ┣ char_def.bin -┃ ┃ ┣ dict.da -┃ ┃ ┣ dict.vals -┃ ┃ ┣ dict.words -┃ ┃ ┣ dict.wordsidx -┃ ┃ ┣ matrix.mtx -┃ ┃ ┗ unk.bin -┃ ┗ nitech_jp_atr503_m001.htsvoice -┗ .env +```bash +docker run --rm -d --env-file .env ghcr.io/discordjs-japan/om:latest ``` -最後に,次のコマンドを実行すると,ボットが起動します(Dockerがインストールされていることが必要です). +## License Notice -```bash -docker run \ - --rm \ - -d \ - -v ./model:/app/model \ - --env-file .env \ - -e DICTIONARY=model/naist-jdic \ - -e MODEL=model/nitech_jp_atr503_m001.htsvoice \ - ghcr.io/discordjs-japan/om:latest -``` +The docker version includes `HTS Voice "NIT ATR503 M001" version 1.05` downloaded from: + Date: Thu, 23 Nov 2023 21:50:02 +0900 Subject: [PATCH 3/7] fix readme link --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1b6f20e7..717ed04a 100644 --- a/README.md +++ b/README.md @@ -17,4 +17,4 @@ docker run --rm -d --env-file .env ghcr.io/discordjs-japan/om:latest ## License Notice The docker version includes `HTS Voice "NIT ATR503 M001" version 1.05` downloaded from: - From 9460f41e3c7c9a8f81928c34c6aadca759d2173f Mon Sep 17 00:00:00 2001 From: femshima <49227365+femshima@users.noreply.github.com> Date: Thu, 23 Nov 2023 21:51:52 +0900 Subject: [PATCH 4/7] not quite license... --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 717ed04a..309c332c 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ Discord.js Japan User Group向けの読み上げボットです. docker run --rm -d --env-file .env ghcr.io/discordjs-japan/om:latest ``` -## License Notice +## Notice The docker version includes `HTS Voice "NIT ATR503 M001" version 1.05` downloaded from: From 334951ea505993bdb3e5db03e1b3abb2ad8e3255 Mon Sep 17 00:00:00 2001 From: femshima <49227365+femshima@users.noreply.github.com> Date: Fri, 24 Nov 2023 07:54:58 +0900 Subject: [PATCH 5/7] improve copyright notice --- README.md | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 309c332c..b777aad1 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,26 @@ Discord.js Japan User Group向けの読み上げボットです. docker run --rm -d --env-file .env ghcr.io/discordjs-japan/om:latest ``` -## Notice +## Copyright Notice -The docker version includes `HTS Voice "NIT ATR503 M001" version 1.05` downloaded from: - +### [HTS Voice "NIT ATR503 M001" version 1.05](http://downloads.sourceforge.net/open-jtalk/hts_voice_nitech_jp_atr503_m001-1.05.tar.gz) + +> [!NOTE] +> HTS Voice is only included in Docker container + +Creative Commons Attribution 3.0 + +- Copyright (c) 2003-2012 Nagoya Institute of Technology Department of Computer Science +- Copyright (c) 2003-2008 Tokyo Institute of Technology Interdisciplinary Graduate School of Science and Engineering + +### [naist-jdic](https://github.com/jpreprocess/jpreprocess/releases/download/v0.6.1/naist-jdic-jpreprocess.tar.gz) + +> [!NOTE] +> naist-jdic is only included in Docker container + +BSD 3-Clause License + +- Copyright (c) 2009, Nara Institute of Science and Technology, Japan. +- Copyright (c) 2011-2017, The UniDic Consortium +- Copyright (c) 2008-2016 Nagoya Institute of Technology Department of Computer Science +- Copyright (c) 2023, JPreprocess Team From d3944f5e2457f12d96bbbe28ee377118c733c6b1 Mon Sep 17 00:00:00 2001 From: femshima <49227365+femshima@users.noreply.github.com> Date: Fri, 24 Nov 2023 07:56:31 +0900 Subject: [PATCH 6/7] refer to package.json --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index b777aad1..0b62a124 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,8 @@ docker run --rm -d --env-file .env ghcr.io/discordjs-japan/om:latest ## Copyright Notice +For copyright of dependent packages, please see package.json. + ### [HTS Voice "NIT ATR503 M001" version 1.05](http://downloads.sourceforge.net/open-jtalk/hts_voice_nitech_jp_atr503_m001-1.05.tar.gz) > [!NOTE] From d3233dbfdfa8732abf7c1bd7dc0ba51fb4a02935 Mon Sep 17 00:00:00 2001 From: femshima <49227365+femshima@users.noreply.github.com> Date: Fri, 24 Nov 2023 07:59:13 +0900 Subject: [PATCH 7/7] put dict and model in separate directory --- Dockerfile | 4 +--- src/synthesis/index.ts | 3 ++- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index db273a39..0fc1c7b6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -23,9 +23,7 @@ RUN wget https://github.com/jpreprocess/jpreprocess/releases/download/v0.6.1/nai && rm naist-jdic-jpreprocess.tar.gz RUN wget http://downloads.sourceforge.net/open-jtalk/hts_voice_nitech_jp_atr503_m001-1.05.tar.gz \ && tar xzf hts_voice_nitech_jp_atr503_m001-1.05.tar.gz \ - && mv hts_voice_nitech_jp_atr503_m001-1.05/* ./ \ - && rm hts_voice_nitech_jp_atr503_m001-1.05.tar.gz \ - && rmdir hts_voice_nitech_jp_atr503_m001-1.05 + && rm hts_voice_nitech_jp_atr503_m001-1.05.tar.gz FROM gcr.io/distroless/nodejs18-debian12:nonroot AS runner WORKDIR /app diff --git a/src/synthesis/index.ts b/src/synthesis/index.ts index 0b627df0..d442ffbe 100644 --- a/src/synthesis/index.ts +++ b/src/synthesis/index.ts @@ -3,5 +3,6 @@ import WorkerSynthesizer from "./worker-synthesizer"; export const synthesizer: Synthesizer = new WorkerSynthesizer( process.env.DICTIONARY ?? "/app/model/naist-jdic", - process.env.MODEL ?? "/app/model/nitech_jp_atr503_m001.htsvoice", + process.env.MODEL ?? + "/app/model/hts_voice_nitech_jp_atr503_m001-1.05/nitech_jp_atr503_m001.htsvoice", );