public override void Speak(SpeechClient.Speech speech)
        {
            try
            {
                PromptBuilder p = new PromptBuilder();
                p.Culture = tts.Voice.Culture;
                p.StartVoice(p.Culture);
                p.StartSentence();

                p.StartStyle(new PromptStyle(PromptEmphasis.None));
                for (int i = 0; i < speech.Text.Length; i++)
                {
                    if (speech.Bookmarks == null || speech.Bookmarks.Length < i + 1 || speech.Bookmarks[i]=="")
                    {
                        string s = "";
                        for (; i < speech.Text.Length; i++) s += speech.Text[i] + " ";
                        p.AppendSsmlMarkup(s);
                        break;
                    }
                    else
                    {
                        p.AppendSsmlMarkup(speech.Text[i]);
                        p.AppendBookmark(speech.Bookmarks[i]);
                    }
                }
                p.EndStyle();
                p.EndSentence();
                p.EndVoice();
                currentSpeech = speech;
                if (speech.Id != "") ids.Add(tts.SpeakAsync(p), speech.Id);
                else tts.SpeakAsync(p);
                
            }
            catch (Exception e)
            {
                Console.WriteLine("WindowsTTS Failed: " + e.Message);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Sends the string to the speech syncth to speak
        /// async. Returns a bookmark. When the bookmark is
        /// reached, an event raised.
        /// </summary>
        /// <param name="text">String to convert</param>
        /// <param name="bookmark">returns bookmark</param>
        /// <returns>true on success</returns>
        public bool SpeakAsync(String text, out int bookmark)
        {
            bool retVal = true;

            bookmark = _nextBookmark++;
            try
            {
                if (!IsMuted())
                {
                    var promptBuilder = new PromptBuilder();
                    promptBuilder.AppendText(replaceWithAltPronunciations(text));
                    promptBuilder.AppendBookmark(bookmark.ToString());

                    Synthesizer.SpeakAsync(promptBuilder);
                }
            }
            catch (Exception ex)
            {
                Log.Debug(ex.ToString());
                retVal = false;
            }

            return(retVal);
        }
Esempio n. 3
0
        /// <summary>
        /// Sends the string to the speech syncth to speak
        /// async. Returns a bookmark. When the bookmark is
        /// reached, an event raised.
        /// </summary>
        /// <param name="text">String to convert</param>
        /// <param name="bookmark">returns bookmark</param>
        /// <returns>true on success</returns>
        public bool SpeakAsync(String text, out int bookmark)
        {
            bool retVal = true;

            bookmark = _nextBookmark++;
            try
            {
                if (!IsMuted())
                {
                    var promptBuilder = new PromptBuilder();
                    promptBuilder.AppendText(replaceWithAltPronunciations(text));
                    promptBuilder.AppendBookmark(bookmark.ToString());

                    Synthesizer.SpeakAsync(promptBuilder);
                }
            }
            catch (Exception ex)
            {
                Log.Debug(ex.ToString());
                retVal = false;
            }

            return retVal;
        }