Fix keyword spotting. (#1689)

Reset the stream right after detecting a keyword
This commit is contained in:
Fangjun Kuang
2025-01-20 16:41:10 +08:00
committed by GitHub
parent b943341fb1
commit 8b989a851c
43 changed files with 813 additions and 293 deletions

View File

@@ -46,6 +46,11 @@ namespace SherpaOnnx
Decode(_handle.Handle, stream.Handle);
}
public void Reset(OnlineStream stream)
{
Reset(_handle.Handle, stream.Handle);
}
// The caller should ensure all passed streams are ready for decoding.
public void Decode(IEnumerable<OnlineStream> streams)
{
@@ -110,6 +115,9 @@ namespace SherpaOnnx
[DllImport(Dll.Filename, EntryPoint = "SherpaOnnxDecodeKeywordStream")]
private static extern void Decode(IntPtr handle, IntPtr stream);
[DllImport(Dll.Filename, EntryPoint = "SherpaOnnxResetKeywordStream")]
private static extern void Reset(IntPtr handle, IntPtr stream);
[DllImport(Dll.Filename, EntryPoint = "SherpaOnnxDecodeMultipleKeywordStreams")]
private static extern void Decode(IntPtr handle, IntPtr[] streams, int n);