mirror of
https://github.com/k2-fsa/sherpa-onnx.git
synced 2026-11-10 21:11:03 +08:00
Export KittenTTS models (#3604)
This commit is contained in:
1 parent
ceb1189bb4
commit
63d0d71b30
3 files changed
+37
-3
No files matched your search
@@ -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
|
||||
@@ -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 = {
|
||||
|
||||
Executable
+27
@@ -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}")
|
||||
Reference in new issue
Block a user