Basically all my app does is take command line input in the form of "option1|option2|option3" etc and then when a match is heard it responds with the zero based index of the match e.g. 0, 1, or 2 for the above. So the idea is to just pass it "What have you got for sale?|Tell me more about Maven Black Briar.|And now you die!" and when the player says one of the phrases to automatically select that choice. if the player instead wants to click the choice or uses [Tab] to exit conversation simply send a "dialogend" message and the recognition engine will stop listening until a new set of words is passed.
tl;dr Voice activation c# app just needs someone capable of hooking up to skyrim's dialog options
SkyrimVoiceRecognition [UPDATED 11/26, now listens on local port 3000]
Spoiler
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Speech.Recognition;using System.Net.Sockets;using System.Net;//Code layout is pretty awful, but I wanted to keep it to 1 file for easy compiling by othersnamespace SkyrimVoiceRecognition{ class Program { public static SpeechRecognitionEngine recognitionEngine = new SpeechRecognitionEngine(); public static Grammar current_dialog_options; private static Int32 port; private static TcpClient client; private static NetworkStream clientStream; static void Main(string[] args) { if (args.Length >= 1) port = Int32.Parse(args[0]); else port = 3000; System.Speech.Synthesis.SpeechSynthesizer speaker = new System.Speech.Synthesis.SpeechSynthesizer(); recognitionEngine.SetInputToDefaultAudioDevice(); recognitionEngine.SpeechRecognized += (s, command) => { Console.WriteLine("Heard: " + command.Result.Semantics.Value); ASCIIEncoding encoder = new ASCIIEncoding(); byte[] buffer = encoder.GetBytes(command.Result.Semantics.Value.ToString()); if (client.Connected) { clientStream.Write(buffer, 0, buffer.Length); clientStream.Flush(); } }; TcpListener tcpListener = new TcpListener(IPAddress.Parse("127.0.0.1"), port); tcpListener.Start(); while(true){ Console.WriteLine("Listening for Skyrim on " + tcpListener.LocalEndpoint); client = tcpListener.AcceptTcpClient(); clientStream = client.GetStream(); Console.WriteLine("Skyrim Connected"); HandleClientComm(); } } public static void setOptions(String[] dialog_options) { recognitionEngine.RecognizeAsyncStop(); if (current_dialog_options != null) recognitionEngine.UnloadGrammar(current_dialog_options); Choices c = new Choices(); for (int i = 0; i < dialog_options.Length; i++) { c.Add(new SemanticResultValue(dialog_options[i], i)); } current_dialog_options = new Grammar(c); recognitionEngine.LoadGrammar(current_dialog_options); recognitionEngine.RecognizeAsync(RecognizeMode.Multiple); } private static void HandleClientComm() { byte[] message = new byte[4096]; int bytesRead; String line; while (true) { bytesRead = 0; try { //blocks until a client sends a message bytesRead = clientStream.Read(message, 0, 4096); } catch(Exception e) { break; } if (bytesRead == 0) { break; } //message has successfully been received ASCIIEncoding encoder = new ASCIIEncoding(); line = encoder.GetString(message, 0, bytesRead); Console.WriteLine("Skyrim: " + line); if (line.Equals("dialogend")) Program.recognitionEngine.RecognizeAsyncStop(); else Program.setOptions(line.Split('|')); } client.Close(); Console.WriteLine("Skyrim Disconnected"); Program.recognitionEngine.RecognizeAsyncStop(); } }}
.