Exemple #1
0
        public ShellViewModel( ITimerHandler timerHandler, 
                               IPlaybackHandler playbackHandler, 
                               ICommandHandler commandHandler )
        {
            this.TimerHandler = timerHandler;
            this.playbackHandler = playbackHandler;

            this.TimerHandler.TimedEventCompleted += ( se, ea ) =>
            {
                this.playbackHandler.PlayTimedEventComplete( se as TimedEvent );
            };

            commandHandler.CommandRecognized += ( se, ea ) =>
            {
                this.playbackHandler.PlayCommandAccepted();

                var command = se as Command;

                if ( command.Verb == "time" )
                {
                    this.TimerHandler.Start( command.Noun );
                }
                else if ( command.Verb == "clear" )
                {
                    this.TimerHandler.Clear( command.Noun );
                }
            };
        }
        public VoiceCommandHandler( IConfigHandler config, ITimerHandler timerHandler )
        {
            this.engine = new SpeechRecognitionEngine();
            this.timerHandler = timerHandler;

            var builder = new GrammarBuilder();
            builder.Append( new Choices( config.Config.Verbs.ToArray() ) );
            builder.Append( new Choices( config.Commands.ToArray() ) );

            this.engine.RequestRecognizerUpdate();
            this.engine.LoadGrammar( new Grammar( builder ) );

            this.engine.SpeechRecognized += engine_SpeechRecognized;

            this.engine.SetInputToDefaultAudioDevice();
            this.engine.RecognizeAsync( RecognizeMode.Multiple );
        }