正在显示
9 个修改的文件
包含
123 行增加
和
10 行删除
| @@ -23,6 +23,8 @@ namespace SherpaOnnx | @@ -23,6 +23,8 @@ namespace SherpaOnnx | ||
| 23 | Debug = 0; | 23 | Debug = 0; |
| 24 | Provider = "cpu"; | 24 | Provider = "cpu"; |
| 25 | ModelType = ""; | 25 | ModelType = ""; |
| 26 | + ModelingUnit = "cjkchar"; | ||
| 27 | + BpeVocab = ""; | ||
| 26 | } | 28 | } |
| 27 | public OfflineTransducerModelConfig Transducer; | 29 | public OfflineTransducerModelConfig Transducer; |
| 28 | public OfflineParaformerModelConfig Paraformer; | 30 | public OfflineParaformerModelConfig Paraformer; |
| @@ -42,5 +44,11 @@ namespace SherpaOnnx | @@ -42,5 +44,11 @@ namespace SherpaOnnx | ||
| 42 | 44 | ||
| 43 | [MarshalAs(UnmanagedType.LPStr)] | 45 | [MarshalAs(UnmanagedType.LPStr)] |
| 44 | public string ModelType; | 46 | public string ModelType; |
| 47 | + | ||
| 48 | + [MarshalAs(UnmanagedType.LPStr)] | ||
| 49 | + public string ModelingUnit; | ||
| 50 | + | ||
| 51 | + [MarshalAs(UnmanagedType.LPStr)] | ||
| 52 | + public string BpeVocab; | ||
| 45 | } | 53 | } |
| 46 | } | 54 | } |
| @@ -23,6 +23,8 @@ namespace SherpaOnnx | @@ -23,6 +23,8 @@ namespace SherpaOnnx | ||
| 23 | Provider = "cpu"; | 23 | Provider = "cpu"; |
| 24 | Debug = 0; | 24 | Debug = 0; |
| 25 | ModelType = ""; | 25 | ModelType = ""; |
| 26 | + ModelingUnit = "cjkchar"; | ||
| 27 | + BpeVocab = ""; | ||
| 26 | } | 28 | } |
| 27 | 29 | ||
| 28 | public OnlineTransducerModelConfig Transducer; | 30 | public OnlineTransducerModelConfig Transducer; |
| @@ -43,5 +45,11 @@ namespace SherpaOnnx | @@ -43,5 +45,11 @@ namespace SherpaOnnx | ||
| 43 | 45 | ||
| 44 | [MarshalAs(UnmanagedType.LPStr)] | 46 | [MarshalAs(UnmanagedType.LPStr)] |
| 45 | public string ModelType; | 47 | public string ModelType; |
| 48 | + | ||
| 49 | + [MarshalAs(UnmanagedType.LPStr)] | ||
| 50 | + public string ModelingUnit; | ||
| 51 | + | ||
| 52 | + [MarshalAs(UnmanagedType.LPStr)] | ||
| 53 | + public string BpeVocab; | ||
| 46 | } | 54 | } |
| 47 | } | 55 | } |
| @@ -87,6 +87,8 @@ type OnlineModelConfig struct { | @@ -87,6 +87,8 @@ type OnlineModelConfig struct { | ||
| 87 | Provider string // Optional. Valid values are: cpu, cuda, coreml | 87 | Provider string // Optional. Valid values are: cpu, cuda, coreml |
| 88 | Debug int // 1 to show model meta information while loading it. | 88 | Debug int // 1 to show model meta information while loading it. |
| 89 | ModelType string // Optional. You can specify it for faster model initialization | 89 | ModelType string // Optional. You can specify it for faster model initialization |
| 90 | + ModelingUnit string // Optional. cjkchar, bpe, cjkchar+bpe | ||
| 91 | + BpeVocab string // Optional. | ||
| 90 | } | 92 | } |
| 91 | 93 | ||
| 92 | // Configuration for the feature extractor | 94 | // Configuration for the feature extractor |
| @@ -187,6 +189,12 @@ func NewOnlineRecognizer(config *OnlineRecognizerConfig) *OnlineRecognizer { | @@ -187,6 +189,12 @@ func NewOnlineRecognizer(config *OnlineRecognizerConfig) *OnlineRecognizer { | ||
| 187 | c.model_config.model_type = C.CString(config.ModelConfig.ModelType) | 189 | c.model_config.model_type = C.CString(config.ModelConfig.ModelType) |
| 188 | defer C.free(unsafe.Pointer(c.model_config.model_type)) | 190 | defer C.free(unsafe.Pointer(c.model_config.model_type)) |
| 189 | 191 | ||
| 192 | + c.model_config.modeling_unit = C.CString(config.ModelConfig.ModelingUnit) | ||
| 193 | + defer C.free(unsafe.Pointer(c.model_config.modeling_unit)) | ||
| 194 | + | ||
| 195 | + c.model_config.bpe_vocab = C.CString(config.ModelConfig.BpeVocab) | ||
| 196 | + defer C.free(unsafe.Pointer(c.model_config.bpe_vocab)) | ||
| 197 | + | ||
| 190 | c.decoding_method = C.CString(config.DecodingMethod) | 198 | c.decoding_method = C.CString(config.DecodingMethod) |
| 191 | defer C.free(unsafe.Pointer(c.decoding_method)) | 199 | defer C.free(unsafe.Pointer(c.decoding_method)) |
| 192 | 200 | ||
| @@ -372,6 +380,9 @@ type OfflineModelConfig struct { | @@ -372,6 +380,9 @@ type OfflineModelConfig struct { | ||
| 372 | 380 | ||
| 373 | // Optional. Specify it for faster model initialization. | 381 | // Optional. Specify it for faster model initialization. |
| 374 | ModelType string | 382 | ModelType string |
| 383 | + | ||
| 384 | + ModelingUnit string // Optional. cjkchar, bpe, cjkchar+bpe | ||
| 385 | + BpeVocab string // Optional. | ||
| 375 | } | 386 | } |
| 376 | 387 | ||
| 377 | // Configuration for the offline/non-streaming recognizer. | 388 | // Configuration for the offline/non-streaming recognizer. |
| @@ -460,6 +471,12 @@ func NewOfflineRecognizer(config *OfflineRecognizerConfig) *OfflineRecognizer { | @@ -460,6 +471,12 @@ func NewOfflineRecognizer(config *OfflineRecognizerConfig) *OfflineRecognizer { | ||
| 460 | c.model_config.model_type = C.CString(config.ModelConfig.ModelType) | 471 | c.model_config.model_type = C.CString(config.ModelConfig.ModelType) |
| 461 | defer C.free(unsafe.Pointer(c.model_config.model_type)) | 472 | defer C.free(unsafe.Pointer(c.model_config.model_type)) |
| 462 | 473 | ||
| 474 | + c.model_config.modeling_unit = C.CString(config.ModelConfig.ModelingUnit) | ||
| 475 | + defer C.free(unsafe.Pointer(c.model_config.modeling_unit)) | ||
| 476 | + | ||
| 477 | + c.model_config.bpe_vocab = C.CString(config.ModelConfig.BpeVocab) | ||
| 478 | + defer C.free(unsafe.Pointer(c.model_config.bpe_vocab)) | ||
| 479 | + | ||
| 463 | c.lm_config.model = C.CString(config.LmConfig.Model) | 480 | c.lm_config.model = C.CString(config.LmConfig.Model) |
| 464 | defer C.free(unsafe.Pointer(c.lm_config.model)) | 481 | defer C.free(unsafe.Pointer(c.lm_config.model)) |
| 465 | 482 |
| @@ -126,6 +126,8 @@ static SherpaOnnxOfflineModelConfig GetOfflineModelConfig(Napi::Object obj) { | @@ -126,6 +126,8 @@ static SherpaOnnxOfflineModelConfig GetOfflineModelConfig(Napi::Object obj) { | ||
| 126 | 126 | ||
| 127 | SHERPA_ONNX_ASSIGN_ATTR_STR(provider, provider); | 127 | SHERPA_ONNX_ASSIGN_ATTR_STR(provider, provider); |
| 128 | SHERPA_ONNX_ASSIGN_ATTR_STR(model_type, modelType); | 128 | SHERPA_ONNX_ASSIGN_ATTR_STR(model_type, modelType); |
| 129 | + SHERPA_ONNX_ASSIGN_ATTR_STR(modeling_unit, modelingUnit); | ||
| 130 | + SHERPA_ONNX_ASSIGN_ATTR_STR(bpe_vocab, bpeVocab); | ||
| 129 | 131 | ||
| 130 | return c; | 132 | return c; |
| 131 | } | 133 | } |
| @@ -232,6 +234,14 @@ CreateOfflineRecognizerWrapper(const Napi::CallbackInfo &info) { | @@ -232,6 +234,14 @@ CreateOfflineRecognizerWrapper(const Napi::CallbackInfo &info) { | ||
| 232 | delete[] c.model_config.model_type; | 234 | delete[] c.model_config.model_type; |
| 233 | } | 235 | } |
| 234 | 236 | ||
| 237 | + if (c.model_config.modeling_unit) { | ||
| 238 | + delete[] c.model_config.modeling_unit; | ||
| 239 | + } | ||
| 240 | + | ||
| 241 | + if (c.model_config.bpe_vocab) { | ||
| 242 | + delete[] c.model_config.bpe_vocab; | ||
| 243 | + } | ||
| 244 | + | ||
| 235 | if (c.lm_config.model) { | 245 | if (c.lm_config.model) { |
| 236 | delete[] c.lm_config.model; | 246 | delete[] c.lm_config.model; |
| 237 | } | 247 | } |
| @@ -118,6 +118,8 @@ SherpaOnnxOnlineModelConfig GetOnlineModelConfig(Napi::Object obj) { | @@ -118,6 +118,8 @@ SherpaOnnxOnlineModelConfig GetOnlineModelConfig(Napi::Object obj) { | ||
| 118 | } | 118 | } |
| 119 | 119 | ||
| 120 | SHERPA_ONNX_ASSIGN_ATTR_STR(model_type, modelType); | 120 | SHERPA_ONNX_ASSIGN_ATTR_STR(model_type, modelType); |
| 121 | + SHERPA_ONNX_ASSIGN_ATTR_STR(modeling_unit, modelingUnit); | ||
| 122 | + SHERPA_ONNX_ASSIGN_ATTR_STR(bpe_vocab, bpeVocab); | ||
| 121 | 123 | ||
| 122 | return c; | 124 | return c; |
| 123 | } | 125 | } |
| @@ -228,6 +230,14 @@ static Napi::External<SherpaOnnxOnlineRecognizer> CreateOnlineRecognizerWrapper( | @@ -228,6 +230,14 @@ static Napi::External<SherpaOnnxOnlineRecognizer> CreateOnlineRecognizerWrapper( | ||
| 228 | delete[] c.model_config.model_type; | 230 | delete[] c.model_config.model_type; |
| 229 | } | 231 | } |
| 230 | 232 | ||
| 233 | + if (c.model_config.modeling_unit) { | ||
| 234 | + delete[] c.model_config.modeling_unit; | ||
| 235 | + } | ||
| 236 | + | ||
| 237 | + if (c.model_config.bpe_vocab) { | ||
| 238 | + delete[] c.model_config.bpe_vocab; | ||
| 239 | + } | ||
| 240 | + | ||
| 231 | if (c.decoding_method) { | 241 | if (c.decoding_method) { |
| 232 | delete[] c.decoding_method; | 242 | delete[] c.decoding_method; |
| 233 | } | 243 | } |
| @@ -88,7 +88,9 @@ func sherpaOnnxOnlineModelConfig( | @@ -88,7 +88,9 @@ func sherpaOnnxOnlineModelConfig( | ||
| 88 | numThreads: Int = 1, | 88 | numThreads: Int = 1, |
| 89 | provider: String = "cpu", | 89 | provider: String = "cpu", |
| 90 | debug: Int = 0, | 90 | debug: Int = 0, |
| 91 | - modelType: String = "" | 91 | + modelType: String = "", |
| 92 | + modelingUnit: String = "cjkchar", | ||
| 93 | + bpeVocab: String = "" | ||
| 92 | ) -> SherpaOnnxOnlineModelConfig { | 94 | ) -> SherpaOnnxOnlineModelConfig { |
| 93 | return SherpaOnnxOnlineModelConfig( | 95 | return SherpaOnnxOnlineModelConfig( |
| 94 | transducer: transducer, | 96 | transducer: transducer, |
| @@ -98,7 +100,9 @@ func sherpaOnnxOnlineModelConfig( | @@ -98,7 +100,9 @@ func sherpaOnnxOnlineModelConfig( | ||
| 98 | num_threads: Int32(numThreads), | 100 | num_threads: Int32(numThreads), |
| 99 | provider: toCPointer(provider), | 101 | provider: toCPointer(provider), |
| 100 | debug: Int32(debug), | 102 | debug: Int32(debug), |
| 101 | - model_type: toCPointer(modelType) | 103 | + model_type: toCPointer(modelType), |
| 104 | + modeling_unit: toCPointer(modelingUnit), | ||
| 105 | + bpeVocab: toCPointer(bpeVocab) | ||
| 102 | ) | 106 | ) |
| 103 | } | 107 | } |
| 104 | 108 | ||
| @@ -354,7 +358,9 @@ func sherpaOnnxOfflineModelConfig( | @@ -354,7 +358,9 @@ func sherpaOnnxOfflineModelConfig( | ||
| 354 | numThreads: Int = 1, | 358 | numThreads: Int = 1, |
| 355 | provider: String = "cpu", | 359 | provider: String = "cpu", |
| 356 | debug: Int = 0, | 360 | debug: Int = 0, |
| 357 | - modelType: String = "" | 361 | + modelType: String = "", |
| 362 | + modelingUnit: String = "cjkchar", | ||
| 363 | + bpeVocab: String = "" | ||
| 358 | ) -> SherpaOnnxOfflineModelConfig { | 364 | ) -> SherpaOnnxOfflineModelConfig { |
| 359 | return SherpaOnnxOfflineModelConfig( | 365 | return SherpaOnnxOfflineModelConfig( |
| 360 | transducer: transducer, | 366 | transducer: transducer, |
| @@ -366,7 +372,9 @@ func sherpaOnnxOfflineModelConfig( | @@ -366,7 +372,9 @@ func sherpaOnnxOfflineModelConfig( | ||
| 366 | num_threads: Int32(numThreads), | 372 | num_threads: Int32(numThreads), |
| 367 | debug: Int32(debug), | 373 | debug: Int32(debug), |
| 368 | provider: toCPointer(provider), | 374 | provider: toCPointer(provider), |
| 369 | - model_type: toCPointer(modelType) | 375 | + model_type: toCPointer(modelType), |
| 376 | + modeling_unit: toCPointer(modelingUnit), | ||
| 377 | + bpeVocab: toCPointer(bpeVocab) | ||
| 370 | ) | 378 | ) |
| 371 | } | 379 | } |
| 372 | 380 |
| @@ -137,7 +137,7 @@ function initSherpaOnnxOnlineModelConfig(config, Module) { | @@ -137,7 +137,7 @@ function initSherpaOnnxOnlineModelConfig(config, Module) { | ||
| 137 | const ctc = initSherpaOnnxOnlineZipformer2CtcModelConfig( | 137 | const ctc = initSherpaOnnxOnlineZipformer2CtcModelConfig( |
| 138 | config.zipformer2Ctc, Module); | 138 | config.zipformer2Ctc, Module); |
| 139 | 139 | ||
| 140 | - const len = transducer.len + paraformer.len + ctc.len + 5 * 4; | 140 | + const len = transducer.len + paraformer.len + ctc.len + 7 * 4; |
| 141 | const ptr = Module._malloc(len); | 141 | const ptr = Module._malloc(len); |
| 142 | 142 | ||
| 143 | let offset = 0; | 143 | let offset = 0; |
| @@ -153,7 +153,11 @@ function initSherpaOnnxOnlineModelConfig(config, Module) { | @@ -153,7 +153,11 @@ function initSherpaOnnxOnlineModelConfig(config, Module) { | ||
| 153 | const tokensLen = Module.lengthBytesUTF8(config.tokens) + 1; | 153 | const tokensLen = Module.lengthBytesUTF8(config.tokens) + 1; |
| 154 | const providerLen = Module.lengthBytesUTF8(config.provider) + 1; | 154 | const providerLen = Module.lengthBytesUTF8(config.provider) + 1; |
| 155 | const modelTypeLen = Module.lengthBytesUTF8(config.modelType) + 1; | 155 | const modelTypeLen = Module.lengthBytesUTF8(config.modelType) + 1; |
| 156 | - const bufferLen = tokensLen + providerLen + modelTypeLen; | 156 | + const modelingUnitLen = Module.lengthBytesUTF8(config.modelingUnit || '') + 1; |
| 157 | + const bpeVocabLen = Module.lengthBytesUTF8(config.bpeVocab || '') + 1; | ||
| 158 | + | ||
| 159 | + const bufferLen = | ||
| 160 | + tokensLen + providerLen + modelTypeLen + modelingUnitLen + bpeVocabLen; | ||
| 157 | const buffer = Module._malloc(bufferLen); | 161 | const buffer = Module._malloc(bufferLen); |
| 158 | 162 | ||
| 159 | offset = 0; | 163 | offset = 0; |
| @@ -164,6 +168,14 @@ function initSherpaOnnxOnlineModelConfig(config, Module) { | @@ -164,6 +168,14 @@ function initSherpaOnnxOnlineModelConfig(config, Module) { | ||
| 164 | offset += providerLen; | 168 | offset += providerLen; |
| 165 | 169 | ||
| 166 | Module.stringToUTF8(config.modelType, buffer + offset, modelTypeLen); | 170 | Module.stringToUTF8(config.modelType, buffer + offset, modelTypeLen); |
| 171 | + offset += modelTypeLen; | ||
| 172 | + | ||
| 173 | + Module.stringToUTF8( | ||
| 174 | + config.modelingUnit || '', buffer + offset, modelingUnitLen); | ||
| 175 | + offset += modelingUnitLen; | ||
| 176 | + | ||
| 177 | + Module.stringToUTF8(config.bpeVocab || '', buffer + offset, bpeVocabLen); | ||
| 178 | + offset += bpeVocabLen; | ||
| 167 | 179 | ||
| 168 | offset = transducer.len + paraformer.len + ctc.len; | 180 | offset = transducer.len + paraformer.len + ctc.len; |
| 169 | Module.setValue(ptr + offset, buffer, 'i8*'); // tokens | 181 | Module.setValue(ptr + offset, buffer, 'i8*'); // tokens |
| @@ -182,6 +194,17 @@ function initSherpaOnnxOnlineModelConfig(config, Module) { | @@ -182,6 +194,17 @@ function initSherpaOnnxOnlineModelConfig(config, Module) { | ||
| 182 | ptr + offset, buffer + tokensLen + providerLen, 'i8*'); // modelType | 194 | ptr + offset, buffer + tokensLen + providerLen, 'i8*'); // modelType |
| 183 | offset += 4; | 195 | offset += 4; |
| 184 | 196 | ||
| 197 | + Module.setValue( | ||
| 198 | + ptr + offset, buffer + tokensLen + providerLen + modelTypeLen, | ||
| 199 | + 'i8*'); // modelingUnit | ||
| 200 | + offset += 4; | ||
| 201 | + | ||
| 202 | + Module.setValue( | ||
| 203 | + ptr + offset, | ||
| 204 | + buffer + tokensLen + providerLen + modelTypeLen + modelingUnitLen, | ||
| 205 | + 'i8*'); // bpeVocab | ||
| 206 | + offset += 4; | ||
| 207 | + | ||
| 185 | return { | 208 | return { |
| 186 | buffer: buffer, ptr: ptr, len: len, transducer: transducer, | 209 | buffer: buffer, ptr: ptr, len: len, transducer: transducer, |
| 187 | paraformer: paraformer, ctc: ctc | 210 | paraformer: paraformer, ctc: ctc |
| @@ -317,6 +340,8 @@ function createOnlineRecognizer(Module, myConfig) { | @@ -317,6 +340,8 @@ function createOnlineRecognizer(Module, myConfig) { | ||
| 317 | provider: 'cpu', | 340 | provider: 'cpu', |
| 318 | debug: 1, | 341 | debug: 1, |
| 319 | modelType: '', | 342 | modelType: '', |
| 343 | + modelingUnit: 'cjkchar', | ||
| 344 | + bpeVocab: '', | ||
| 320 | }; | 345 | }; |
| 321 | 346 | ||
| 322 | const featureConfig = { | 347 | const featureConfig = { |
| @@ -504,7 +529,7 @@ function initSherpaOnnxOfflineModelConfig(config, Module) { | @@ -504,7 +529,7 @@ function initSherpaOnnxOfflineModelConfig(config, Module) { | ||
| 504 | const tdnn = initSherpaOnnxOfflineTdnnModelConfig(config.tdnn, Module); | 529 | const tdnn = initSherpaOnnxOfflineTdnnModelConfig(config.tdnn, Module); |
| 505 | 530 | ||
| 506 | const len = transducer.len + paraformer.len + nemoCtc.len + whisper.len + | 531 | const len = transducer.len + paraformer.len + nemoCtc.len + whisper.len + |
| 507 | - tdnn.len + 5 * 4; | 532 | + tdnn.len + 7 * 4; |
| 508 | const ptr = Module._malloc(len); | 533 | const ptr = Module._malloc(len); |
| 509 | 534 | ||
| 510 | let offset = 0; | 535 | let offset = 0; |
| @@ -526,7 +551,11 @@ function initSherpaOnnxOfflineModelConfig(config, Module) { | @@ -526,7 +551,11 @@ function initSherpaOnnxOfflineModelConfig(config, Module) { | ||
| 526 | const tokensLen = Module.lengthBytesUTF8(config.tokens) + 1; | 551 | const tokensLen = Module.lengthBytesUTF8(config.tokens) + 1; |
| 527 | const providerLen = Module.lengthBytesUTF8(config.provider) + 1; | 552 | const providerLen = Module.lengthBytesUTF8(config.provider) + 1; |
| 528 | const modelTypeLen = Module.lengthBytesUTF8(config.modelType) + 1; | 553 | const modelTypeLen = Module.lengthBytesUTF8(config.modelType) + 1; |
| 529 | - const bufferLen = tokensLen + providerLen + modelTypeLen; | 554 | + const modelingUnitLen = Module.lengthBytesUTF8(config.modelingUnit || '') + 1; |
| 555 | + const bpeVocabLen = Module.lengthBytesUTF8(config.bpeVocab || '') + 1; | ||
| 556 | + | ||
| 557 | + const bufferLen = | ||
| 558 | + tokensLen + providerLen + modelTypeLen + modelingUnitLen + bpeVocabLen; | ||
| 530 | const buffer = Module._malloc(bufferLen); | 559 | const buffer = Module._malloc(bufferLen); |
| 531 | 560 | ||
| 532 | offset = 0; | 561 | offset = 0; |
| @@ -537,6 +566,14 @@ function initSherpaOnnxOfflineModelConfig(config, Module) { | @@ -537,6 +566,14 @@ function initSherpaOnnxOfflineModelConfig(config, Module) { | ||
| 537 | offset += providerLen; | 566 | offset += providerLen; |
| 538 | 567 | ||
| 539 | Module.stringToUTF8(config.modelType, buffer + offset, modelTypeLen); | 568 | Module.stringToUTF8(config.modelType, buffer + offset, modelTypeLen); |
| 569 | + offset += modelTypeLen; | ||
| 570 | + | ||
| 571 | + Module.stringToUTF8( | ||
| 572 | + config.modelingUnit || '', buffer + offset, modelingUnitLen); | ||
| 573 | + offset += modelingUnitLen; | ||
| 574 | + | ||
| 575 | + Module.stringToUTF8(config.bpeVocab || '', buffer + offset, bpeVocabLen); | ||
| 576 | + offset += bpeVocabLen; | ||
| 540 | 577 | ||
| 541 | offset = | 578 | offset = |
| 542 | transducer.len + paraformer.len + nemoCtc.len + whisper.len + tdnn.len; | 579 | transducer.len + paraformer.len + nemoCtc.len + whisper.len + tdnn.len; |
| @@ -556,6 +593,17 @@ function initSherpaOnnxOfflineModelConfig(config, Module) { | @@ -556,6 +593,17 @@ function initSherpaOnnxOfflineModelConfig(config, Module) { | ||
| 556 | ptr + offset, buffer + tokensLen + providerLen, 'i8*'); // modelType | 593 | ptr + offset, buffer + tokensLen + providerLen, 'i8*'); // modelType |
| 557 | offset += 4; | 594 | offset += 4; |
| 558 | 595 | ||
| 596 | + Module.setValue( | ||
| 597 | + ptr + offset, buffer + tokensLen + providerLen + modelTypeLen, | ||
| 598 | + 'i8*'); // modelingUnit | ||
| 599 | + offset += 4; | ||
| 600 | + | ||
| 601 | + Module.setValue( | ||
| 602 | + ptr + offset, | ||
| 603 | + buffer + tokensLen + providerLen + modelTypeLen + modelingUnitLen, | ||
| 604 | + 'i8*'); // bpeVocab | ||
| 605 | + offset += 4; | ||
| 606 | + | ||
| 559 | return { | 607 | return { |
| 560 | buffer: buffer, ptr: ptr, len: len, transducer: transducer, | 608 | buffer: buffer, ptr: ptr, len: len, transducer: transducer, |
| 561 | paraformer: paraformer, nemoCtc: nemoCtc, whisper: whisper, tdnn: tdnn | 609 | paraformer: paraformer, nemoCtc: nemoCtc, whisper: whisper, tdnn: tdnn |
| @@ -19,7 +19,7 @@ static_assert(sizeof(SherpaOnnxOnlineZipformer2CtcModelConfig) == 1 * 4, ""); | @@ -19,7 +19,7 @@ static_assert(sizeof(SherpaOnnxOnlineZipformer2CtcModelConfig) == 1 * 4, ""); | ||
| 19 | static_assert(sizeof(SherpaOnnxOnlineModelConfig) == | 19 | static_assert(sizeof(SherpaOnnxOnlineModelConfig) == |
| 20 | sizeof(SherpaOnnxOnlineTransducerModelConfig) + | 20 | sizeof(SherpaOnnxOnlineTransducerModelConfig) + |
| 21 | sizeof(SherpaOnnxOnlineParaformerModelConfig) + | 21 | sizeof(SherpaOnnxOnlineParaformerModelConfig) + |
| 22 | - sizeof(SherpaOnnxOnlineZipformer2CtcModelConfig) + 5 * 4, | 22 | + sizeof(SherpaOnnxOnlineZipformer2CtcModelConfig) + 7 * 4, |
| 23 | ""); | 23 | ""); |
| 24 | static_assert(sizeof(SherpaOnnxFeatureConfig) == 2 * 4, ""); | 24 | static_assert(sizeof(SherpaOnnxFeatureConfig) == 2 * 4, ""); |
| 25 | static_assert(sizeof(SherpaOnnxOnlineCtcFstDecoderConfig) == 2 * 4, ""); | 25 | static_assert(sizeof(SherpaOnnxOnlineCtcFstDecoderConfig) == 2 * 4, ""); |
| @@ -52,6 +52,8 @@ void MyPrint(SherpaOnnxOnlineRecognizerConfig *config) { | @@ -52,6 +52,8 @@ void MyPrint(SherpaOnnxOnlineRecognizerConfig *config) { | ||
| 52 | fprintf(stdout, "provider: %s\n", model_config->provider); | 52 | fprintf(stdout, "provider: %s\n", model_config->provider); |
| 53 | fprintf(stdout, "debug: %d\n", model_config->debug); | 53 | fprintf(stdout, "debug: %d\n", model_config->debug); |
| 54 | fprintf(stdout, "model type: %s\n", model_config->model_type); | 54 | fprintf(stdout, "model type: %s\n", model_config->model_type); |
| 55 | + fprintf(stdout, "modeling unit: %s\n", model_config->modeling_unit); | ||
| 56 | + fprintf(stdout, "bpe vocab: %s\n", model_config->bpe_vocab); | ||
| 55 | 57 | ||
| 56 | fprintf(stdout, "----------feat config----------\n"); | 58 | fprintf(stdout, "----------feat config----------\n"); |
| 57 | fprintf(stdout, "sample rate: %d\n", feat->sample_rate); | 59 | fprintf(stdout, "sample rate: %d\n", feat->sample_rate); |
| @@ -23,7 +23,7 @@ static_assert(sizeof(SherpaOnnxOfflineModelConfig) == | @@ -23,7 +23,7 @@ static_assert(sizeof(SherpaOnnxOfflineModelConfig) == | ||
| 23 | sizeof(SherpaOnnxOfflineParaformerModelConfig) + | 23 | sizeof(SherpaOnnxOfflineParaformerModelConfig) + |
| 24 | sizeof(SherpaOnnxOfflineNemoEncDecCtcModelConfig) + | 24 | sizeof(SherpaOnnxOfflineNemoEncDecCtcModelConfig) + |
| 25 | sizeof(SherpaOnnxOfflineWhisperModelConfig) + | 25 | sizeof(SherpaOnnxOfflineWhisperModelConfig) + |
| 26 | - sizeof(SherpaOnnxOfflineTdnnModelConfig) + 5 * 4, | 26 | + sizeof(SherpaOnnxOfflineTdnnModelConfig) + 7 * 4, |
| 27 | ""); | 27 | ""); |
| 28 | static_assert(sizeof(SherpaOnnxFeatureConfig) == 2 * 4, ""); | 28 | static_assert(sizeof(SherpaOnnxFeatureConfig) == 2 * 4, ""); |
| 29 | static_assert(sizeof(SherpaOnnxOfflineRecognizerConfig) == | 29 | static_assert(sizeof(SherpaOnnxOfflineRecognizerConfig) == |
| @@ -90,6 +90,8 @@ void PrintOfflineRecognizerConfig(SherpaOnnxOfflineRecognizerConfig *config) { | @@ -90,6 +90,8 @@ void PrintOfflineRecognizerConfig(SherpaOnnxOfflineRecognizerConfig *config) { | ||
| 90 | fprintf(stdout, "provider: %s\n", model_config->provider); | 90 | fprintf(stdout, "provider: %s\n", model_config->provider); |
| 91 | fprintf(stdout, "debug: %d\n", model_config->debug); | 91 | fprintf(stdout, "debug: %d\n", model_config->debug); |
| 92 | fprintf(stdout, "model type: %s\n", model_config->model_type); | 92 | fprintf(stdout, "model type: %s\n", model_config->model_type); |
| 93 | + fprintf(stdout, "modeling unit: %s\n", model_config->modeling_unit); | ||
| 94 | + fprintf(stdout, "bpe vocab: %s\n", model_config->bpe_vocab); | ||
| 93 | 95 | ||
| 94 | fprintf(stdout, "----------feat config----------\n"); | 96 | fprintf(stdout, "----------feat config----------\n"); |
| 95 | fprintf(stdout, "sample rate: %d\n", feat->sample_rate); | 97 | fprintf(stdout, "sample rate: %d\n", feat->sample_rate); |
-
请 注册 或 登录 后发表评论