public static void GenerateGrammar() { var temp = new ConcurrentDictionary <string, ConcurrentList <string> >(); foreach (var command in CommandStorage.AllCommands) { ConcurrentList <string> choices; if (command.Key.Contains(" ")) { var words = command.Key.Split(' '); if (!temp.TryGetValue(words[0], out choices)) { choices = new ConcurrentList <string>(); } for (var I = 1; I < words.Length; I++) { choices.Add(words[I]); } temp.AddOrUpdate(words[0], choices); } else { if (!temp.TryGetValue(command.Key, out choices)) { choices = new ConcurrentList <string>(); } temp.AddOrUpdate(command.Key, choices); } } foreach (var single in temp) { var grammarBuilder = new GrammarBuilder(); if (single.Value.Count != 0) { grammarBuilder = new GrammarBuilder(single.Key); } var commandChoices = new Choices(); if (single.Value.Count == 0) { commandChoices = new Choices(single.Key); } else { foreach (var word in single.Value) { commandChoices.Add(word); } } grammarBuilder.Append(commandChoices); InternalSpeechRecognizer.LoadGrammar(new Grammar(grammarBuilder)); } }
private void NaturalSpeakingCheckBoxChecked(object sender, RoutedEventArgs e) { if (!_initialized) { return; } if (NaturalSpeakingCheckBox.IsChecked == null) { return; } InternalSpeechRecognizer.IsNaturalSpeaking = NaturalSpeakingCheckBox.IsChecked.Value; if (NaturalSpeakingCheckBox.IsChecked.Value) { InternalSpeechRecognizer.EnableNaturalSpeaking(); } else { InternalSpeechRecognizer.DisableNaturalSpeaking(); } }
private async void page_Loaded(object sender, RoutedEventArgs e) { await HardwareInterface.Initialize(); DisplayCmd("Double click any item in here to read its content"); DisplayCmd("Go to 'File -> Profiles' to load a profile!"); DisplayCmd("If you're new, go to the store and download one!"); try { if (sender != null && e != null) { await Task.Run(async() => { var builder = new StringBuilder(); foreach (var script in Directory.GetFiles("Scripts\\")) { var info = new FileInfo(script); var localHash = info.CreationTimeUtc.ToString(CultureInfo.InvariantCulture); var scriptName = Path.GetFileName(script); string remoteHash; try { remoteHash = await Kernel.Channel.GetScriptHashAsync(scriptName, ""); } catch { continue; } var localTime = DateTime.Parse(localHash); var remoteTime = DateTime.Parse(remoteHash); if (localTime >= remoteTime) { continue; } builder.AppendLine("New version of '" + scriptName + "' available in the store!"); if (!Directory.Exists(@"Cache\Store\")) { continue; } if (File.Exists(@"Cache\Store\" + scriptName?.Replace(".cs", ".badge"))) { File.Delete(@"Cache\Store\" + scriptName?.Replace(".cs", ".badge")); } if (File.Exists(@"Cache\Store\" + scriptName?.Replace(".cs", ".header"))) { File.Delete(@"Cache\Store\" + scriptName?.Replace(".cs", ".header")); } } if (!string.IsNullOrEmpty(builder.ToString())) { MessageBox.Show(builder.ToString()); } }); } } catch (Exception ex) { MessageBox.Show("VOTC Master Server offline. No updates could be fetched :("); IoQueue.Add(ex); } InternalSpeechRecognizer.PrepareSpeech(); if (string.IsNullOrEmpty(Kernel.FacebookAccessToken)) { return; } try { Kernel.FacebookClient = new FacebookClient(Kernel.FacebookAccessToken); dynamic friendsTaskResult = await Kernel.FacebookClient.GetTaskAsync("/me"); Kernel.FacebookName = friendsTaskResult.first_name + " " + friendsTaskResult.last_name; dynamic facebookImage = await Kernel.FacebookClient.GetTaskAsync("/me/picture?redirect=0&height=200&type=normal&width=200"); Kernel.ProfilePicture = facebookImage["data"].url; Kernel.UI.LoadImage(); } catch { //Ignored } }