-1

How to create C# code that would allow my computer to speak english words that would be based on text provided by the system?

1
  • I'm not quite sure what you are asking. Are you trying to do text-to-speech? Commented Oct 26, 2011 at 2:28

2 Answers 2

5

Text-to-speech is built into the .Net Framework 4 without needing to reference any external .dlls, using the System.Speech.Synthesis.SpeechSynthesizer class. It doesn't sound that great on XP, but better on Vista and 7. It's simple to use too:

using (SpeechSynthesizer synth = new SpeechSynthesizer()) { synth.Speak("hello"); } 
Sign up to request clarification or add additional context in comments.

Comments

2

you can try to use this code of mine.

public static class Melodie { private static SpeechLib.SpVoice WomenAgent = new SpeechLib.SpVoice(); public static void AnnounceRestrictionOfAccount() { WomenAgent.Speak("You're account has been block by the system security", SpeechLib.SpeechVoiceSpeakFlags.SVSFDefault); } public static void SayGoodBye() { WomenAgent.Speak("Goodbye!"); } public static void WelcomeUser(User userToBeWelcomed) { string Salutation = ConstructWelcomeSpeech(userToBeWelcomed); WomenAgent.Speak(Salutation); } private static string ConstructWelcomeSpeech(User user) { string salutation = "Welcome "; if (user.Gender == "Male") { salutation += " Mr. "; } else if (user.Gender == "Female") { if (user.CivilStatus != null) { if (user.CivilStatus == "Single") salutation += " Ms. "; else salutation += " Mrs. "; } } salutation += user.FirstName + " " + user.LastName; return salutation; } public static void AnnounceMessage(string message) { WomenAgent.Speak(message); } } 

and you can read more about SpeechLib in MSDN.

another thing you should also include Microsoft speech lib 5.0 as a reference in you're project. :)

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.