void _speechService_SpeechRecognized(object sender, Microsoft.Speech.Recognition.SpeechRecognizedEventArgs e) { const double ConfidenceThreshold = 0.7; if (e.Result.Confidence >= ConfidenceThreshold) { _speechText = e.Result.Semantics.Value.ToString(); switch (e.Result.Semantics.Value.ToString()) { case "START CALIBRATION": _speechService.Speak("Working on it Boss. Might I say myself that this is a great presentation!"); StartCalibration(); break; case "CALIBRATION COMPLETE": //since the calibration window is a modal dialog, this won't get called until the calibration window is closed, which is to late therefore, //don't use speech to close this calibration window as we don't want to allow user to keep calibration open during active sessions //StopCalibration(); break; } } }
/// <summary> /// Initializes a new instance of the MainViewModel class. /// </summary> public MainViewModel(IKioskInteractionService interactionService, ISpeechService speechService, IItemInteractionService manipulationService, IConfigurationProvider configurationProvider) { this.RowWidth = DEPTH_WIDTH; _kioskInteractionService = interactionService; _kioskInteractionService.KioskStateChanged += _kioskInteractionService_KioskStateChanged; _kioskInteractionService.BodyTrackUpdate += _kioskInteractionService_BodyTrackUpdate; BodyTrack = new ObservableCollection <double>() { -75, -75, -75, -75, -75, -75 }; _itemInteractionService = manipulationService; _itemInteractionService.ServiceStateChanged += _itemInteractionService_ServiceStateChanged; _itemInteractionService.ItemInteraction += _itemInteractionService_ItemInteraction; _itemInteractionService.PropertyChanged += _itemInteractionService_PropertyChanged; _speechService = speechService; _speechService.SpeechRecognized += _speechService_SpeechRecognized; _speechService.SpeechRejected += _speechService_SpeechRejected; _speechService.StartListening(); _speechService.Speak("Kiosk Ready"); Messenger.Default.Register <string>(this, (msg) => { if (msg == "SPECIALSTOP") { Debug.WriteLine("MVM SPECIALSTOP " + _lastKioskState); this.KioskState = "CloseSpecial"; } }); this.OpenObjectDetection = new RelayCommand(() => { ShowObjectDetectionWindow(true); }); _configurationProvider = configurationProvider; _configurationProvider.ConfigurationSettingsChanged += _configurationProvider_ConfigurationSettingsChanged; GetConfig(); // Show Object Detection Window on start up ShowObjectDetectionWindow(); }
/// <summary> /// Initializes a new instance of the MainViewModel class. /// </summary> public MainViewModel(IKioskInteractionService interactionService, ISpeechService speechService, IItemInteractionService manipulationService, IConfigurationProvider configurationProvider) { this.RowWidth = DEPTH_WIDTH; _kioskInteractionService = interactionService; _kioskInteractionService.KioskStateChanged += _kioskInteractionService_KioskStateChanged; _kioskInteractionService.BodyTrackUpdate += _kioskInteractionService_BodyTrackUpdate; BodyTrack = new ObservableCollection<double>() { -75, -75, -75, -75, -75, -75 }; _itemInteractionService = manipulationService; _itemInteractionService.ServiceStateChanged += _itemInteractionService_ServiceStateChanged; _itemInteractionService.ItemInteraction += _itemInteractionService_ItemInteraction; _itemInteractionService.PropertyChanged += _itemInteractionService_PropertyChanged; _speechService = speechService; _speechService.SpeechRecognized += _speechService_SpeechRecognized; _speechService.SpeechRejected += _speechService_SpeechRejected; _speechService.StartListening(); _speechService.Speak("Kiosk Ready"); Messenger.Default.Register<string>(this, (msg) => { if (msg == "SPECIALSTOP") { Debug.WriteLine("MVM SPECIALSTOP " + _lastKioskState); this.KioskState = "CloseSpecial"; } }); this.OpenObjectDetection = new RelayCommand(() => { ShowObjectDetectionWindow(true); }); _configurationProvider = configurationProvider; _configurationProvider.ConfigurationSettingsChanged += _configurationProvider_ConfigurationSettingsChanged; GetConfig(); // Show Object Detection Window on start up ShowObjectDetectionWindow(); }
private async void AskCommandHandler() { if (String.IsNullOrEmpty(Query)) { return; } IsEntryPossible = false; try { var qnaResult = await WebService.Query(Query); Debug.WriteLine(qnaResult.ToString()); ResponseJson = qnaResult.ToString(); Answers.Insert(0, qnaResult); textToSpeech.Speak(qnaResult.Answer); Query = ""; } finally { IsEntryPossible = true; } }