对“NAudio!NAudio.Wave.WaveInterop+WaveInCallback::Invoke”类型的已垃圾回收委托进行了回调。这可能会导致应用程序崩溃、损坏和数据丢失。向非托管代码传递委托时,托管应用程序必须让这些委托保持活动状态,直到确信不会再次调用它们。
程序是想对麦克风的声音录取后,进行识别!
大致的代码都在下面,但是每次程序关闭时都会出现上面的错误,雪地跪求大神指导!
namespace NAudio.Wave
{
public class WaveInStream : WaveStream
{
public WaveInStream(int deviceNumber, WaveFormat desiredFormat, Control callbackWindow);
public override long Length { get; }
public override long Position { get; set; }
public override WaveFormat WaveFormat { get; }
public event EventHandler<WaveInEventArgs> DataAvailable;
public event EventHandler RecordingStopped;
protected override void Dispose(bool disposing);
public override int Read(byte[] buffer, int offset, int count);
public void StartRecording();
public void StopRecording();
}
}
private void button3_Click(object sender, EventArgs e)
{
if (luyin)
{
luyin = false;
isr = new ASR(c1, c2);
isr.DataArrived += new EventHandler<FlyASR.DataArrivedEventArgs>(asr_DataAvailable);
isr.StartRecoding();
button3.Text = "停止录音";
}
else
{
luyin = true;
isr.StopRecoding();
button3.Text = "开始录音";
}
}
......
using NAudio.Wave;
namespace ASR
{
public class ASR
{
private class ASRDll
{
#region ISR dllimport
#endregion