I'd like to make a speech recognition software, but I always get the same error message, when I try to.
System.PlatformNotSupportedException:
I saw the same problem on stackoverflow, I installed the stuffs, but the problem is still exists. Here's my code below, and this is the stack overflow "solution", what not works for me:
PlatformNotSupportedException Using .NET Speech Recognition
Yes, I installed every mentioned stuffs...
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Speech.Recognition;
using System.Speech.Synthesis;
namespace SpeechExe
{
class ExecuteSpeech
{
SpeechRecognitionEngine sre = new SpeechRecognitionEngine();
Choices choices = new Choices();
GrammarBuilder gb = new GrammarBuilder();
private void MakeCommands()
{
string[] commantList = { "say hello" };
choices.Add(commantList);
gb.Append(choices);
Grammar grammar = new Grammar(gb);
sre.LoadGrammarAsync(grammar);
sre.SetInputToDefaultAudioDevice();
sre.SpeechRecognized += Sre_SpeechRecognized;
}
private void Sre_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
{
switch(e.Result.Text)
{
case "say hello":
Console.WriteLine("Hello!");
break;
}
}
public void Start()
{
this.MakeCommands();
sre.RecognizeAsync(RecognizeMode.Multiple);
}
}
}