public override void ViewDidLoad() { base.ViewDidLoad(); ss = new AVSpeechSynthesizer(); ss.DidFinishSpeechUtterance += (object sender, AVSpeechSynthesizerUteranceEventArgs e) => { }; ss.DidStartSpeechUtterance += (object sender, AVSpeechSynthesizerUteranceEventArgs e) => { }; ss.WillSpeakRangeOfSpeechString += (object sender, AVSpeechSynthesizerWillSpeakEventArgs e) => { }; nlp = new NaturalLanguageProcessor.NaturalLanguageProcessor(); nlp.SetConfiguration(File.ReadAllText("RPRSpeechIntents.json"), File.ReadAllText("RPRScreenContexts.json")); recordButton.Enabled = false; this.pickerView.Model = new ScreensModel(this, nlp.ContextConfigurations.Select(cc => cc.Name).ToList()); speechIdleTimer = new System.Timers.Timer(3 * 1000); speechIdleTimer.Elapsed += (sender, e) => { this.stopSpeechRecognition(); speechIdleTimer.Stop(); }; }
public static void Main(string [] args) { var nlp = new NaturalLanguageProcessor.NaturalLanguageProcessor(); var intentConfigurations = JsonConvert.DeserializeObject <List <IntentConfiguration> > (File.ReadAllText("RPRSpeechIntents.json")).ToList(); var contextConfigurations = JsonConvert.DeserializeObject <List <ContextConfiguration> > (File.ReadAllText("RPRScreenContexts.json")).ToList(); nlp.SetConfiguration(intentConfigurations, contextConfigurations); while (true) { Console.WriteLine("Which screen are you in?"); string screen = Console.ReadLine(); var suggestions = nlp.GetSuggestions(screen); if (suggestions != null) { Console.WriteLine("Some things you can ask me:"); suggestions.ForEach(s => { Console.WriteLine(s); }); } else { Console.WriteLine("Sorry, I do not understand the context."); break; } Console.WriteLine("Okay, go ahead, I am listening"); string userSearch = Console.ReadLine(); var intentResult = nlp.GetMatchingIntent(userSearch); if (intentResult != null) { Console.WriteLine("Awesome, I will get it done."); Console.WriteLine("Action: " + intentResult.Action); if (intentResult.Parameters != null) { foreach (var paramter in intentResult.Parameters) { Console.WriteLine("Parameter Name: " + paramter.Key); Console.WriteLine("Parameter Values: " + string.Join(", ", paramter.Value)); } } else { Console.WriteLine("No specific parameters mentioned."); } } else { Console.Write("Sorry, I do not understand that."); } Console.ReadLine(); } }