5

How can I get the phonics sound by pushing any letter key? For example, I want to get the phonics sound of A by pushing the 'A' key.

I'm using Microsoft SAPI v5.1. Can you point me in the right direction please?

Alex Aza
  • 76,499
  • 26
  • 155
  • 134
user758475
  • 51
  • 3

1 Answers1

4

Add reference to System.Speech assembly.

Add using System.Speech.Synthesis;

using (var speechSynthesizer = new SpeechSynthesizer())
{
    speechSynthesizer.Speak("A");
    speechSynthesizer.Speak("B");
    speechSynthesizer.Speak("C");
}

For example like this:

using (var speechSynthesizer = new SpeechSynthesizer())
{
    while (true)
    {
        var consoleKey = Console.ReadKey();
        if (consoleKey.Key == ConsoleKey.Escape)
            break;
        var text = consoleKey.KeyChar.ToString();
        speechSynthesizer.Speak(text);
    }
}
Alex Aza
  • 76,499
  • 26
  • 155
  • 134