예제 #1
0
        private void btnRegistration_Click(object sender, RoutedEventArgs e)
        {
            if (db.Users.SingleOrDefault(x => x.username == txtUsername.Text) != null)
            {
                MessageBox.Show("Username is already exist!", "Error", MessageBoxButton.OK);
                return;
            }

            string temp = "";

            if (!String.IsNullOrEmpty((temp = validation(txtUsername.Text, "Username"))))
            {
                MessageBox.Show(temp, "Error", MessageBoxButton.OK); return;
            }
            if (!String.IsNullOrEmpty((temp = validation(txtName.Text, "Name"))))
            {
                MessageBox.Show(temp, "Error", MessageBoxButton.OK); return;
            }
            if (txtPassword.Password == "xxxxxxx")
            {
                txtPassword.Password = "";
            }
            if (!String.IsNullOrEmpty((temp = validation(txtPassword.Password, "Password"))))
            {
                MessageBox.Show(temp, "Error", MessageBoxButton.OK); return;
            }
            if (!String.IsNullOrEmpty((temp = validation(txtFamilyId.Text, "FamilyId"))))
            {
                MessageBox.Show(temp, "Error", MessageBoxButton.OK); return;
            }
            if (!String.IsNullOrEmpty((temp = validation(txtAge.Text, "Age"))))
            {
                MessageBox.Show(temp, "Error", MessageBoxButton.OK); return;
            }


            regUser.username  = txtUsername.Text.Trim();
            regUser.name      = txtName.Text.Trim();
            regUser.password  = txtPassword.Password.Trim();
            regUser.age       = txtAge.Text.Trim();
            regUser.photofile = ConfigurationSettings.AppSettings.Get("photoslocation") + txtUsername.Text + ".jpg";
            regUser.familyid  = txtFamilyId.Text.Trim();
            Helper.SaveImageCapture((BitmapSource)image1.Source, regUser.photofile);

            db.Users.InsertOnSubmit(regUser);
            db.SubmitChanges();
            MessageBox.Show("Registration successful, please record your voice for speaker recognition login!", "Successful", MessageBoxButton.OK);
            //GC.Collect();
            UserRegistrationAudio mw = new UserRegistrationAudio(txtUsername.Text);

            mw.Show();
            this.Close();
        }
예제 #2
0
        private void speakResponse(string text)
        {
            string howWarmQuestion = "How warm do you want your home to be?";

            if ((text.ToLower().Contains("degree") || text.ToLower().Contains("temperature"))
                //(text.ToLower().Contains("has") || text.ToLower().Contains("house") || text.ToLower().Contains("home"))
                )
            {
                string temp = Regex.Match(text.ToLower(), @"\d+").Value;
                if (String.IsNullOrEmpty(temp))
                {
                    lblAI.Content = howWarmQuestion;
                }
                else
                {
                    lblAI.Content = "Your default temprature has been set to " + temp + " degrees. Thank you!";
                    isResponded   = true;
                }
                talk(lblAI.Content.ToString());
            }
            else if (text.ToLower().Contains("log") && text.ToLower().Contains("out"))
            {
                logout();
            }
            else
            {
                if (!String.IsNullOrEmpty(Regex.Match(text.ToLower(), @"\d+").Value) && String.Equals(howWarmQuestion, lblAI.Content.ToString()))
                {
                    string temp = Regex.Match(text.ToLower(), @"\d+").Value;
                    lblAI.Content = "Your default temprature has been set to " + temp + " degrees. Thank you!";
                    isResponded   = true;
                    talk(lblAI.Content.ToString());
                }
                else
                {
                    lblAI.Content = "";
                    MessageBox.Show("Please notice: The only feature available at the moment is to set your home temperature.", "Warning", MessageBoxButton.OK);
                }
            }

            if (isResponded)
            {
                string temp = Regex.Match(text.ToLower(), @"\d+").Value;
                UserTableDataContext dataContext = new UserTableDataContext();
                User usr = dataContext.Users.SingleOrDefault(x => x.username == user.username);
                usr.defaulthometemprature = int.Parse(temp);
                dataContext.SubmitChanges();
            }
        }
예제 #3
0
 private void btnSave_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         UserTableDataContext dataContext = new UserTableDataContext();
         user = dataContext.Users.SingleOrDefault(x => x.username == user.username);
         user.defaulthometemprature = int.Parse(txtSetHouseTemperature.Text);
         dataContext.SubmitChanges();
         MessageBox.Show("Temperature setting has been updated!", "Successful");
     }
     catch (Exception ex)
     {
         MessageBox.Show("Invalid temperature format!\n" + ex.Message, "Failed", MessageBoxButton.OK);
     }
 }
예제 #4
0
        /// <summary>
        /// Enrolls the audio of the speaker
        /// </summary>
        /// <param name="audioStream">The audio stream</param>
        private async void enrollSpeaker(Stream audioStream)
        {
            try
            {
                //Stopwatch sw = Stopwatch.StartNew();
                Enrollment response = await _serviceClient.EnrollAsync(audioStream, _speakerId);

                //sw.Stop();
                lblStatus.Content           = "Enrollment done, " + response.RemainingEnrollments.ToString() + " remaining(s)"; //+ sw.Elapsed;
                txtRemainingEnrollment.Text = response.RemainingEnrollments.ToString();


                txtPhraseText.Text = response.Phrase;

                if (response.RemainingEnrollments == 0)
                {
                    //MessageBox.Show("You have now completed the minimum number of enrollments. You can press finish or add more enrollments", "Speaker enrolled");
                    MessageBox.Show("Registration completed!", "Speaker enrolled");
                    user.speakerguid   = _speakerId.ToString();
                    user.speakerphrase = txtPhraseText.Text;
                    dataContext.SubmitChanges();
                    //GC.Collect();
                    MainWindow mw = new MainWindow();
                    mw.Show();
                    this.Close();
                }
                btnReset.IsEnabled = true;
            }
            catch (EnrollmentException exception)
            {
                lblStatus.Content = "Cannot enroll speaker: " + exception.Message;
            }
            catch (Exception gexp)
            {
                lblStatus.Content = "Error: " + gexp.Message;
            }
        }