csukuangfj commited on
Commit
0b08f51
·
1 Parent(s): d46547f

update model

Browse files
app-vad-asr.js CHANGED
@@ -117,6 +117,10 @@ function initOfflineRecognizer() {
117
  };
118
  } else if (fileExists('dolphin.onnx')) {
119
  config.modelConfig.dolphin = {model: './dolphin.onnx'};
 
 
 
 
120
  } else {
121
  console.log('Please specify a model.');
122
  alert('Please specify a model.');
 
117
  };
118
  } else if (fileExists('dolphin.onnx')) {
119
  config.modelConfig.dolphin = {model: './dolphin.onnx'};
120
+ } else if (fileExists('zipformer-ctc.onnx')) {
121
+ // you need to rename model.int8.onnx from zipformer CTC to
122
+ // zipformer-ctc.onnx
123
+ config.modelConfig.zipformerCtc = {model: './zipformer-ctc.onnx'};
124
  } else {
125
  console.log('Please specify a model.');
126
  alert('Please specify a model.');
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
 
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:38077a45ce05762933ccd128f452787c65d1dc3d8931d7bfdacb1e4da42d10a5
3
- size 11517356
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f97b22403d4ae1a2bee52b48eeac54a2a0c65325cb3df1ccdb4b5e67b54db9c5
3
+ size 11514834