diff --git a/sherpa-onnx/c-api/c-api.cc b/sherpa-onnx/c-api/c-api.cc index 07933bee4..c08a3fef6 100644 --- a/sherpa-onnx/c-api/c-api.cc +++ b/sherpa-onnx/c-api/c-api.cc @@ -107,6 +107,13 @@ SherpaOnnxOnlineStream *CreateOnlineStream( return stream; } +SherpaOnnxOnlineStream *CreateOnlineStreamWithHotwords( + const SherpaOnnxOnlineRecognizer *recognizer, const char *hotwords) { + SherpaOnnxOnlineStream *stream = + new SherpaOnnxOnlineStream(recognizer->impl->CreateStream(hotwords)); + return stream; +} + void DestroyOnlineStream(SherpaOnnxOnlineStream *stream) { delete stream; } void AcceptWaveform(SherpaOnnxOnlineStream *stream, int32_t sample_rate, diff --git a/sherpa-onnx/c-api/c-api.h b/sherpa-onnx/c-api/c-api.h index 5e514d3d5..ff8f73da0 100644 --- a/sherpa-onnx/c-api/c-api.h +++ b/sherpa-onnx/c-api/c-api.h @@ -31,7 +31,7 @@ extern "C" { #define SHERPA_ONNX_IMPORT #endif #else // WIN32 -#define SHERPA_ONNX_EXPORT +#define SHERPA_ONNX_EXPORT __attribute__((visibility("default"))) #define SHERPA_ONNX_IMPORT SHERPA_ONNX_EXPORT #endif @@ -178,6 +178,13 @@ SHERPA_ONNX_API void DestroyOnlineRecognizer( SHERPA_ONNX_API SherpaOnnxOnlineStream *CreateOnlineStream( const SherpaOnnxOnlineRecognizer *recognizer); +/// Create an online stream for accepting wave samples with the specified hot words. +/// +/// @param recognizer A pointer returned by CreateOnlineRecognizer() +/// @return Return a pointer to an OnlineStream. The user has to invoke +/// DestroyOnlineStream() to free it to avoid memory leak. +SHERPA_ONNX_API SherpaOnnxOnlineStream *CreateOnlineStreamWithHotwords(const SherpaOnnxOnlineRecognizer *recognizer, const char *hotwords); + /// Destroy an online stream. /// /// @param stream A pointer returned by CreateOnlineStream()