Spaces:
Configuration error
Configuration error
Commit
·
0549674
1
Parent(s):
5c28bd9
update model
Browse files- sherpa-onnx-asr.js +35 -2
sherpa-onnx-asr.js
CHANGED
|
@@ -43,6 +43,10 @@ function freeConfig(config, Module) {
|
|
| 43 |
freeConfig(config.dolphin, Module)
|
| 44 |
}
|
| 45 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
if ('moonshine' in config) {
|
| 47 |
freeConfig(config.moonshine, Module)
|
| 48 |
}
|
|
@@ -627,6 +631,23 @@ function initSherpaOnnxOfflineDolphinModelConfig(config, Module) {
|
|
| 627 |
}
|
| 628 |
}
|
| 629 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 630 |
function initSherpaOnnxOfflineWhisperModelConfig(config, Module) {
|
| 631 |
const encoderLen = Module.lengthBytesUTF8(config.encoder || '') + 1;
|
| 632 |
const decoderLen = Module.lengthBytesUTF8(config.decoder || '') + 1;
|
|
@@ -840,6 +861,12 @@ function initSherpaOnnxOfflineModelConfig(config, Module) {
|
|
| 840 |
};
|
| 841 |
}
|
| 842 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 843 |
if (!('whisper' in config)) {
|
| 844 |
config.whisper = {
|
| 845 |
encoder: '',
|
|
@@ -906,9 +933,12 @@ function initSherpaOnnxOfflineModelConfig(config, Module) {
|
|
| 906 |
const dolphin =
|
| 907 |
initSherpaOnnxOfflineDolphinModelConfig(config.dolphin, Module);
|
| 908 |
|
|
|
|
|
|
|
|
|
|
| 909 |
const len = transducer.len + paraformer.len + nemoCtc.len + whisper.len +
|
| 910 |
tdnn.len + 8 * 4 + senseVoice.len + moonshine.len + fireRedAsr.len +
|
| 911 |
-
dolphin.len;
|
| 912 |
|
| 913 |
const ptr = Module._malloc(len);
|
| 914 |
|
|
@@ -1010,11 +1040,14 @@ function initSherpaOnnxOfflineModelConfig(config, Module) {
|
|
| 1010 |
Module._CopyHeap(dolphin.ptr, dolphin.len, ptr + offset);
|
| 1011 |
offset += dolphin.len;
|
| 1012 |
|
|
|
|
|
|
|
|
|
|
| 1013 |
return {
|
| 1014 |
buffer: buffer, ptr: ptr, len: len, transducer: transducer,
|
| 1015 |
paraformer: paraformer, nemoCtc: nemoCtc, whisper: whisper, tdnn: tdnn,
|
| 1016 |
senseVoice: senseVoice, moonshine: moonshine, fireRedAsr: fireRedAsr,
|
| 1017 |
-
dolphin: dolphin
|
| 1018 |
}
|
| 1019 |
}
|
| 1020 |
|
|
|
|
| 43 |
freeConfig(config.dolphin, Module)
|
| 44 |
}
|
| 45 |
|
| 46 |
+
if ('zipformerCtc' in config) {
|
| 47 |
+
freeConfig(config.zipformerCtc, Module)
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
if ('moonshine' in config) {
|
| 51 |
freeConfig(config.moonshine, Module)
|
| 52 |
}
|
|
|
|
| 631 |
}
|
| 632 |
}
|
| 633 |
|
| 634 |
+
function initSherpaOnnxOfflineZipformerCtcModelConfig(config, Module) {
|
| 635 |
+
const n = Module.lengthBytesUTF8(config.model || '') + 1;
|
| 636 |
+
|
| 637 |
+
const buffer = Module._malloc(n);
|
| 638 |
+
|
| 639 |
+
const len = 1 * 4; // 1 pointer
|
| 640 |
+
const ptr = Module._malloc(len);
|
| 641 |
+
|
| 642 |
+
Module.stringToUTF8(config.model || '', buffer, n);
|
| 643 |
+
|
| 644 |
+
Module.setValue(ptr, buffer, 'i8*');
|
| 645 |
+
|
| 646 |
+
return {
|
| 647 |
+
buffer: buffer, ptr: ptr, len: len,
|
| 648 |
+
}
|
| 649 |
+
}
|
| 650 |
+
|
| 651 |
function initSherpaOnnxOfflineWhisperModelConfig(config, Module) {
|
| 652 |
const encoderLen = Module.lengthBytesUTF8(config.encoder || '') + 1;
|
| 653 |
const decoderLen = Module.lengthBytesUTF8(config.decoder || '') + 1;
|
|
|
|
| 861 |
};
|
| 862 |
}
|
| 863 |
|
| 864 |
+
if (!('zipformerCtc' in config)) {
|
| 865 |
+
config.zipformerCtc = {
|
| 866 |
+
model: '',
|
| 867 |
+
};
|
| 868 |
+
}
|
| 869 |
+
|
| 870 |
if (!('whisper' in config)) {
|
| 871 |
config.whisper = {
|
| 872 |
encoder: '',
|
|
|
|
| 933 |
const dolphin =
|
| 934 |
initSherpaOnnxOfflineDolphinModelConfig(config.dolphin, Module);
|
| 935 |
|
| 936 |
+
const zipformerCtc =
|
| 937 |
+
initSherpaOnnxOfflineZipformerCtcModelConfig(config.zipformerCtc, Module);
|
| 938 |
+
|
| 939 |
const len = transducer.len + paraformer.len + nemoCtc.len + whisper.len +
|
| 940 |
tdnn.len + 8 * 4 + senseVoice.len + moonshine.len + fireRedAsr.len +
|
| 941 |
+
dolphin.len + zipformerCtc.len;
|
| 942 |
|
| 943 |
const ptr = Module._malloc(len);
|
| 944 |
|
|
|
|
| 1040 |
Module._CopyHeap(dolphin.ptr, dolphin.len, ptr + offset);
|
| 1041 |
offset += dolphin.len;
|
| 1042 |
|
| 1043 |
+
Module._CopyHeap(zipformerCtc.ptr, zipformerCtc.len, ptr + offset);
|
| 1044 |
+
offset += zipformerCtc.len;
|
| 1045 |
+
|
| 1046 |
return {
|
| 1047 |
buffer: buffer, ptr: ptr, len: len, transducer: transducer,
|
| 1048 |
paraformer: paraformer, nemoCtc: nemoCtc, whisper: whisper, tdnn: tdnn,
|
| 1049 |
senseVoice: senseVoice, moonshine: moonshine, fireRedAsr: fireRedAsr,
|
| 1050 |
+
dolphin: dolphin, zipformerCtc: zipformerCtc
|
| 1051 |
}
|
| 1052 |
}
|
| 1053 |
|