Пример #1
0
 private int GenerateRandomNumber(int lowerBound, int upperBound)
 {
     // get the actual upper and lower bounds (the user could have put the higher number first, but they could also have put it last so we need to figure out which it is)
     if (lowerBound > upperBound)
     {
         var temp = lowerBound;
         lowerBound = upperBound;
         upperBound = temp;
     }
     // if the user said "exclusive", move the lower bound up and the upper bound down
     if (this.CommandString.ToLower().Contains("exclusive"))
     {
         lowerBound++;
         upperBound--;
     }
     // make sure the upper bound is greater than the lower bound
     if (upperBound == lowerBound)
     {
         TextToSpeechEngine.SpeakText(this.MediaElement, $"Sorry, but I can't pick a whole number between {lowerBound} and {upperBound}");
         throw new ArgumentException();
     }
     else
     {
         return(new Random().Next(lowerBound, upperBound));
     }
 }
Пример #2
0
        private async Task <string> GetReminderTitleAsync()
        {
            string title = "";
            var    titleIdentifierRegex = new Regex("(?<=(named |called |titled )).+");
            var    match = titleIdentifierRegex.Match(this.CommandString);

            if (match.Success)
            {
                title = match.Value;
            }
            else
            {
                // ask the user to give a title if listening is enabled, else tell the user to retry with a title
                if (Utils.IsListeningSettingEnabled())
                {
                    TextToSpeechEngine.SpeakText(this.MediaElement, "Sure, what's the title of the reminder?");
                    await SpeechRecognitionManager.RequestListen(this.GetType(), (text) => title = text);
                }
                else
                {
                    // title should be null, which will be used in the calling method to tell the user that title is required
                    title = null;
                }
            }
            return(title);
        }
Пример #3
0
        public async override void PerformAction()
        {
            CommandString = CommandString.ToUpper();
            string strDestination = "";

            if (CommandString.Contains(" TO "))
            {
                strDestination = CommandString.Substring(CommandString.IndexOf(" TO ") + 4);
            }
            else
            {
                // have bob ask the user where they want to go
                TextToSpeechEngine.SpeakText(this.MediaElement, "Sure, where do you want to go?");
                // sleep the thread to give bob enough time to speak
                if (!await SpeechRecognitionManager.RequestListen(this.GetType(), (text) =>
                {
                    strDestination = text;
                    GetDirections(text);
                }))
                {
                    string message = "Sorry, but something went wrong. To get directions, say \"Hey Bob, how do I get to thePlace\"";
                    TextToSpeechEngine.SpeakText(this.MediaElement, message);
                    this.ShowMessage(message);
                }
                else
                {
                    ProvideDirectionsSuccessMessage(strDestination);
                }
            }
            if (StringUtils.IsNotBlank(strDestination))
            {
                GetDirections(strDestination);
                ProvideDirectionsSuccessMessage(strDestination);
            }
        }
Пример #4
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);
            }
        }
Пример #5
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"));
            }
        }
Пример #6
0
        private async Task <Reminder> CreateReminderAsync()
        {
            this.ClearArea();
            Reminder createdReminder = new Reminder();
            DateTime?dateTime        = this.GetReminderDateAndTime();

            // if the date is null, then we need to tell the user that a date and time is required
            if (dateTime != null)
            {
                string title = await this.GetReminderTitleAsync();

                if (title == null)
                {
                    string message = "Sorry, but reminders require a title. If you don't need a title, try setting an alarm instead.";
                    TextToSpeechEngine.SpeakText(this.MediaElement, message);
                    this.ShowMessage(message);
                    createdReminder = null;
                }
                else
                {
                    // description can't be easily input with text, so don't set it
                    createdReminder.Title = title;
                    createdReminder.ActivateDateAndTime = dateTime.Value;
                }
            }
            else
            {
                // tell the user that a date is needed, and set the alarm to null so the calling code can handle it
                var message = "Sorry, but to create a reminder I need a date and time to set the reminder off at. Please try again.";
                TextToSpeechEngine.SpeakText(this.MediaElement, message);
                this.ShowMessage(message);
                createdReminder = null;
            }
            return(createdReminder);
        }
 public SystemVoice(VoiceInfo voice, TextToSpeechEngine parent) : base(parent)
 {
     _voice  = voice;
     Name    = _voice.Name;
     Gender  = _voice.Gender;
     Age     = _voice.Age;
     Culture = _voice.Culture.Name;
 }
Пример #8
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);
        }
Пример #9
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);
        }
Пример #10
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);
        }
Пример #11
0
        public override void PerformAction()
        {
            Joke joke = StoredProcedures.QueryRandomJoke();

            this.ClearArea();
            if (joke != null)
            {
                TextToSpeechEngine.SpeakText(this.MediaElement, joke.Text);
                this.ShowMessage(joke.Text);
            }
        }
Пример #12
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();
     }
 }
Пример #13
0
 private async void RequestMicrophoneAcessIfUserWantsVoiceDetection()
 {
     if (Utils.IsListeningSettingEnabled())
     {
         if (await AudioCapturePermissions.RequestMicrophonePermission())
         {
             SpeechRecognitionManager.StartListeningForMainPage(performActionFromCommandBoxText, this.CommandBox);
         }
         else
         {
             TextToSpeechEngine.SpeakText(this.media, "Sorry, but something went wrong with setting up your microphone. You cannot use me through speech, but you can still use the command bar at the bottom of the screen.");
         }
     }
 }
Пример #14
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);
        }
Пример #15
0
        private void FlipCoin()
        {
            // coins are always 2-sided, so pick a random number and associate it with heads or tails
            int    side     = new Random().Next(2);
            string sideName = side == 0 ? "Heads" : "Tails";
            string text     = $"It landed on {sideName}";

            AudioPlayer.PlaySound("coin_flip", () =>
            {
                Utils.RunOnMainThread(() =>
                {
                    TextToSpeechEngine.SpeakText(this.MediaElement, text);
                    this.ShowMessage(sideName);
                });
            });
        }
Пример #16
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);
            }
        }
Пример #17
0
 /// <summary>
 /// should only be called after <see cref="StartListeningForMainPage(Action{string}, TextBox)"/> has been called since the main page was navigated to
 /// </summary>
 private static void StartListeningForMainPage()
 {
     if (Utils.IsListeningSettingEnabled())
     {
         if (MainPageFunction != null && MainPageTextBox != null)
         {
             // the main page takes priority over everything when it comes to listening, so force stop
             SpeechRecognitionUtils.Stop();
             CurrentListener       = typeof(MainPage);
             IsCurrentListenerDone = false;
             SpeechRecognitionUtils.StartLooping(MainPageFunction, MainPageTextBox);
         }
     }
     else
     {
         TextToSpeechEngine.SpeakText(new MediaElement(), "Sorry, but something went wrong with setting up your microphone. You cannot use me through speech, but you can still use the command bar at the bottom of the screen.");
     }
 }
Пример #18
0
        public override async void PerformAction()
        {
            Action <string> repeatAction = (text) =>
            {
                this.ClearArea();
                TextToSpeechEngine.SpeakText(this.MediaElement, $"{text}");
                this.ShowMessage($"You said {text}");
            };
            var executedSuccessfully = await SpeechRecognitionManager.RequestListen(this.GetType(), repeatAction);

            if (!executedSuccessfully)
            {
                this.ClearArea();
                string message = "Something went wrong with listening to you, so I cannot repeat after you. Do you have voice activation set to off in the app settings or system settings?";
                TextToSpeechEngine.SpeakText(this.MediaElement, message);
                this.ShowMessage(message);
            }
        }
Пример #19
0
        private async void ProvideDirectionsSuccessMessage(string destination)
        {
            // show a link to the search
            this.ClearArea();
            var linkElement = new HyperlinkButton();

            linkElement.Content = $"Directions to {destination.ToLower()}";
            string directionsLink = await GetDirectionsLink(destination);

            if (directionsLink != null)
            {
                linkElement.NavigateUri = new Uri(directionsLink);
                linkElement.FontSize    = 24;
                RelativePanel.SetAlignHorizontalCenterWithPanel(linkElement, true);
                RelativePanel.SetAlignVerticalCenterWithPanel(linkElement, true);
                this.DynamicArea.Children.Add(linkElement);
                TextToSpeechEngine.SpeakText(this.MediaElement, $"Alright, getting {linkElement.Content.ToString().ToLower()}");
            }
        }
Пример #20
0
        public override void PerformAction()
        {
            //get list of searchable websites from database
            List <SearchableWebsite> allSearchableWebsites = StoredProcedures.QueryAllSearchableWebsites();
            //need to check if user provided a website to search
            bool isUserProvidedWebsiteSearch = false;

            //go through list of searchable websites. return true if user included the searchable website in search
            //this will also set the website if there is a match
            isUserProvidedWebsiteSearch = GetActionFromCommand(allSearchableWebsites);
            string searchParameters;
            string searchQuery;

            if (isUserProvidedWebsiteSearch)
            {
                //find what is wanted to be searched and concatenate with + for end of url
                searchParameters = GetSearchParameters(isUserProvidedWebsiteSearch);
                searchQuery      = BuildSearchQuery(desiredSearchableWebsite, searchParameters);
                //launch browser. this will be done with the default browser
                LaunchSearch(searchQuery);
            }
            else
            {
                //sets desiredSearchEngine, which is the default selected in settings
                GetDefaultSearchEngine();
                searchParameters = GetSearchParameters(isUserProvidedWebsiteSearch);
                searchQuery      = BuildSearchQuery(desiredSearchEngine, searchParameters);
                //launch browser. this will be done with the default browser
                LaunchSearch(searchQuery);
            }
            // show a link to the search
            this.ClearArea();
            var linkElement = new HyperlinkButton();

            linkElement.Content     = $"{searchParameters} on {(desiredSearchableWebsite != null ? desiredSearchableWebsite.Name : desiredSearchEngine?.Name)}";
            linkElement.NavigateUri = new Uri(searchQuery);
            linkElement.FontSize    = 24;
            RelativePanel.SetAlignHorizontalCenterWithPanel(linkElement, true);
            RelativePanel.SetAlignVerticalCenterWithPanel(linkElement, true);
            this.DynamicArea.Children.Add(linkElement);
            // announce to the user that we're searching for something
            TextToSpeechEngine.SpeakText(this.MediaElement, $"Sure, searching for {linkElement.Content}");
        }
Пример #21
0
        public TtsForm()
        {
            InitializeComponent();

            player = new WavePlayer();
            player.ProgressChanged += player_ProgressChanged;

            this.config          = new TtsConfig();
            config.ServerUrl     = "dev.voicecloud.cn";
            config.ApplicationId = "518fcbd0";
            config.Timeout       = 10000;
            config.MaxTextSize   = 4096;
            tts = new TextToSpeechEngine(this.config);
            tts.AudioReceived   += tts_AudioReceived;
            tts.ProgressChanged += tts_ProgressChanged;

            btnSpeakText.Click       += btnSpeakText_Click;
            btnSpeakFormatText.Click += btnSpeakFormatText_Click;
        }
Пример #22
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);
        }
Пример #23
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.");
            }
        }
Пример #24
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.");
            }
        }
Пример #25
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);
        }
Пример #26
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);
        }
Пример #27
0
        private Alarm CreateAlarm()
        {
            Alarm    createdAlarm = new Alarm();
            DateTime?dateTime     = this.GetAlarmDateAndTime();

            if (dateTime != null)
            {
                string title = this.FindAlarmTitle();
                createdAlarm.Title = title;
                createdAlarm.ActivateDateAndTime = dateTime.Value;
            }
            else
            {
                // tell the user that a date is needed, and set the alarm to null so the calling code can handle it
                var message = "Sorry, but to create an alarm I need a date and time to set the alarm off at. Please try again.";
                TextToSpeechEngine.SpeakText(this.MediaElement, message);
                this.ShowMessage(message);
                createdAlarm = null;
            }
            return(createdAlarm);
        }
Пример #28
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);
     }
 }
Пример #29
0
        public override void PerformAction()
        {
            this.ClearArea();
            types type = GetTypeFromCommand();

            if (type == types.DICE)
            {
                this.RollDie();
            }
            else if (type == types.COIN)
            {
                this.FlipCoin();
            }
            else if (type == types.NUMBER)
            {
                this.PickRandomNumber();
            }
            else
            {
                TextToSpeechEngine.SpeakText(this.MediaElement, "Sorry, but something went wrong and I couldn't pick a random number for you");
            }
        }
Пример #30
0
        private void RollDie()
        {
            // the first number we come across is the number of sides the die has, if we don't come across a number we default it to 6 sides
            string numberOfSides   = new Regex("[0-9]+").Match(this.CommandString).Value;
            int    parsedSideCount = 6;

            if (numberOfSides != "")
            {
                parsedSideCount = int.Parse(numberOfSides);
            }
            // pick the random number with the range [1, numberOfSides]
            int pickedSide = new Random().Next(1, parsedSideCount + 1);

            AudioPlayer.PlaySound("die_roll", () =>
            {
                Utils.RunOnMainThread(() =>
                {
                    TextToSpeechEngine.SpeakText(this.MediaElement, $"You rolled a {pickedSide}");
                    this.ShowMessage(pickedSide.ToString());
                });
            });
        }
 public SystemVoice(VoiceInfo voice, TextToSpeechEngine parent)
     : base(parent)
 {
     _voice = voice;
     Name = _voice.Name;
     Gender = _voice.Gender;
     Age = _voice.Age;
     Culture = _voice.Culture.Name;
 }