Windows Voice Access commands programmatically

Viewed 95

Windows has API for speech recognition, it also provides system apps that perform speech recognition and execute recognised command. Is there a way/API to send commands programmatically? Text and Audio file is acceptable. But please don't suggest using virtual mic, thanks!

Clarification:

playing back audio outloud is not the way

1 Answers

Since an audio file is acceptable, you can use the text to speech API to generate speech by the entered command and save that to a file that you can pass to the speech recognition API.

    SpeechSynthesizer ss = new SpeechSynthesizer();
    ss.Volume = 100;
    ss.SelectVoiceByHints(VoiceGender.Female, VoiceAge.Adult);
    ss.SetOutputToWaveFile(@"C:\Command.wav");
    string command = Console.ReadLine();
    ss.Speak(command);

Although I have found one question talking about the quality of the file and has an answer on how to fix it, either way if it recognizes it with no issues then you don't have to deal with the quality.

Related