简体   繁体   中英

record audio data while using speech recognition?

I'm successfully using the .NET speech recognition portion in my C# application for basic talking things.

In addition to this, is it possible to record the audio that it picks up inside my application in parallel with my application recognizing it. I want to save it for a later date so I can analyze it.

Would you create a separate thread and then put some .NET audio recordings in there when I speak into the microphone? I only want to save them in a local directory, in .wav format. An easy recording such as 48khz and 16 bit sample.

I'm using a normal form application, and this is the type of speech code I have now just to give you an idea.

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

Have a look at the Windows APIs. I am sure you can register an handler/event handler/interceptor there, to get the audio data. Check out following link: maybe helpfull

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM