csukuangfj
commited on
Commit
•
5567528
1
Parent(s):
705e4a8
update model
Browse files- sherpa-onnx-tts.js +20 -24
- sherpa-onnx-wasm-main-tts.js +0 -0
- sherpa-onnx-wasm-main-tts.wasm +2 -2
sherpa-onnx-tts.js
CHANGED
@@ -14,14 +14,10 @@ function freeConfig(config, Module) {
|
|
14 |
// The user should free the returned pointers
|
15 |
function initSherpaOnnxOfflineTtsVitsModelConfig(config, Module) {
|
16 |
const modelLen = Module.lengthBytesUTF8(config.model) + 1;
|
17 |
-
const lexiconLen = Module.lengthBytesUTF8(config.lexicon) + 1;
|
18 |
-
const tokensLen = Module.lengthBytesUTF8(config.tokens) + 1;
|
19 |
-
const dataDirLen = Module.lengthBytesUTF8(config.dataDir) + 1;
|
20 |
-
|
21 |
-
if (!('dictDir' in config)) {
|
22 |
-
config.dictDir = ''
|
23 |
-
}
|
24 |
-
const dictDirLen = Module.lengthBytesUTF8(config.dictDir) + 1;
|
25 |
|
26 |
const n = modelLen + lexiconLen + tokensLen + dataDirLen + dictDirLen;
|
27 |
|
@@ -31,19 +27,19 @@ function initSherpaOnnxOfflineTtsVitsModelConfig(config, Module) {
|
|
31 |
const ptr = Module._malloc(len);
|
32 |
|
33 |
let offset = 0;
|
34 |
-
Module.stringToUTF8(config.model, buffer + offset, modelLen);
|
35 |
offset += modelLen;
|
36 |
|
37 |
-
Module.stringToUTF8(config.lexicon, buffer + offset, lexiconLen);
|
38 |
offset += lexiconLen;
|
39 |
|
40 |
-
Module.stringToUTF8(config.tokens, buffer + offset, tokensLen);
|
41 |
offset += tokensLen;
|
42 |
|
43 |
-
Module.stringToUTF8(config.dataDir, buffer + offset, dataDirLen);
|
44 |
offset += dataDirLen;
|
45 |
|
46 |
-
Module.stringToUTF8(config.dictDir, buffer + offset, dictDirLen);
|
47 |
offset += dictDirLen;
|
48 |
|
49 |
offset = 0;
|
@@ -59,9 +55,9 @@ function initSherpaOnnxOfflineTtsVitsModelConfig(config, Module) {
|
|
59 |
Module.setValue(ptr + 12, buffer + offset, 'i8*');
|
60 |
offset += dataDirLen;
|
61 |
|
62 |
-
Module.setValue(ptr + 16, config.noiseScale, 'float');
|
63 |
-
Module.setValue(ptr + 20, config.noiseScaleW, 'float');
|
64 |
-
Module.setValue(ptr + 24, config.lengthScale, 'float');
|
65 |
Module.setValue(ptr + 28, buffer + offset, 'i8*');
|
66 |
offset += dictDirLen;
|
67 |
|
@@ -81,13 +77,13 @@ function initSherpaOnnxOfflineTtsModelConfig(config, Module) {
|
|
81 |
Module._CopyHeap(vitsModelConfig.ptr, vitsModelConfig.len, ptr + offset);
|
82 |
offset += vitsModelConfig.len;
|
83 |
|
84 |
-
Module.setValue(ptr + offset, config.numThreads, 'i32');
|
85 |
offset += 4;
|
86 |
|
87 |
-
Module.setValue(ptr + offset, config.debug, 'i32');
|
88 |
offset += 4;
|
89 |
|
90 |
-
const providerLen = Module.lengthBytesUTF8(config.provider) + 1;
|
91 |
const buffer = Module._malloc(providerLen);
|
92 |
Module.stringToUTF8(config.provider, buffer, providerLen);
|
93 |
Module.setValue(ptr + offset, buffer, 'i8*');
|
@@ -107,17 +103,17 @@ function initSherpaOnnxOfflineTtsConfig(config, Module) {
|
|
107 |
Module._CopyHeap(modelConfig.ptr, modelConfig.len, ptr + offset);
|
108 |
offset += modelConfig.len;
|
109 |
|
110 |
-
const ruleFstsLen = Module.lengthBytesUTF8(config.ruleFsts) + 1;
|
111 |
-
const ruleFarsLen = Module.lengthBytesUTF8(config.ruleFars) + 1;
|
112 |
|
113 |
const buffer = Module._malloc(ruleFstsLen + ruleFarsLen);
|
114 |
-
Module.stringToUTF8(config.ruleFsts, buffer, ruleFstsLen);
|
115 |
-
Module.stringToUTF8(config.ruleFars, buffer + ruleFstsLen, ruleFarsLen);
|
116 |
|
117 |
Module.setValue(ptr + offset, buffer, 'i8*');
|
118 |
offset += 4;
|
119 |
|
120 |
-
Module.setValue(ptr + offset, config.maxNumSentences, 'i32');
|
121 |
offset += 4;
|
122 |
|
123 |
Module.setValue(ptr + offset, buffer + ruleFstsLen, 'i8*');
|
|
|
14 |
// The user should free the returned pointers
|
15 |
function initSherpaOnnxOfflineTtsVitsModelConfig(config, Module) {
|
16 |
const modelLen = Module.lengthBytesUTF8(config.model) + 1;
|
17 |
+
const lexiconLen = Module.lengthBytesUTF8(config.lexicon || '') + 1;
|
18 |
+
const tokensLen = Module.lengthBytesUTF8(config.tokens || '') + 1;
|
19 |
+
const dataDirLen = Module.lengthBytesUTF8(config.dataDir || '') + 1;
|
20 |
+
const dictDirLen = Module.lengthBytesUTF8(config.dictDir || '') + 1;
|
|
|
|
|
|
|
|
|
21 |
|
22 |
const n = modelLen + lexiconLen + tokensLen + dataDirLen + dictDirLen;
|
23 |
|
|
|
27 |
const ptr = Module._malloc(len);
|
28 |
|
29 |
let offset = 0;
|
30 |
+
Module.stringToUTF8(config.model || '', buffer + offset, modelLen);
|
31 |
offset += modelLen;
|
32 |
|
33 |
+
Module.stringToUTF8(config.lexicon || '', buffer + offset, lexiconLen);
|
34 |
offset += lexiconLen;
|
35 |
|
36 |
+
Module.stringToUTF8(config.tokens || '', buffer + offset, tokensLen);
|
37 |
offset += tokensLen;
|
38 |
|
39 |
+
Module.stringToUTF8(config.dataDir || '', buffer + offset, dataDirLen);
|
40 |
offset += dataDirLen;
|
41 |
|
42 |
+
Module.stringToUTF8(config.dictDir || '', buffer + offset, dictDirLen);
|
43 |
offset += dictDirLen;
|
44 |
|
45 |
offset = 0;
|
|
|
55 |
Module.setValue(ptr + 12, buffer + offset, 'i8*');
|
56 |
offset += dataDirLen;
|
57 |
|
58 |
+
Module.setValue(ptr + 16, config.noiseScale || 0.667, 'float');
|
59 |
+
Module.setValue(ptr + 20, config.noiseScaleW || 0.8, 'float');
|
60 |
+
Module.setValue(ptr + 24, config.lengthScale || 1.0, 'float');
|
61 |
Module.setValue(ptr + 28, buffer + offset, 'i8*');
|
62 |
offset += dictDirLen;
|
63 |
|
|
|
77 |
Module._CopyHeap(vitsModelConfig.ptr, vitsModelConfig.len, ptr + offset);
|
78 |
offset += vitsModelConfig.len;
|
79 |
|
80 |
+
Module.setValue(ptr + offset, config.numThreads || 1, 'i32');
|
81 |
offset += 4;
|
82 |
|
83 |
+
Module.setValue(ptr + offset, config.debug || 0, 'i32');
|
84 |
offset += 4;
|
85 |
|
86 |
+
const providerLen = Module.lengthBytesUTF8(config.provider || 'cpu') + 1;
|
87 |
const buffer = Module._malloc(providerLen);
|
88 |
Module.stringToUTF8(config.provider, buffer, providerLen);
|
89 |
Module.setValue(ptr + offset, buffer, 'i8*');
|
|
|
103 |
Module._CopyHeap(modelConfig.ptr, modelConfig.len, ptr + offset);
|
104 |
offset += modelConfig.len;
|
105 |
|
106 |
+
const ruleFstsLen = Module.lengthBytesUTF8(config.ruleFsts || '') + 1;
|
107 |
+
const ruleFarsLen = Module.lengthBytesUTF8(config.ruleFars || '') + 1;
|
108 |
|
109 |
const buffer = Module._malloc(ruleFstsLen + ruleFarsLen);
|
110 |
+
Module.stringToUTF8(config.ruleFsts || '', buffer, ruleFstsLen);
|
111 |
+
Module.stringToUTF8(config.ruleFars || '', buffer + ruleFstsLen, ruleFarsLen);
|
112 |
|
113 |
Module.setValue(ptr + offset, buffer, 'i8*');
|
114 |
offset += 4;
|
115 |
|
116 |
+
Module.setValue(ptr + offset, config.maxNumSentences || 1, 'i32');
|
117 |
offset += 4;
|
118 |
|
119 |
Module.setValue(ptr + offset, buffer + ruleFstsLen, 'i8*');
|
sherpa-onnx-wasm-main-tts.js
CHANGED
The diff for this file is too large to render.
See raw diff
|
|
sherpa-onnx-wasm-main-tts.wasm
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:c511de4df62a6f0e9fbb65cf0efb8f26bb4c03ef3c5e7d830ba2b1e30470a06d
|
3 |
+
size 11476859
|