using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Speech.Recognition;
namespace ConsoleApp2
{
class Program
{
static SpeechRecognitionEngine recEngine = new
SpeechRecognitionEngine();
bool keyHold = false;
static void Main(string[] args)
{
Choices commands = new Choices();
commands.Add(new string[] { "Current dollar value", "Current euro value" });
GrammarBuilder gBuilder = new GrammarBuilder();
gBuilder.Append(commands);
Grammar grammar = new Grammar(gBuilder);
recEngine.LoadGrammarAsync(grammar);
recEngine.SetInputToDefaultAudioDevice();
recEngine.RecognizeAsync(RecognizeMode.Multiple);
}
void recEngine_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
{
switch (e.Result.Text)
{
case "Current dollar value":
Console.WriteLine("10kr");
break;
case "Current euro value":
Console.WriteLine();
break;
}
}
}
}
The program is just closing on startup, and does not record my voice, I tried with putting a console.readkey();
under this line in the code recEngine.RecognizeAsync(RecognizeMode.Multiple);
. It holds the program up and did not close automatically ofc but still the program does not record my incoming voice command.
Why is this?