/// <summary>
        /// This method is called when the app first appears, but it also checks if it has been launched
        /// using Cortana's voice commands, and takes appropriate action if this is the case.
        /// </summary>
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            _dispatcher = CoreWindow.GetForCurrentThread().Dispatcher;
            _presence   = new UserPresence(_dispatcher, _unfilteredName);

            _pageParameters = e.Parameter as VoiceCommandObjects.VoiceCommand;
            if (_pageParameters != null)
            {
                switch (_pageParameters.VoiceCommandName)
                {
                case "addNewNote":
                    _activeNote = CreateNote(App.EVERYONE);
                    break;

                case "addNewNoteForPerson":
                    _activeNote = CreateNote(_pageParameters.NoteOwner);
                    break;

                default:
                    break;
                }
            }

            //Perform initialization for facial detection.
            if (AppSettings.FaceApiKey != "")
            {
                await FacialSimilarity.TrainDetectionAsync();
            }

            // Perform initialization for speech recognition.
            _speechManager = new SpeechManager(FamilyModel);
            _speechManager.PhraseRecognized += speechManager_PhraseRecognized;
            _speechManager.StateChanged     += speechManager_StateChanged;
            await _speechManager.StartContinuousRecognition();
        }
Exemple #2
0
        private async void startButton_Click(object sender, RoutedEventArgs e)
        {
            startButton.IsEnabled = false;
            startButton.Content   = "Please Wait...";

            //Perform initialization for facial detection.
            await FacialSimilarity.TrainDetectionAsync();



            //Open the camera
            changeCameraState();


            listenAgainButton.Visibility = Visibility.Visible;
            stopButton.Visibility        = Visibility.Visible;
            startButton.Visibility       = Visibility.Collapsed;
            startButton.IsEnabled        = true;
            startButton.Content          = "Start";

            ////Set up the timer
            checkThisPhraseTimer = ThreadPoolTimer.CreatePeriodicTimer(async(source) =>
            {
                checkVoiceFeedback();

                // Update the UI thread by using the UI core dispatcher.
                await Dispatcher.RunAsync(CoreDispatcherPriority.High, () =>
                {
                    if (thisPhrase.Contains("stranger"))
                    {
                        listenAgainButton.Content = "Stranger";
                    }
                });
            }, checkThisPhraseTimeSpan);
        }
Exemple #3
0
        /// <summary>
        /// Test Internet Connection and Load Persons and Faces
        /// </summary>
        private async void testInternetConnection()
        {
            //Test Internet Connection
            try
            {
                showProgressDialog("Checking the Internet Connection and Loading the data...");
                progressDialog.Title             = "Processing: ";
                progressDialog.PrimaryButtonText = "Ok";
                //statusTextBlock.Text = "Checking the Internet Connection...";

                //Get Person List for this patient
                Persons.Clear();
                ObservableCollection <Person> persons = await AzureDatabaseService.GetPersonList(PatientId);

                //statusTextBlock.Text = persons.Count + " Persons: ";

                //Clear Local User Folder
                StorageFolder userFolder = await ApplicationData.Current.LocalFolder.CreateFolderAsync(("Users\\"), CreationCollisionOption.OpenIfExists);

                await userFolder.DeleteAsync();

                userFolder = await ApplicationData.Current.LocalFolder.CreateFolderAsync(("Users\\"), CreationCollisionOption.OpenIfExists);

                //Perform initialization for facial detection.
                await FacialSimilarity.TrainDetectionAsync();

                //Download each person
                foreach (Person person in persons)
                {
                    //Update Info
                    person.DefaultIcon = await AzureBlobService.DisplayImageFile(person.DefaultImageAddress);

                    Persons.Add(person);

                    //Get Face List for each person
                    ObservableCollection <Face> faces = await AzureDatabaseService.GetFaceList(person.Id);

                    foreach (Face face in faces)
                    {
                        face.Image = await AzureBlobService.DisplayImageFile(face.ImageAddress);
                    }
                    Faces.Add(faces);

                    AddNewPersonFromDB(person, faces);

                    //statusTextBlock.Text += faces.Count + " faces ";
                }
            }
            catch (System.Net.Http.HttpRequestException)
            {
                internetConnection = false;
                //statusTextBlock.Text = " ";
                //showProgressDialog("Internet Connection Error! Please check your Internet connection.");
                progressDialog.Title                  = "Internet Connection Error!";
                progressDialog.PrimaryButtonText      = "Ok, I know";
                progressDialog.IsPrimaryButtonEnabled = true;
                //await progressDialog.ShowAsync();

                return;
                //Test Internet Connection Again
                //testInternetConnection();
            }

            internetConnection = true;
            //statusTextBlock.Text = "Internet Connection Success!";
            progressDialog.Content = "Success!";
            progressDialog.IsPrimaryButtonEnabled = true;
            return;
        }