diff --git a/.github/workflows/export-kitten.yaml b/.github/workflows/export-kitten.yaml index 8f5fca7e53..ac02460866 100644 --- a/.github/workflows/export-kitten.yaml +++ b/.github/workflows/export-kitten.yaml @@ -3,7 +3,7 @@ name: export-kitten-to-onnx on: push: branches: - - kitten-0.2 + - update-kitten workflow_dispatch: @@ -174,7 +174,7 @@ jobs: echo "$d exists" rm -rf huggingface - git clone https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/$d huggingface + git clone https://csukuangfj2:$HF_TOKEN@huggingface.co/csukuangfj2/$d huggingface cd huggingface rm -rf ./* @@ -194,5 +194,5 @@ jobs: git status git commit -m "add models" - git push https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/$d main || true + git push https://csukuangfj2:$HF_TOKEN@huggingface.co/csukuangfj2/$d main || true done diff --git a/wasm/tts/sherpa-onnx-tts.node.js b/wasm/tts/sherpa-onnx-tts.node.js index 70749d7232..c2c707f22e 100644 --- a/wasm/tts/sherpa-onnx-tts.node.js +++ b/wasm/tts/sherpa-onnx-tts.node.js @@ -1060,6 +1060,13 @@ function createOfflineTts(Module, myConfig) { offlineTtsPocketModelConfig.vocabJson = './vocab.json'; offlineTtsPocketModelConfig.tokenScoresJson = './token_scores.json'; break; + case 6: + // KittenTTS + offlineTtsKittenModelConfig.model = './model.onnx'; + offlineTtsKittenModelConfig.voices = './voices.bin'; + offlineTtsKittenModelConfig.tokens = './tokens.txt'; + offlineTtsKittenModelConfig.dataDir = './espeak-ng-data'; + break; } const offlineTtsModelConfig = { diff --git a/wasm/tts/sync-tts-node.py b/wasm/tts/sync-tts-node.py new file mode 100755 index 0000000000..3a589068dd --- /dev/null +++ b/wasm/tts/sync-tts-node.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python3 +# Synchronize sherpa-onnx-tts.node.js from sherpa-onnx-tts.js. +# The only difference should be the export mechanism: +# sherpa-onnx-tts.js uses ES module: export { ... } +# sherpa-onnx-tts.node.js uses CommonJS: module.exports = { ... } + +import os +import re + +dir_path = os.path.dirname(os.path.abspath(__file__)) +src = os.path.join(dir_path, "sherpa-onnx-tts.js") +dst = os.path.join(dir_path, "sherpa-onnx-tts.node.js") + +with open(src) as f: + content = f.read() + +# Replace ES module export with CommonJS module.exports +content = re.sub( + r"export \{[^}]*\};", + """if (typeof process == 'object' && typeof process.versions == 'object' &&\\n typeof process.versions.node == 'string') {\\n module.exports = {\\n createOfflineTts,\\n getDefaultOfflineTtsModelType,\\n };\\n}""", + content, +) + +with open(dst, "w") as f: + f.write(content) + +print(f"Updated {dst} from {src}")