sherpa-onnx
sherpa-onnx copied to clipboard
关于在dotnet下,语音唤醒词kws的问题
@pkufool 简单描述一下。我直接用的keyword-spotting-from-microphone这个demo 但是添加唤醒词 比如输入 带有“XX室” 或者“XX础" (目前只测出这两个字有问题) 的时候会报错 初始化的时候就错误了
代码如下: public class keyword_spotting_from_microphone
{
public keyword_spotting_from_microphone()
{
var config = new KeywordSpotterConfig();
config.FeatConfig.SampleRate = 16000;
config.FeatConfig.FeatureDim = 80;
config.ModelConfig.Transducer.Encoder = "./sherpa-onnx-kws-zipformer-wenetspeech-3.3M-2024-01-01/encoder-epoch-12-avg-2-chunk-16-left-64.onnx";
config.ModelConfig.Transducer.Decoder = "./sherpa-onnx-kws-zipformer-wenetspeech-3.3M-2024-01-01/decoder-epoch-12-avg-2-chunk-16-left-64.onnx";
config.ModelConfig.Transducer.Joiner = "./sherpa-onnx-kws-zipformer-wenetspeech-3.3M-2024-01-01/joiner-epoch-12-avg-2-chunk-16-left-64.onnx";
config.ModelConfig.Tokens = "./sherpa-onnx-kws-zipformer-wenetspeech-3.3M-2024-01-01/tokens.txt";
config.ModelConfig.Provider = "cpu";
config.ModelConfig.NumThreads = 1;
config.ModelConfig.Debug = 1;
config.KeywordsFile = "./sherpa-onnx-kws-zipformer-wenetspeech-3.3M-2024-01-01/test_wavs/test_keywords.txt";
var kws = new KeywordSpotter(config);
Console.WriteLine("----------Use pre-defined keywords----------");
OnlineStream kws_s = kws.CreateStream("j ī x iè s hì @机械室"); //报错
Console.WriteLine(PortAudio.VersionInfo.versionText);
PortAudio.Initialize();
报错位置 stream.Start(); while (true) { while (kws.IsReady(kws_s)) //报错位置 { kws.Decode(kws_s); }
var result = kws.GetResult(kws_s);
if (result.Keyword != "")
{
Console.WriteLine("关键词已识别: {0}", result.Keyword);
}
Thread.Sleep(200); // ms
报错信息 1:System.AccessViolationException HResult=0x80004003 Message=Attempted to read or write protected memory. This is often an indication that other memory is corrupt. Source=<无法计算异常源> StackTrace: <无法计算异常堆栈跟踪> 2:Fatal error. System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt. Repeat 2 times:
at SherpaOnnx.KeywordSpotter.IsReady(IntPtr, IntPtr)
at SherpaOnnx.KeywordSpotter.IsReady(SherpaOnnx.OnlineStream) at ConsoleAppVoiceSherpa.keyword_spotting_from_microphone..ctor() at ConsoleAppVoiceSherpa.Program.Main(System.String[])