使用语音识别时录制音频数据?

时间:2013-08-20 14:34:16

标签: c# .net audio recording

我在我的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

1 个答案:

答案 0 :(得分:2)

查看Windows API。我相信你可以在那里注册一个处理程序/事件处理程序/拦截器来获取音频数据。请查看以下链接:maybe helpfull