Commit
·
9294636
1
Parent(s):
1fef2bd
update model
Browse files- sherpa-onnx-tts.js +77 -1
- sherpa-onnx-wasm-main-tts.js +0 -0
- sherpa-onnx-wasm-main-tts.wasm +2 -2
sherpa-onnx-tts.js
CHANGED
@@ -16,6 +16,10 @@ function freeConfig(config, Module) {
|
|
16 |
freeConfig(config.kokoro, Module)
|
17 |
}
|
18 |
|
|
|
|
|
|
|
|
|
19 |
Module._free(config.ptr);
|
20 |
}
|
21 |
|
@@ -204,6 +208,52 @@ function initSherpaOnnxOfflineTtsKokoroModelConfig(config, Module) {
|
|
204 |
}
|
205 |
}
|
206 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
207 |
function initSherpaOnnxOfflineTtsModelConfig(config, Module) {
|
208 |
if (!('offlineTtsVitsModelConfig' in config)) {
|
209 |
config.offlineTtsVitsModelConfig = {
|
@@ -244,6 +294,15 @@ function initSherpaOnnxOfflineTtsModelConfig(config, Module) {
|
|
244 |
};
|
245 |
}
|
246 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
247 |
|
248 |
const vitsModelConfig = initSherpaOnnxOfflineTtsVitsModelConfig(
|
249 |
config.offlineTtsVitsModelConfig, Module);
|
@@ -254,8 +313,11 @@ function initSherpaOnnxOfflineTtsModelConfig(config, Module) {
|
|
254 |
const kokoroModelConfig = initSherpaOnnxOfflineTtsKokoroModelConfig(
|
255 |
config.offlineTtsKokoroModelConfig, Module);
|
256 |
|
|
|
|
|
|
|
257 |
const len = vitsModelConfig.len + matchaModelConfig.len +
|
258 |
-
kokoroModelConfig.len + 3 * 4;
|
259 |
|
260 |
const ptr = Module._malloc(len);
|
261 |
|
@@ -281,9 +343,13 @@ function initSherpaOnnxOfflineTtsModelConfig(config, Module) {
|
|
281 |
Module._CopyHeap(kokoroModelConfig.ptr, kokoroModelConfig.len, ptr + offset);
|
282 |
offset += kokoroModelConfig.len;
|
283 |
|
|
|
|
|
|
|
284 |
return {
|
285 |
buffer: buffer, ptr: ptr, len: len, config: vitsModelConfig,
|
286 |
matcha: matchaModelConfig, kokoro: kokoroModelConfig,
|
|
|
287 |
}
|
288 |
}
|
289 |
|
@@ -413,12 +479,22 @@ function createOfflineTts(Module, myConfig) {
|
|
413 |
lengthScale: 1.0,
|
414 |
dictDir: '',
|
415 |
lexicon: '',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
416 |
};
|
417 |
|
418 |
const offlineTtsModelConfig = {
|
419 |
offlineTtsVitsModelConfig: offlineTtsVitsModelConfig,
|
420 |
offlineTtsMatchaModelConfig: offlineTtsMatchaModelConfig,
|
421 |
offlineTtsKokoroModelConfig: offlineTtsKokoroModelConfig,
|
|
|
422 |
numThreads: 1,
|
423 |
debug: 1,
|
424 |
provider: 'cpu',
|
|
|
16 |
freeConfig(config.kokoro, Module)
|
17 |
}
|
18 |
|
19 |
+
if ('kitten' in config) {
|
20 |
+
freeConfig(config.kitten, Module)
|
21 |
+
}
|
22 |
+
|
23 |
Module._free(config.ptr);
|
24 |
}
|
25 |
|
|
|
208 |
}
|
209 |
}
|
210 |
|
211 |
+
function initSherpaOnnxOfflineTtsKittenModelConfig(config, Module) {
|
212 |
+
const modelLen = Module.lengthBytesUTF8(config.model) + 1;
|
213 |
+
const voicesLen = Module.lengthBytesUTF8(config.voices) + 1;
|
214 |
+
const tokensLen = Module.lengthBytesUTF8(config.tokens || '') + 1;
|
215 |
+
const dataDirLen = Module.lengthBytesUTF8(config.dataDir || '') + 1;
|
216 |
+
|
217 |
+
const n = modelLen + voicesLen + tokensLen + dataDirLen;
|
218 |
+
|
219 |
+
const buffer = Module._malloc(n);
|
220 |
+
|
221 |
+
const len = 5 * 4;
|
222 |
+
const ptr = Module._malloc(len);
|
223 |
+
|
224 |
+
let offset = 0;
|
225 |
+
Module.stringToUTF8(config.model || '', buffer + offset, modelLen);
|
226 |
+
offset += modelLen;
|
227 |
+
|
228 |
+
Module.stringToUTF8(config.voices || '', buffer + offset, voicesLen);
|
229 |
+
offset += voicesLen;
|
230 |
+
|
231 |
+
Module.stringToUTF8(config.tokens || '', buffer + offset, tokensLen);
|
232 |
+
offset += tokensLen;
|
233 |
+
|
234 |
+
Module.stringToUTF8(config.dataDir || '', buffer + offset, dataDirLen);
|
235 |
+
offset += dataDirLen;
|
236 |
+
|
237 |
+
offset = 0;
|
238 |
+
Module.setValue(ptr, buffer + offset, 'i8*');
|
239 |
+
offset += modelLen;
|
240 |
+
|
241 |
+
Module.setValue(ptr + 4, buffer + offset, 'i8*');
|
242 |
+
offset += voicesLen;
|
243 |
+
|
244 |
+
Module.setValue(ptr + 8, buffer + offset, 'i8*');
|
245 |
+
offset += tokensLen;
|
246 |
+
|
247 |
+
Module.setValue(ptr + 12, buffer + offset, 'i8*');
|
248 |
+
offset += dataDirLen;
|
249 |
+
|
250 |
+
Module.setValue(ptr + 16, config.lengthScale || 1.0, 'float');
|
251 |
+
|
252 |
+
return {
|
253 |
+
buffer: buffer, ptr: ptr, len: len,
|
254 |
+
}
|
255 |
+
}
|
256 |
+
|
257 |
function initSherpaOnnxOfflineTtsModelConfig(config, Module) {
|
258 |
if (!('offlineTtsVitsModelConfig' in config)) {
|
259 |
config.offlineTtsVitsModelConfig = {
|
|
|
294 |
};
|
295 |
}
|
296 |
|
297 |
+
if (!('offlineTtsKittenModelConfig' in config)) {
|
298 |
+
config.offlineTtsKittenModelConfig = {
|
299 |
+
model: '',
|
300 |
+
voices: '',
|
301 |
+
tokens: '',
|
302 |
+
lengthScale: 1.0,
|
303 |
+
};
|
304 |
+
}
|
305 |
+
|
306 |
|
307 |
const vitsModelConfig = initSherpaOnnxOfflineTtsVitsModelConfig(
|
308 |
config.offlineTtsVitsModelConfig, Module);
|
|
|
313 |
const kokoroModelConfig = initSherpaOnnxOfflineTtsKokoroModelConfig(
|
314 |
config.offlineTtsKokoroModelConfig, Module);
|
315 |
|
316 |
+
const kittenModelConfig = initSherpaOnnxOfflineTtsKittenModelConfig(
|
317 |
+
config.offlineTtsKittenModelConfig, Module);
|
318 |
+
|
319 |
const len = vitsModelConfig.len + matchaModelConfig.len +
|
320 |
+
kokoroModelConfig.len + kittenModelConfig.len + 3 * 4;
|
321 |
|
322 |
const ptr = Module._malloc(len);
|
323 |
|
|
|
343 |
Module._CopyHeap(kokoroModelConfig.ptr, kokoroModelConfig.len, ptr + offset);
|
344 |
offset += kokoroModelConfig.len;
|
345 |
|
346 |
+
Module._CopyHeap(kittenModelConfig.ptr, kittenModelConfig.len, ptr + offset);
|
347 |
+
offset += kittenModelConfig.len;
|
348 |
+
|
349 |
return {
|
350 |
buffer: buffer, ptr: ptr, len: len, config: vitsModelConfig,
|
351 |
matcha: matchaModelConfig, kokoro: kokoroModelConfig,
|
352 |
+
kitten: kittenModelConfig,
|
353 |
}
|
354 |
}
|
355 |
|
|
|
479 |
lengthScale: 1.0,
|
480 |
dictDir: '',
|
481 |
lexicon: '',
|
482 |
+
lang: '',
|
483 |
+
};
|
484 |
+
|
485 |
+
const offlineTtsKittenModelConfig = {
|
486 |
+
model: '',
|
487 |
+
voices: '',
|
488 |
+
tokens: '',
|
489 |
+
dataDir: '',
|
490 |
+
lengthScale: 1.0,
|
491 |
};
|
492 |
|
493 |
const offlineTtsModelConfig = {
|
494 |
offlineTtsVitsModelConfig: offlineTtsVitsModelConfig,
|
495 |
offlineTtsMatchaModelConfig: offlineTtsMatchaModelConfig,
|
496 |
offlineTtsKokoroModelConfig: offlineTtsKokoroModelConfig,
|
497 |
+
offlineTtsKittenModelConfig: offlineTtsKittenModelConfig,
|
498 |
numThreads: 1,
|
499 |
debug: 1,
|
500 |
provider: 'cpu',
|
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:f7b138cad9d37facfeb8ba03ac1df376fba9b2f3d0c90486ddcfaea298f09c03
|
3 |
+
size 11764197
|