Quantcast
Channel: Windows Forms General forum
Viewing all articles
Browse latest Browse all 12583

Commands via notepad using speech recognition

$
0
0

I made 2 grammars with 2 types of choices like this (they work)

Choices artists = new Choices(new string[] { "bullet-for-my-valentine-          curses", "black-veil-brides-saviour", "three-days-grace-wake-up" });
        Choices search = new Choices(new string[] { "bullet" });
        GrammarBuilder findServices = new GrammarBuilder("Play");
        findServices.Append(artists);
        GrammarBuilder google = new GrammarBuilder("Look");
        google.Append("for");
        google.Append(search);

        // Create a Grammar object from the GrammarBuilder and load it to the recognizer.
        Grammar servicesGrammar = new Grammar(findServices);
        Grammar lookingGrammar = new Grammar(google);
        _recognizer.RequestRecognizerUpdate();
        _recognizer.LoadGrammar(servicesGrammar);
        _recognizer.LoadGrammar(lookingGrammar);

with also this, where " " has things which I'm going to say:

void _recognizer_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
    {
        if (e.Result.Words[1].Text == "bullet-for-my-valentine-curses")
        {
            JARVIS.Speak("Playing" + e.Result.Words[1].Text);
            Process.Start("http://www.youtube.com/results?search_query=" + e.Result.Words[1].Text);
        }
        else if (e.Result.Words[2].Text == "bullet")
        {
            JARVIS.Speak("Searching for" + e.Result.Words[2].Text);
            Process.Start("http://hr.wikipedia.org/wiki/" + e.Result.Words[2].Text);
        }
    }

How to replace what I'm going to say, with location of notepad which will contain commands insead writing all of them in " ". I made one before, but the code is not the same. Do you have any sugestions how to do that?!



Viewing all articles
Browse latest Browse all 12583

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>