コード例 #1
0
ファイル: AgeAction.cs プロジェクト: ploiu/Bob
        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);
            }
        }
コード例 #2
0
ファイル: WeatherAction.cs プロジェクト: strongr787/Capstone
        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"));
            }
        }
コード例 #3
0
        public void ToStringTest()
        {
            SSMLBuilder builder = new SSMLBuilder("Hello");
            string      text    = builder.AddSpeak().AddParagraph().ToString();

            Assert.AreEqual("<speak><p>Hello</p></speak>", text);
        }
コード例 #4
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);
        }
コード例 #5
0
ファイル: MainPage.xaml.cs プロジェクト: ploiu/Bob
        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);
        }
コード例 #6
0
ファイル: GreetingAction.cs プロジェクト: ploiu/Bob
        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);
        }
コード例 #7
0
ファイル: WeatherAction.cs プロジェクト: strongr787/Capstone
        /// <summary>
        /// enforces spoken sentence structure in weather description by wrapping all the sentences in an ssml &lt;sentence&gt; tag. This prevents the text to speech engine from misreading a sentence (e.g. 45mph. will not be counted as a sentence because it thinks the period is used in an abbreviation)
        /// </summary>
        /// <param name="weatherDescription">the string to split into forced sentences</param>
        /// <returns></returns>
        private string SplitWeatherDescUpIntoSSMLSentences(string weatherDescription)
        {
            string ssmlDescription = "";

            string[] descriptionSentences = weatherDescription.Split(".");
            foreach (string sentence in descriptionSentences)
            {
                ssmlDescription += new SSMLBuilder().Sentence(sentence + ".").BuildWithoutWrapperElement();
            }

            return(ssmlDescription);
        }
コード例 #8
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();
     }
 }
コード例 #9
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);
        }
コード例 #10
0
ファイル: MainPage.xaml.cs プロジェクト: ploiu/Bob
        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);
            }
        }
コード例 #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);
        }
コード例 #12
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.");
            }
        }
コード例 #13
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.");
            }
        }
コード例 #14
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);
        }
コード例 #15
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);
        }
コード例 #16
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);
     }
 }
コード例 #17
0
ファイル: ThankYouAction.cs プロジェクト: ploiu/Bob
        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);
            }
        }
コード例 #18
0
ファイル: AlexaController.cs プロジェクト: S3P/alexa
        private string GetResponseString(string intentString)
        {
            string      text    = "";
            SSMLBuilder builder = null;

            switch (intentString)
            {
            case "WhathappenedIntent":
                builder = new SSMLBuilder("It was a good evening.");
                text    = builder.AddParagraph().ToString();
                builder = new SSMLBuilder("40 orders arrived, for a total amount of 1900 Euro.");
                text    = text + builder.AddParagraph().ToString();
                builder = new SSMLBuilder(text);
                text    = builder.AddParagraph().ToString();
                return(text);

            case "AvailableStockIntent":
                builder = new SSMLBuilder("No, there is insufficient stock to deliver 5 of them. Do you want to delay delivery or place a rush order at one of your suppliers?");
                text    = builder.AddParagraph().ToString();
                return(text);

            case "ScoreIntent":
                builder = new SSMLBuilder("Your current score on eBay is 83%, and your target is 90%.");
                text    = builder.AddParagraph().ToString();
                return(text);

            case "QuickerDeliveryIntent":
                builder = new SSMLBuilder("Supplier BCC can deliver the items today, before noon.");
                text    = builder.AddParagraph().ToString();
                return(text);

            case "PurchaseIntent":
                builder = new SSMLBuilder("OK, purchase order to BCC was sent. Expected delivery is at noon today");
                text    = builder.AddParagraph().ToString();
                return(text);

            case "ThanksIntent":
                builder = new SSMLBuilder("By the way don't forget Today is Carina's birthday.");
                text    = builder.AddParagraph().ToString();
                return(text);

            case "CustomerUpdateIntent":
                var amounts = GetAmounts();
                builder = new SSMLBuilder(string.Format(GetNotes() + "They owe you {0} Euros, of which {1} Euros is late", amounts.d.results[0].TotalAmount, amounts.d.results[0].AgeGroup2Amount));
                text    = builder.AddParagraph().ToString();
                return(text);

            case "ShowCashflowIntent":
                builder = new SSMLBuilder("OK, Done.");
                text    = builder.AddParagraph().ToString();
                return(text);

            case "ShowSalesTrendIntent":
                builder = new SSMLBuilder("OK, Done.");
                text    = builder.AddParagraph().ToString();
                return(text);

            case "SetReminderIntent":
                builder = new SSMLBuilder("OK, reminder set to tell Baker Electronics about audio cables.");
                text    = builder.AddParagraph().ToString();
                return(text);

            default:
                return("The command is not correct please try again!");
            }
        }
コード例 #19
0
        public void TestNoOptionsBuildsSpeakElement()
        {
            string builtText = new SSMLBuilder().Build();

            Assert.AreEqual("<speak version='1.0' xmlns='http://www.w3.org/2001/10/synthesis' xml:lang='en-US'></speak>", builtText);
        }
コード例 #20
0
        public void TestSentenceCreatesSentenceElement()
        {
            string builtText = new SSMLBuilder().Sentence("test").Build();

            Assert.IsTrue(builtText.Contains("<sentence>test</sentence>"));
        }