Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8394051
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T19:57:52+00:00 2026-06-09T19:57:52+00:00

This is a Microsoft speech api related questions: The idea it’s that when SpeechSynthesizer

  • 0

This is a Microsoft speech api related questions:

The idea it’s that when SpeechSynthesizer triggers SpeakStarted event, I would like to know what the SpeechSynthesizer is going to say within this event. So I can synchronize the speech and GUI display.

Code:

SpeechSynthesizer _reader = new SpeechSynthesizer();


_reader.SpeakStarted += new EventHandler<SpeakStartedEventArgs>(_reader_SpeakStarted);


  void _reader_SpeakStarted(object sender, SpeakStartedEventArgs e)
        {
            // now _speak started!
            Console.WriteLine("_reader_SpeakStarted\t" + e.ToString());
           // string textContent=????
          //  updateGUI(textContent);

        }


_reader.SpeakAsync("Hello world A B C"); //asynchronize method!!!
_reader.SpeakAsync("Hello world B C D");
_reader.SpeakAsync("Hello world C D E");

Problem:

Within SpeakStarted event one couldn’t tell the text content to be spoken.

It’s weird that the “Hello world x x x” does appear in the arguments, if you put a break point there, but there is no way to access it.

If someone could kindly help me, I would very much appreciate it.

.Net 4, windows 7 64 bits, VS2010

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T19:57:53+00:00Added an answer on June 9, 2026 at 7:57 pm

    The prompt object doesn’t always contain text which is why it is not exposed as a public property. The same object can also be constructed using marker-up or an audio file. The best way do execute this would be to store the values you are passing into the SpeakAsync method as global arguments which can be passed into the UI when you want to display them.

    private static string _spokenWords;

        static void Main(string[] args)
        {
    
            SpeechSynthesizer _reader = new SpeechSynthesizer();
    
            _reader.SpeakStarted += ReaderSpeakStarted;
    
            _spokenWords = "Hello world A B C";
            _reader.SpeakAsync(_spokenWords); //asynchronize method!!! 
    
    
        }
    
    
        static void ReaderSpeakStarted(object sender, SpeakStartedEventArgs e)
        {
            // now _speak started! 
            Console.WriteLine("_reader_SpeakStarted\t" + _spokenWords);
    
            // string textContent=???? 
            //  updateGUI(textContent); 
    

    You can also look at using reflection to break out the private text field in the prompt object to access the value. Although this is going to be more resource intensive and not necessarily as stable:

    static void Main(string[] args)
    {

            SpeechSynthesizer _reader = new SpeechSynthesizer();
    
            _reader.SpeakStarted += ReaderSpeakStarted;
    
            _reader.SpeakAsync("Hello world A B C"); //asynchronize method!!! 
            _reader.SpeakAsync("Hello world B C D"); 
            _reader.SpeakAsync("Hello world C D E"); 
    
        }
    
    
        static void ReaderSpeakStarted(object sender, SpeakStartedEventArgs e)
        {
            // now _speak started! 
            var spokenWord = GetTextFieldValue(e.Prompt);
            Console.WriteLine("_reader_SpeakStarted\t" + spokenWord);
    
            // string textContent=???? 
            //  updateGUI(textContent); 
    
        }
    
        private static string GetTextFieldValue(Prompt p)
        {
            var text = typeof(Prompt).GetField("_text", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(p);
            return (string)(text.GetType() == typeof(String) ? text : string.Empty);
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've spotted this question: Does Microsoft SkyDrive have an API? But not having an
I have used code like this: http://msdn.microsoft.com/en-us/library/dw70f090.aspx to access database before when working in
This Microsoft support page shows that there is no Win32 equivalent to C Run-Time's
For a simple sql-server update trigger, I may write a class like this: [Microsoft.SqlServer.Server.SqlTrigger
I am open and close an excel book fro mC# like this Microsoft.Office.Interop.Excel.Application oXL
So, I took some code from this Microsoft provided Example which allows me to
Im having trouble understanding this : why Microsoft put Xattribute under Xobject ? they
This article from Microsoft details how to implement transport security with an anonymous client
I'm usng this: http://schemas.microsoft.com/cdo/configuration/smtpauthenticate The schema is down? My software doesn't work anymore. Gives
You may know this recommendation from Microsoft about the use of exceptions in .NET:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.