k2-fsa / sherpa-onnx

Speech-to-text, text-to-speech, speaker diarization, and VAD using next-gen Kaldi with onnxruntime without Internet connection. Support embedded systems, Android, iOS, Raspberry Pi, RISC-V, x86_64 servers, websocket server/client, C/C++, Python, Kotlin, C#, Go, NodeJS, Java, Swift, Dart, JavaScript, Flutter, Object Pascal, Lazarus, Rust
https://k2-fsa.github.io/sherpa/onnx/index.html
Apache License 2.0
3.69k stars 428 forks source link

Changing hotwords without reloading model #1556

Open mxbi opened 5 days ago

mxbi commented 5 days ago

First of all, thank you for building such a cool library.

I'm using the C++ API to load streaming Zipformer models with SherpaOnnxCreateOnlineRecognizer, using hotwords_file to bias the decoding. In my use case, there are different situations in which we're expecting different utterances, but changing the hotwords appears to require reloading the model (which is obviously)

Is there a way to change the hotwords for an already created recognizer? If not, then I could try to help implement it if you had some pointers on how to do it.

Thanks a lot!

csukuangfj commented 5 days ago

We already support it.

please see https://github.com/k2-fsa/sherpa-onnx/blob/e424cc9e0df1a4f03bd0da6845af6f3b891d8518/sherpa-onnx/c-api/c-api.h#L233