本文整理汇总了C#中NAudio.Wave.WaveIn.StopRecording方法的典型用法代码示例。如果您正苦于以下问题:C# WaveIn.StopRecording方法的具体用法?C# WaveIn.StopRecording怎么用?C# WaveIn.StopRecording使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NAudio.Wave.WaveIn
的用法示例。
在下文中一共展示了WaveIn.StopRecording方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PrepareMic
public static void PrepareMic()
{
WaveIn waveIn = new WaveIn();
waveIn.WaveFormat = new WaveFormat(SAMPLE_FREQ, 16, 1);
waveIn.StartRecording();
waveIn.StopRecording();
waveIn.Dispose();
}
示例2: waveIn_RecordingStopped
private void waveIn_RecordingStopped(object sender, EventArgs e)
{
if (writeToFile == 1)
{
waveIn.Dispose();
waveIn = null;
writer.Close();
writer = null;
int bytes_to_read = (rec_times + 1) * 6400;
byte[] wav_bytes = new byte[bytes_to_read];
WaveFileReader wfr = new WaveFileReader("file.wav");
if (wfr.Length < bytes_to_read)
{
wfr.Read(wav_bytes, 0, (int)wfr.Length);
}
else
{
wfr.Position = wfr.Length - 1 - bytes_to_read;
wfr.Read(wav_bytes, 0, bytes_to_read);
}
wfr.Dispose();
wfr.Close();
WaveIn second_waveIn = new WaveIn();
second_waveIn.DeviceNumber = 0;
second_waveIn.WaveFormat = new WaveFormat(16000, 2);
WaveFileWriter second_writer = new WaveFileWriter("cmd.wav", second_waveIn.WaveFormat);
second_waveIn.StartRecording();
second_writer.Write(wav_bytes, 0, bytes_to_read);
second_waveIn.StopRecording();
second_waveIn.Dispose();
second_waveIn = null;
second_writer.Close();
second_writer = null;
listBox1.Items.Add("CONVERTING");
listBox1.SelectedIndex = listBox1.Items.Count - 1;
Wav2Flac("cmd.wav", "file.flac");
result = GoogleSpeechRequest(16000);
string res = result;
int k = res.IndexOf("utterance\":\"") + "utterance\":\"".Length;
int k1 = res.IndexOf("\"", k + 1);
string cmd = res.Substring(k, k1 - k);
listBox1.Items.Add("RECOGNIZED");
richTextBox1.Text += cmd + "\n";
File.Delete("cmd.wav");
rec_times = 0;
writeToFile = 0;
}
else
if (writeToFile == 0)
{
waveIn.Dispose();
waveIn = null;
writer.Close();
writer = null;
}
}