public MainScreen() { InitializeComponent(); // Setup Api Stuff LoggingApiProvider loggingApiProvider = new LoggingApiProvider(); TextToSpeechApiProvider textToSpeechApiProvider = new TextToSpeechApiProvider(); // Setup Api Stuff that needs Text to speech support ProcessApiProvider processApiProvider = new ProcessApiProvider(textToSpeechApiProvider); RecognizerApiProvider p_Brain = new RecognizerApiProvider(textToSpeechApiProvider); // Setup Language Provider m_Brain = p_Brain; // HAHAHAHA science..... SetupLanguageProvider(); // Setup the Api Listing IDictionary<string, ApiProvider> apiListing = new ApiDictionary<string, ApiProvider>(); apiListing.Add("TextToSpeechApi", textToSpeechApiProvider); apiListing.Add("ProcessApi", processApiProvider); apiListing.Add("LoggingApi", loggingApiProvider); apiListing.Add("LoreiApi", m_Brain); // Setup Scripting Languages m_Brain.LoadScriptProcessor(new LuaScriptProcessor(apiListing)); m_Brain.LoadScriptProcessor(new IronPythonScriptProcessor(apiListing)); }
/************ Constructors ************/ public LuaScriptProcessor( IDictionary<string, ApiProvider> apiDictionary) { // Save pointer to Api Listing m_apiListing = apiDictionary; // Do something horrible to support old API used by Lua scripts foreach (String x in apiDictionary.Keys) { if (x == "LoreiApi") { // Grab the LoreiApi and cast it so we have access to it so we can expose the old api m_LoreiApi = (RecognizerApiProvider)apiDictionary[x]; break; } } // Setup LUA functions SetupLuaFunctions(); SetupOldLoreiApiMethods(); //Well this was much simpler than expected. this.LoadScripts(); // Setup the old grammars CreateAndLoadGrammars(); }
public AllProgramsProcessor(RecognizerApiProvider p_owner, IDictionary<string, ApiProvider> apiListing) { m_owner = p_owner; m_ProcApi = (ProcessApiProvider)apiListing["ProcessApi"]; //Get the list of programs. Returns a List with keyvalue pairs of just the shortcut name, Full path m_ListOfPrograms = GetAllShortcuts(); //Register them. RegisterAllProgramsWithLorei(m_ListOfPrograms); }
// Events private void m_Brain_StateChanged(RecognizerApiProvider sender, bool newState) { if (newState == true) { stateText.Text = "Enabled"; return; } else { stateText.Text = "Disabled"; return; } }
void m_Brain_TextReceived(RecognizerApiProvider sender, System.Speech.Recognition.SpeechRecognizedEventArgs data) { this.lastCommandLabel.Text = m_Brain.LastCommand; }