提供设置关键词的api,方便动态调整关键词来进行识别 (#923)

This commit is contained in:
hantengc
2024-05-27 19:07:26 +08:00
committed by GitHub
parent 49ea59d4ff
commit 1371c6b3f0
2 changed files with 17 additions and 0 deletions

View File

@@ -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());

View File

@@ -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.
///