我成功地在我的 C# 应用程序中使用 .NET 语音识别部分来处理基本的谈话内容。
除此之外,是否可以在我的应用程序识别它的同时记录它在我的应用程序中拾取的音频。我想将其保存以备后用,以便进行分析。
当我对着麦克风讲话时,您会创建一个单独的线程,然后将一些 .NET 录音放在那里吗?我只想将它们以 .wav 格式保存在本地目录中。一个简单的记录,如 48khz 和 16 位样本。
我正在使用普通表单应用程序,这是我现在拥有的语音代码类型,只是为了给你一个想法。
using System.Speech.Recognition;
//then inside the class and namespace I have
public partial class Form1 : Form
{
SpeechRecognitionEngine _recognizer = new SpeechRecognitionEngine();
//declared variables here
//now I initialize
public Form1()
{
InitializeComponent();
_recognizer.SetInputToDefaultAudioDevice();
_recognizer.LoadGrammar(new Grammar(new GrammarBuilder(new Choices(File.ReadAllLines(@"Commands.txt")))));
_recognizer.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(_recognizer_SpeechRecognized);
_recognizer.RecognizeAsync(RecognizeMode.Multiple);
systemOnline();
}
void _recognizer_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
{
string time = now.GetDateTimeFormats('t')[0];
int ranNum;
string speech = e.Result.Text;
switch (speech)
{
//Open Google
case "Google":
//code opens google in default browser