Commit
·
6d26682
1
Parent(s):
7da4dd1
update model
Browse files- sherpa-onnx-asr.js +71 -4
- sherpa-onnx-wasm-main-vad-asr.js +0 -0
- sherpa-onnx-wasm-main-vad-asr.wasm +2 -2
sherpa-onnx-asr.js
CHANGED
|
@@ -35,6 +35,10 @@ function freeConfig(config, Module) {
|
|
| 35 |
freeConfig(config.whisper, Module)
|
| 36 |
}
|
| 37 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
if ('tdnn' in config) {
|
| 39 |
freeConfig(config.tdnn, Module)
|
| 40 |
}
|
|
@@ -563,7 +567,7 @@ function initSherpaOnnxOfflineWhisperModelConfig(config, Module) {
|
|
| 563 |
const n = encoderLen + decoderLen + languageLen + taskLen;
|
| 564 |
const buffer = Module._malloc(n);
|
| 565 |
|
| 566 |
-
const len = 5 * 4; // 4 pointers
|
| 567 |
const ptr = Module._malloc(len);
|
| 568 |
|
| 569 |
let offset = 0;
|
|
@@ -598,6 +602,55 @@ function initSherpaOnnxOfflineWhisperModelConfig(config, Module) {
|
|
| 598 |
}
|
| 599 |
}
|
| 600 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 601 |
function initSherpaOnnxOfflineTdnnModelConfig(config, Module) {
|
| 602 |
const n = Module.lengthBytesUTF8(config.model || '') + 1;
|
| 603 |
const buffer = Module._malloc(n);
|
|
@@ -693,6 +746,15 @@ function initSherpaOnnxOfflineModelConfig(config, Module) {
|
|
| 693 |
};
|
| 694 |
}
|
| 695 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 696 |
if (!('tdnn' in config)) {
|
| 697 |
config.tdnn = {
|
| 698 |
model: '',
|
|
@@ -724,8 +786,11 @@ function initSherpaOnnxOfflineModelConfig(config, Module) {
|
|
| 724 |
const senseVoice =
|
| 725 |
initSherpaOnnxOfflineSenseVoiceModelConfig(config.senseVoice, Module);
|
| 726 |
|
|
|
|
|
|
|
|
|
|
| 727 |
const len = transducer.len + paraformer.len + nemoCtc.len + whisper.len +
|
| 728 |
-
tdnn.len + 8 * 4 + senseVoice.len;
|
| 729 |
|
| 730 |
const ptr = Module._malloc(len);
|
| 731 |
|
|
@@ -745,7 +810,6 @@ function initSherpaOnnxOfflineModelConfig(config, Module) {
|
|
| 745 |
Module._CopyHeap(tdnn.ptr, tdnn.len, ptr + offset);
|
| 746 |
offset += tdnn.len;
|
| 747 |
|
| 748 |
-
|
| 749 |
const tokensLen = Module.lengthBytesUTF8(config.tokens || '') + 1;
|
| 750 |
const providerLen = Module.lengthBytesUTF8(config.provider || 'cpu') + 1;
|
| 751 |
const modelTypeLen = Module.lengthBytesUTF8(config.modelType || '') + 1;
|
|
@@ -817,11 +881,14 @@ function initSherpaOnnxOfflineModelConfig(config, Module) {
|
|
| 817 |
offset += 4;
|
| 818 |
|
| 819 |
Module._CopyHeap(senseVoice.ptr, senseVoice.len, ptr + offset);
|
|
|
|
|
|
|
|
|
|
| 820 |
|
| 821 |
return {
|
| 822 |
buffer: buffer, ptr: ptr, len: len, transducer: transducer,
|
| 823 |
paraformer: paraformer, nemoCtc: nemoCtc, whisper: whisper, tdnn: tdnn,
|
| 824 |
-
senseVoice: senseVoice,
|
| 825 |
}
|
| 826 |
}
|
| 827 |
|
|
|
|
| 35 |
freeConfig(config.whisper, Module)
|
| 36 |
}
|
| 37 |
|
| 38 |
+
if ('moonshine' in config) {
|
| 39 |
+
freeConfig(config.moonshine, Module)
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
if ('tdnn' in config) {
|
| 43 |
freeConfig(config.tdnn, Module)
|
| 44 |
}
|
|
|
|
| 567 |
const n = encoderLen + decoderLen + languageLen + taskLen;
|
| 568 |
const buffer = Module._malloc(n);
|
| 569 |
|
| 570 |
+
const len = 5 * 4; // 4 pointers + 1 int32
|
| 571 |
const ptr = Module._malloc(len);
|
| 572 |
|
| 573 |
let offset = 0;
|
|
|
|
| 602 |
}
|
| 603 |
}
|
| 604 |
|
| 605 |
+
function initSherpaOnnxOfflineMoonshineModelConfig(config, Module) {
|
| 606 |
+
const preprocessorLen = Module.lengthBytesUTF8(config.preprocessor || '') + 1;
|
| 607 |
+
const encoderLen = Module.lengthBytesUTF8(config.encoder || '') + 1;
|
| 608 |
+
const uncachedDecoderLen =
|
| 609 |
+
Module.lengthBytesUTF8(config.uncachedDecoder || '') + 1;
|
| 610 |
+
const cachedDecoderLen =
|
| 611 |
+
Module.lengthBytesUTF8(config.cachedDecoder || '') + 1;
|
| 612 |
+
|
| 613 |
+
const n =
|
| 614 |
+
preprocessorLen + encoderLen + uncachedDecoderLen + cachedDecoderLen;
|
| 615 |
+
const buffer = Module._malloc(n);
|
| 616 |
+
|
| 617 |
+
const len = 4 * 4; // 4 pointers
|
| 618 |
+
const ptr = Module._malloc(len);
|
| 619 |
+
|
| 620 |
+
let offset = 0;
|
| 621 |
+
Module.stringToUTF8(
|
| 622 |
+
config.preprocessor || '', buffer + offset, preprocessorLen);
|
| 623 |
+
offset += preprocessorLen;
|
| 624 |
+
|
| 625 |
+
Module.stringToUTF8(config.encoder || '', buffer + offset, encoderLen);
|
| 626 |
+
offset += encoderLen;
|
| 627 |
+
|
| 628 |
+
Module.stringToUTF8(
|
| 629 |
+
config.uncachedDecoder || '', buffer + offset, uncachedDecoderLen);
|
| 630 |
+
offset += uncachedDecoderLen;
|
| 631 |
+
|
| 632 |
+
Module.stringToUTF8(
|
| 633 |
+
config.cachedDecoder || '', buffer + offset, cachedDecoderLen);
|
| 634 |
+
offset += cachedDecoderLen;
|
| 635 |
+
|
| 636 |
+
offset = 0;
|
| 637 |
+
Module.setValue(ptr, buffer + offset, 'i8*');
|
| 638 |
+
offset += preprocessorLen;
|
| 639 |
+
|
| 640 |
+
Module.setValue(ptr + 4, buffer + offset, 'i8*');
|
| 641 |
+
offset += encoderLen;
|
| 642 |
+
|
| 643 |
+
Module.setValue(ptr + 8, buffer + offset, 'i8*');
|
| 644 |
+
offset += uncachedDecoderLen;
|
| 645 |
+
|
| 646 |
+
Module.setValue(ptr + 12, buffer + offset, 'i8*');
|
| 647 |
+
offset += cachedDecoderLen;
|
| 648 |
+
|
| 649 |
+
return {
|
| 650 |
+
buffer: buffer, ptr: ptr, len: len,
|
| 651 |
+
}
|
| 652 |
+
}
|
| 653 |
+
|
| 654 |
function initSherpaOnnxOfflineTdnnModelConfig(config, Module) {
|
| 655 |
const n = Module.lengthBytesUTF8(config.model || '') + 1;
|
| 656 |
const buffer = Module._malloc(n);
|
|
|
|
| 746 |
};
|
| 747 |
}
|
| 748 |
|
| 749 |
+
if (!('moonshine' in config)) {
|
| 750 |
+
config.moonshine = {
|
| 751 |
+
preprocessor: '',
|
| 752 |
+
encoder: '',
|
| 753 |
+
uncachedDecoder: '',
|
| 754 |
+
cachedDecoder: '',
|
| 755 |
+
};
|
| 756 |
+
}
|
| 757 |
+
|
| 758 |
if (!('tdnn' in config)) {
|
| 759 |
config.tdnn = {
|
| 760 |
model: '',
|
|
|
|
| 786 |
const senseVoice =
|
| 787 |
initSherpaOnnxOfflineSenseVoiceModelConfig(config.senseVoice, Module);
|
| 788 |
|
| 789 |
+
const moonshine =
|
| 790 |
+
initSherpaOnnxOfflineMoonshineModelConfig(config.moonshine, Module);
|
| 791 |
+
|
| 792 |
const len = transducer.len + paraformer.len + nemoCtc.len + whisper.len +
|
| 793 |
+
tdnn.len + 8 * 4 + senseVoice.len + moonshine.len;
|
| 794 |
|
| 795 |
const ptr = Module._malloc(len);
|
| 796 |
|
|
|
|
| 810 |
Module._CopyHeap(tdnn.ptr, tdnn.len, ptr + offset);
|
| 811 |
offset += tdnn.len;
|
| 812 |
|
|
|
|
| 813 |
const tokensLen = Module.lengthBytesUTF8(config.tokens || '') + 1;
|
| 814 |
const providerLen = Module.lengthBytesUTF8(config.provider || 'cpu') + 1;
|
| 815 |
const modelTypeLen = Module.lengthBytesUTF8(config.modelType || '') + 1;
|
|
|
|
| 881 |
offset += 4;
|
| 882 |
|
| 883 |
Module._CopyHeap(senseVoice.ptr, senseVoice.len, ptr + offset);
|
| 884 |
+
offset += senseVoice.len;
|
| 885 |
+
|
| 886 |
+
Module._CopyHeap(moonshine.ptr, moonshine.len, ptr + offset);
|
| 887 |
|
| 888 |
return {
|
| 889 |
buffer: buffer, ptr: ptr, len: len, transducer: transducer,
|
| 890 |
paraformer: paraformer, nemoCtc: nemoCtc, whisper: whisper, tdnn: tdnn,
|
| 891 |
+
senseVoice: senseVoice, moonshine: moonshine,
|
| 892 |
}
|
| 893 |
}
|
| 894 |
|
sherpa-onnx-wasm-main-vad-asr.js
CHANGED
|
The diff for this file is too large to render.
See raw diff
|
|
|
sherpa-onnx-wasm-main-vad-asr.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:e0bdfd246590dbb70e21d7f8a3214018a7861ea84651cef8b2e97208e956c3f3
|
| 3 |
+
size 11426570
|