From 94a6e2ac16bfb91c6a79d8e47cba3c96e357ca85 Mon Sep 17 00:00:00 2001 From: hantengc Date: Mon, 27 May 2024 10:37:26 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BE=9B=E8=AE=BE=E7=BD=AE=E5=85=B3?= =?UTF-8?q?=E9=94=AE=E8=AF=8D=E7=9A=84api=EF=BC=8C=E6=96=B9=E4=BE=BF?= =?UTF-8?q?=E5=8A=A8=E6=80=81=E8=B0=83=E6=95=B4=E5=85=B3=E9=94=AE=E8=AF=8D?= =?UTF-8?q?=E6=9D=A5=E8=BF=9B=E8=A1=8C=E8=AF=86=E5=88=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sherpa-onnx/c-api/c-api.cc | 7 +++++++ sherpa-onnx/c-api/c-api.h | 10 ++++++++++ 2 files changed, 17 insertions(+) diff --git a/sherpa-onnx/c-api/c-api.cc b/sherpa-onnx/c-api/c-api.cc index 615e86da8c..5cc5cde01b 100644 --- a/sherpa-onnx/c-api/c-api.cc +++ b/sherpa-onnx/c-api/c-api.cc @@ -561,6 +561,13 @@ SherpaOnnxOnlineStream *CreateKeywordStream( return stream; } +SherpaOnnxOnlineStream *CreateKeywordStreamWithKeywords( + const SherpaOnnxKeywordSpotter *spotter, const char *keywords) { + SherpaOnnxOnlineStream *stream = + new SherpaOnnxOnlineStream(spotter->impl->CreateStream(keywords)); + return stream; +} + int32_t IsKeywordStreamReady(SherpaOnnxKeywordSpotter *spotter, SherpaOnnxOnlineStream *stream) { return spotter->impl->IsReady(stream->impl.get()); diff --git a/sherpa-onnx/c-api/c-api.h b/sherpa-onnx/c-api/c-api.h index 87cdfc5ca8..5638650fa2 100644 --- a/sherpa-onnx/c-api/c-api.h +++ b/sherpa-onnx/c-api/c-api.h @@ -583,6 +583,16 @@ SHERPA_ONNX_API void DestroyKeywordSpotter(SherpaOnnxKeywordSpotter *spotter); SHERPA_ONNX_API SherpaOnnxOnlineStream *CreateKeywordStream( const SherpaOnnxKeywordSpotter *spotter); +/// Create an online stream for accepting wave samples with the specified hot +/// words. +/// +/// @param spotter A pointer returned by CreateKeywordSpotter() +/// @param keywords A pointer points to the keywords that you set +/// @return Return a pointer to an OnlineStream. The user has to invoke +/// DestroyOnlineStream() to free it to avoid memory leak. +SHERPA_ONNX_API SherpaOnnxOnlineStream *CreateKeywordStreamWithKeywords( + const SherpaOnnxKeywordSpotter *spotter, const char *keywords); + /// Return 1 if there are enough number of feature frames for decoding. /// Return 0 otherwise. ///