Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Text-to-speech using Phonics Sounds

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?

like image 538
user758475 Avatar asked Oct 11 '22 00:10

user758475


1 Answers

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);
    }
}
like image 186
Alex Aza Avatar answered Oct 15 '22 10:10

Alex Aza