Ejemplo n.º 1
0
        public override void PerformAction()
        {
            this.ClearArea();
            this.CommandString = this.CommandString.ToLower();
            string oldPhrase = "how old are you";
            string agePhrase = "what is your age";
            string birthDate = "what is your birthdate";
            string born      = "when were you born";

            if (this.CommandString.Contains(oldPhrase) || this.CommandString.Contains(agePhrase) || this.CommandString.Contains(birthDate) || this.CommandString.Contains(born))
            {
                DateTime dobBob = new DateTime(2020, 5, 4, 18, 30, 0);
                CalculateAge(dobBob);
                string text = String.Format("I was released to the world on {0}. Therefore, I am {1} years, {2} months, and {3} days old.", dobBob.ToString(), ageInyears, ageInMonths, ageInDays);
                string ssml = new SSMLBuilder().Prosody(text, contour: "(20%, +8%) (60%,-8%) (80%, +2%)").Build();
                TextToSpeechEngine.SpeakInflectedText(this.MediaElement, ssml);
                this.ShowMessage(text);
            }
            else
            {
                string text = @"I'm sorry I do not understand. If you are interested in how old I am, please say,'hey bob, how old are you'";
                string ssml = new SSMLBuilder().Prosody(text, contour: "(20%, +8%) (60%,-8%) (80%, +2%)").Build();
                TextToSpeechEngine.SpeakInflectedText(this.MediaElement, ssml);
                this.ShowMessage(text);
            }
        }
Ejemplo n.º 2
0
        public async override void PerformAction()
        {
            List <WeatherInfo> weatherInfos = await WeatherService.GetWeather();

            // if there's a date in the command string, find it and compare it with the dates provided
            DateTime commandDate = DateTimeParser.ParseDateTimeFromText(this.CommandString);
            // get the first applicable weather info
            WeatherInfo firstApplicableWeatherInfo = weatherInfos.Find(info => info.DateApplicable >= commandDate);

            if (firstApplicableWeatherInfo != null && this.MediaElement != null)
            {
                this.ClearArea();
                // TODO get better at determining where there should be inflection. Right now this works but sounds a bit too robotic
                string inflectionData = new SSMLBuilder().Prosody(SplitWeatherDescUpIntoSSMLSentences(firstApplicableWeatherInfo.Description), contour: "(30%,+10%) (60%,-10%) (90%,+5%)").Build();
                TextToSpeechEngine.SpeakInflectedText(this.MediaElement, inflectionData);
                this.ShowMessage(firstApplicableWeatherInfo.Description);
            }
            else if (firstApplicableWeatherInfo == null)
            {
                this.ClearArea();
                string message = "I could not find any weather info for the date specified. Try making sure that you have location enabled, and that this app can access your location through system settings, privacy, location";
                TextToSpeechEngine.SpeakText(this.MediaElement, message);
                this.ShowMessage(message.Replace("settings, privacy, location", "settings > privacy > location"));
            }
        }
Ejemplo n.º 3
0
        public override void PerformAction()
        {
            this.ClearArea();
            this.CommandString = this.CommandString.ToLower();
            string text = GetGreeting();
            string ssml = new SSMLBuilder().Prosody(text, contour: "(20%, +8%) (60%,-8%) (80%, +2%)").Build();

            TextToSpeechEngine.SpeakInflectedText(this.MediaElement, ssml);
            this.ShowMessage(text);
        }
Ejemplo n.º 4
0
        private void IntroduceBob()
        {
            string greetingText = "Hi, I'm Bob, your new digital assistant! It's nice to meet you! To get started, try saying \"Hey bob, what can you do?\" or type \"What can you do?\" in the command box down below.";

            // write the greeting text to the dynamic area
            UIUtils.ShowMessageOnRelativePanel(this.DynamicArea, greetingText);
            string ssmlText = new SSMLBuilder().Prosody(greetingText, contour: "(5%, +20%) (40%, -15%)").Build();

            TextToSpeechEngine.SpeakInflectedText(this.media, ssmlText);
        }
Ejemplo n.º 5
0
        private void EditReminder()
        {
            // it's pretty hard to figure out which reminder to edit and which fields need to be edited, so direct the users to the reminders page
            this.ClearArea();
            string text     = "For now, editing reminders through voice is not supported. You can edit a reminder by going to the reminders page, finding the reminder you want to edit, and clicking the \"edit\" button.";
            string ssmlText = new SSMLBuilder().Prosody(text, pitch: "+2%", contour: "(10%,-2%) (40%, -3%) (80%, +3%)").Build();

            TextToSpeechEngine.SpeakInflectedText(this.MediaElement, ssmlText);
            this.ShowMessage(text);
        }
Ejemplo n.º 6
0
 public override void PerformAction()
 {
     // TODO start recording voice and show controls on the dynamic area
     if (this.DynamicArea != null)
     {
         // have bob tell the user to click the recording button when they're ready
         string ssmlText = new SSMLBuilder().Prosody("Sure, just click the button on your screen when you're ready.", contour: "(0%, +10%) (50%, -5%) (80%, -15%)").Build();
         TextToSpeechEngine.SpeakInflectedText(this.MediaElement, ssmlText);
         this.ClearArea();
         this.SetUpUI();
     }
 }
Ejemplo n.º 7
0
        private async Task <Alarm> NewAlarm()
        {
            Alarm createdAlarm = await this.CreateAlarm();

            // insert the alarm into the database
            StoredProcedures.CreateAlarm(createdAlarm.Title, createdAlarm.ActivateDateAndTime);
            string mainPart    = $"Alright, alarm set for ";
            string datePart    = createdAlarm.ActivateDateAndTime.ToString("MMM d");
            string timePart    = createdAlarm.ActivateDateAndTime.ToString("h:mm tt");
            string rawSSML     = new SSMLBuilder().Add(mainPart).SayAs(datePart, SSMLBuilder.SayAsTypes.DATE).Add(" at ").SayAs(timePart, SSMLBuilder.SayAsTypes.TIME).BuildWithoutWrapperElement();
            string prosodySSML = new SSMLBuilder().Prosody(rawSSML, pitch: "+5%", contour: "(10%,+5%) (50%,-5%) (80%,-5%)").Build();

            TextToSpeechEngine.SpeakInflectedText(this.MediaElement, prosodySSML);
            return(createdAlarm);
        }
Ejemplo n.º 8
0
        private void performActionFromCommandBoxText(string text)
        {
            // get the action for the text in the text box
            Func <string, BobTheDigitalAssistant.Actions.Action> actionPrimer = ActionRouter.GetFunctionFromCommandString(text);

            if (actionPrimer != null)
            {
                BobTheDigitalAssistant.Actions.Action action = actionPrimer.Invoke(text);
                action.PerformAction(this.media, this.DynamicArea);
            }
            else
            {
                // TODO pull this response from the database once the story to create bob responses is done
                string message = "Sorry, I don't understand.";
                string ssml    = new SSMLBuilder().Prosody(message, contour: "(5%, +10%) (30%, -10%) (80%, +0.5%)").Build();
                TextToSpeechEngine.SpeakInflectedText(this.media, ssml);
            }
        }
Ejemplo n.º 9
0
        private void DeleteReminder()
        {
            Reminder reminderToDelete = this.GetReminderForClosestMatchToPassedDate();

            if (reminderToDelete != null)
            {
                StoredProcedures.DeleteReminder(reminderToDelete.ReminderID);
                string message = new SSMLBuilder().Prosody("Successfully deleted reminder.", contour: "(1%,+2%) (50%,-1%) (80%,-1%)").Build();
                TextToSpeechEngine.SpeakInflectedText(this.MediaElement, message);
                this.ShowMessage($"Successfully deleted reminder {reminderToDelete.Title}");
            }
            else
            {
                this.ClearArea();
                // no reminder found, tell the user
                string message = new SSMLBuilder().Prosody("Sorry, but I wasn't able to find a reminder for that time.", contour: "(0%,+5%) (1%,-5%) (2%,+1%) (3%,-1%) (10%,+1%) (20%,-1%) (30%,+1%) (40%,-1%) (50%,+1%) (80%,-1%)").Build();
                TextToSpeechEngine.SpeakInflectedText(this.MediaElement, message);
                this.ShowMessage("Sorry, but I wasn't able to find a reminder for that time.");
            }
        }
Ejemplo n.º 10
0
        private void DeleteAlarm()
        {
            Alarm alarmToDelete = GetAlarmForClosestMatchToPassedDate();

            if (alarmToDelete != null)
            {
                StoredProcedures.DeleteAlarm(alarmToDelete.AlarmID);
                string message = new SSMLBuilder().Prosody("Alright, cancelled your alarm.", contour: "(0%, +5%) (10%,-5%) (50%,+1%) (80%,+5%)").Build();
                TextToSpeechEngine.SpeakInflectedText(this.MediaElement, message);
                ShowMessage($"Successfully deleted alarm {alarmToDelete.Title}");
            }
            else
            {
                this.ClearArea();
                // no alarm found, tell the user
                string message = new SSMLBuilder().Prosody("Sorry, but I wasn't able to find an alarm for that time.", contour: "(0%,+5%) (1%,-5%) (2%,+1%) (3%,-1%) (10%,+1%) (20%,-1%) (30%,+1%) (40%,-1%) (50%,+1%) (80%,-1%)").Build();
                TextToSpeechEngine.SpeakInflectedText(this.MediaElement, message);
                this.ShowMessage("Sorry, but I wasn't able to find an alarm for that time.");
            }
        }
Ejemplo n.º 11
0
        public override void PerformAction()
        {
            // pick 2 actions that bob can do and recommend them.
            Random random          = new Random();
            string firstSuggestion = AvailableActions[random.Next(0, AvailableActions.Count)];
            string secondSuggestion;

            // a body-less while loop that keeps picking a suggestion until it's not the first suggestion
            while ((secondSuggestion = AvailableActions[random.Next(0, AvailableActions.Count)]) == firstSuggestion)
            {
                ;
            }
            this.ClearArea();
            string text     = $"My list of skills is growing, but right now some things I can do are {firstSuggestion}, and {secondSuggestion}";
            string ssmlText = new SSMLBuilder().Prosody(text, contour: "(5%, +10%) (20%, -5%) (60%, -5%)").Build();

            // our media element will be set in the call of PerformAction(mediaElement, dynamicArea, ssmlText)
            TextToSpeechEngine.SpeakInflectedText(this.MediaElement, ssmlText);
            this.ShowMessage(text);
        }
Ejemplo n.º 12
0
        private async Task <Reminder> NewReminderAsync()
        {
            Reminder createdReminder = await this.CreateReminderAsync();

            // if the reminder is null, then don't do anything
            if (createdReminder != null)
            {
                // insert the reminder into the database
                StoredProcedures.CreateReminder(createdReminder.Title, createdReminder.ActivateDateAndTime, createdReminder.Description);
                // schedule a toast notification for the reminder
                AlarmAndReminderHelper.ScheduleReminder(StoredProcedures.QueryLatestReminder());
                string mainPart    = $"Alright, reminder set for ";
                string datePart    = createdReminder.ActivateDateAndTime.ToString("MMM d");
                string timePart    = createdReminder.ActivateDateAndTime.ToString("h:mm tt");
                string rawSSML     = new SSMLBuilder().Add(mainPart).SayAs(datePart, SSMLBuilder.SayAsTypes.DATE).Add(" at ").SayAs(timePart, SSMLBuilder.SayAsTypes.TIME).BuildWithoutWrapperElement();
                string prosodySSML = new SSMLBuilder().Prosody(rawSSML, pitch: "+5%", contour: "(10%,+5%) (50%,-5%) (80%,-5%)").Build();
                TextToSpeechEngine.SpeakInflectedText(this.MediaElement, prosodySSML);
            }

            return(createdReminder);
        }
Ejemplo n.º 13
0
 public override void PerformAction()
 {
     this.ClearArea();
     this.CommandString = this.CommandString.ToLower();
     if (this.CommandString.Contains("time"))
     {
         string time = DateTime.Now.ToString("h:mm tt");
         string text = $"Currently, it is {time}";
         string ssml = new SSMLBuilder().Prosody(text, contour: "(20%, +8%) (60%,-8%) (80%, +2%)").Build();
         TextToSpeechEngine.SpeakInflectedText(this.MediaElement, ssml);
         this.ShowMessage(text);
     }
     else if (this.CommandString.Contains("date"))
     {
         string date = DateTime.Now.ToString("MMM dd yyyy");
         string text = $"Today's date is {date}";
         string ssml = new SSMLBuilder().Prosody(text, contour: "(20%, +8%) (60%,-8%) (80%, +2%)").Build();
         TextToSpeechEngine.SpeakInflectedText(this.MediaElement, ssml);
         this.ShowMessage(text);
     }
 }
Ejemplo n.º 14
0
        private Alarm NewAlarm()
        {
            this.ClearArea();
            Alarm createdAlarm = this.CreateAlarm();

            // the alarm can be null if the user did not provide a date
            if (createdAlarm != null)
            {
                // insert the alarm into the database
                StoredProcedures.CreateAlarm(createdAlarm.Title, createdAlarm.ActivateDateAndTime);
                // schedule a toast notification for the alarm
                AlarmAndReminderHelper.ScheduleAlarm(StoredProcedures.QueryLatestAlarm());
                string mainPart    = $"Alright, alarm set for ";
                string datePart    = createdAlarm.ActivateDateAndTime.ToString("MMM d");
                string timePart    = createdAlarm.ActivateDateAndTime.ToString("h:mm tt");
                string rawSSML     = new SSMLBuilder().Add(mainPart).SayAs(datePart, SSMLBuilder.SayAsTypes.DATE).Add(" at ").SayAs(timePart, SSMLBuilder.SayAsTypes.TIME).BuildWithoutWrapperElement();
                string prosodySSML = new SSMLBuilder().Prosody(rawSSML, pitch: "+5%", contour: "(10%,+5%) (50%,-5%) (80%,-5%)").Build();
                TextToSpeechEngine.SpeakInflectedText(this.MediaElement, prosodySSML);
            }
            return(createdAlarm);
        }
Ejemplo n.º 15
0
        public override void PerformAction()
        {
            this.ClearArea();
            this.CommandString = this.CommandString.ToLower();
            string thankYouPhrase = "thank you";
            string thanks         = "thanks";

            if (this.CommandString.Contains(thankYouPhrase) || this.CommandString.Contains(thanks))
            {
                string text = "You are welcome.";
                string ssml = new SSMLBuilder().Prosody(text, contour: "(20%, +8%) (60%,-8%) (80%, +2%)").Build();
                TextToSpeechEngine.SpeakInflectedText(this.MediaElement, ssml);
                this.ShowMessage(text);
            }
            else
            {
                string text = @"I'm sorry I do not understand.";
                string ssml = new SSMLBuilder().Prosody(text, contour: "(20%, +8%) (60%,-8%) (80%, +2%)").Build();
                TextToSpeechEngine.SpeakInflectedText(this.MediaElement, ssml);
                this.ShowMessage(text);
            }
        }