Add C++ runtime for Tele-AI/TeleSpeech-ASR (#970)
This commit is contained in:
@@ -529,7 +529,7 @@ function initSherpaOnnxOfflineModelConfig(config, Module) {
|
||||
const tdnn = initSherpaOnnxOfflineTdnnModelConfig(config.tdnn, Module);
|
||||
|
||||
const len = transducer.len + paraformer.len + nemoCtc.len + whisper.len +
|
||||
tdnn.len + 7 * 4;
|
||||
tdnn.len + 8 * 4;
|
||||
const ptr = Module._malloc(len);
|
||||
|
||||
let offset = 0;
|
||||
@@ -553,9 +553,11 @@ function initSherpaOnnxOfflineModelConfig(config, Module) {
|
||||
const modelTypeLen = Module.lengthBytesUTF8(config.modelType) + 1;
|
||||
const modelingUnitLen = Module.lengthBytesUTF8(config.modelingUnit || '') + 1;
|
||||
const bpeVocabLen = Module.lengthBytesUTF8(config.bpeVocab || '') + 1;
|
||||
const teleSpeechCtcLen =
|
||||
Module.lengthBytesUTF8(config.teleSpeechCtc || '') + 1;
|
||||
|
||||
const bufferLen =
|
||||
tokensLen + providerLen + modelTypeLen + modelingUnitLen + bpeVocabLen;
|
||||
const bufferLen = tokensLen + providerLen + modelTypeLen + modelingUnitLen +
|
||||
bpeVocabLen + teleSpeechCtcLen;
|
||||
const buffer = Module._malloc(bufferLen);
|
||||
|
||||
offset = 0;
|
||||
@@ -575,6 +577,10 @@ function initSherpaOnnxOfflineModelConfig(config, Module) {
|
||||
Module.stringToUTF8(config.bpeVocab || '', buffer + offset, bpeVocabLen);
|
||||
offset += bpeVocabLen;
|
||||
|
||||
Module.stringToUTF8(
|
||||
config.teleSpeechCtc || '', buffer + offset, teleSpeechCtcLen);
|
||||
offset += teleSpeechCtcLen;
|
||||
|
||||
offset =
|
||||
transducer.len + paraformer.len + nemoCtc.len + whisper.len + tdnn.len;
|
||||
Module.setValue(ptr + offset, buffer, 'i8*'); // tokens
|
||||
@@ -604,6 +610,13 @@ function initSherpaOnnxOfflineModelConfig(config, Module) {
|
||||
'i8*'); // bpeVocab
|
||||
offset += 4;
|
||||
|
||||
Module.setValue(
|
||||
ptr + offset,
|
||||
buffer + tokensLen + providerLen + modelTypeLen + modelingUnitLen +
|
||||
bpeVocabLen,
|
||||
'i8*'); // teleSpeechCtc
|
||||
offset += 4;
|
||||
|
||||
return {
|
||||
buffer: buffer, ptr: ptr, len: len, transducer: transducer,
|
||||
paraformer: paraformer, nemoCtc: nemoCtc, whisper: whisper, tdnn: tdnn
|
||||
|
||||
@@ -23,7 +23,7 @@ static_assert(sizeof(SherpaOnnxOfflineModelConfig) ==
|
||||
sizeof(SherpaOnnxOfflineParaformerModelConfig) +
|
||||
sizeof(SherpaOnnxOfflineNemoEncDecCtcModelConfig) +
|
||||
sizeof(SherpaOnnxOfflineWhisperModelConfig) +
|
||||
sizeof(SherpaOnnxOfflineTdnnModelConfig) + 7 * 4,
|
||||
sizeof(SherpaOnnxOfflineTdnnModelConfig) + 8 * 4,
|
||||
"");
|
||||
static_assert(sizeof(SherpaOnnxFeatureConfig) == 2 * 4, "");
|
||||
static_assert(sizeof(SherpaOnnxOfflineRecognizerConfig) ==
|
||||
@@ -92,6 +92,7 @@ void PrintOfflineRecognizerConfig(SherpaOnnxOfflineRecognizerConfig *config) {
|
||||
fprintf(stdout, "model type: %s\n", model_config->model_type);
|
||||
fprintf(stdout, "modeling unit: %s\n", model_config->modeling_unit);
|
||||
fprintf(stdout, "bpe vocab: %s\n", model_config->bpe_vocab);
|
||||
fprintf(stdout, "telespeech_ctc: %s\n", model_config->telespeech_ctc);
|
||||
|
||||
fprintf(stdout, "----------feat config----------\n");
|
||||
fprintf(stdout, "sample rate: %d\n", feat->sample_rate);
|
||||
|
||||
Reference in New Issue
Block a user