Ejemplo n.º 1
0
        /// <summary>
        /// Some speech was recognized by the voiceEngine.
        /// </summary>
        private void sre_SpeechRecognized(object sender, SpeechRecognizedEventArgs recognizedPhrase)
        {
            // Trigger the event for command recoginized
            TriggerCommandAccepted(recognizedPhrase.Result.Words.Aggregate("", (phraseSoFar, word) => phraseSoFar + word.Text + " "), recognizedPhrase.Result.Confidence);

            // Makes sure that the active application is valid for input
            var activeApplication = ForegroundProcess.ExecutableName;

            if (!MonitoredExecutables.Any(x => x.Equals(activeApplication, StringComparison.OrdinalIgnoreCase)))
            {
                Trace.WriteLine(string.Format("Skipping command, {0} is not in the list of monitored applications", activeApplication));

                //App.Sentry.Capture(new SharpRaven.Data.SentryEvent("Unmonitored Forground Application")
                //{
                //    Level = SharpRaven.Data.ErrorLevel.Warning,
                //    Extra = new Dictionary<string, string>()
                //    {
                //        { "ExecutableName", activeApplication }
                //    }
                //});
                return;
            }

            // Get a thread from the thread pool to execute the command
#pragma warning disable CS4014
            CommandPool.ExecuteAsync(recognizedPhrase.Result.Semantics);
#pragma warning restore CS4014
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Some speech was recognized by the voiceEngine.
        /// </summary>
        private void sre_SpeechRecognized(object sender, SpeechRecognizedEventArgs recognizedPhrase)
        {
            // Trigger the event for command recoginized
            TriggerCommandAccepted(recognizedPhrase.Result.Words.Aggregate("", (phraseSoFar, word) => phraseSoFar + word.Text + " "), recognizedPhrase.Result.Confidence);

            // Makes sure that the active application is valid for input
            var activeApplication = ForegroundProcess.ExecutableName;

            if (!MonitoredExecutables.Any(x => x.Equals(activeApplication, StringComparison.OrdinalIgnoreCase)))
            {
                Trace.WriteLine(string.Format("Skipping command, {0} is not in the list of monitored applications", activeApplication));
                return;
            }

            // Get a thread from the thread pool to execute the command
            CommandPool.ExecuteAsync(recognizedPhrase.Result.Semantics);
        }