Fix keyword spotting. (#1689)
Reset the stream right after detecting a keyword
This commit is contained in:
@@ -168,6 +168,10 @@ class KeywordSpotter {
|
||||
SherpaOnnxBindings.decodeKeywordStream?.call(ptr, stream.ptr);
|
||||
}
|
||||
|
||||
void reset(OnlineStream stream) {
|
||||
SherpaOnnxBindings.resetKeywordStream?.call(ptr, stream.ptr);
|
||||
}
|
||||
|
||||
Pointer<SherpaOnnxKeywordSpotter> ptr;
|
||||
KeywordSpotterConfig config;
|
||||
}
|
||||
|
||||
@@ -667,6 +667,12 @@ typedef DecodeKeywordStreamNative = Void Function(
|
||||
typedef DecodeKeywordStream = void Function(
|
||||
Pointer<SherpaOnnxKeywordSpotter>, Pointer<SherpaOnnxOnlineStream>);
|
||||
|
||||
typedef ResetKeywordStreamNative = Void Function(
|
||||
Pointer<SherpaOnnxKeywordSpotter>, Pointer<SherpaOnnxOnlineStream>);
|
||||
|
||||
typedef ResetKeywordStream = void Function(
|
||||
Pointer<SherpaOnnxKeywordSpotter>, Pointer<SherpaOnnxOnlineStream>);
|
||||
|
||||
typedef GetKeywordResultAsJsonNative = Pointer<Utf8> Function(
|
||||
Pointer<SherpaOnnxKeywordSpotter>, Pointer<SherpaOnnxOnlineStream>);
|
||||
|
||||
@@ -1157,6 +1163,7 @@ class SherpaOnnxBindings {
|
||||
static CreateKeywordStreamWithKeywords? createKeywordStreamWithKeywords;
|
||||
static IsKeywordStreamReady? isKeywordStreamReady;
|
||||
static DecodeKeywordStream? decodeKeywordStream;
|
||||
static ResetKeywordStream? resetKeywordStream;
|
||||
static GetKeywordResultAsJson? getKeywordResultAsJson;
|
||||
static FreeKeywordResultJson? freeKeywordResultJson;
|
||||
|
||||
@@ -1459,6 +1466,11 @@ class SherpaOnnxBindings {
|
||||
'SherpaOnnxDecodeKeywordStream')
|
||||
.asFunction();
|
||||
|
||||
resetKeywordStream ??= dynamicLibrary
|
||||
.lookup<NativeFunction<ResetKeywordStreamNative>>(
|
||||
'SherpaOnnxResetKeywordStream')
|
||||
.asFunction();
|
||||
|
||||
getKeywordResultAsJson ??= dynamicLibrary
|
||||
.lookup<NativeFunction<GetKeywordResultAsJsonNative>>(
|
||||
'SherpaOnnxGetKeywordResultAsJson')
|
||||
|
||||
Reference in New Issue
Block a user