Ejemplo n.º 1
0
 private static void AddDomainSpecificCommands(Machine machine)
 {
     machine.Context.AddWord10("say", "Speak given string", s => speech.Say(s));
     machine.Context.AddWord20("phrase", "Add phrase to speech recognition grammar; bind to Brief expression (`phrase 'hello [say \"hi there\"]`)", (p, b) => speechCommands.Add(p, b));
     machine.Context.AddWord00("speechreco", "Start speech recognition, after having added `phrase` bindings (`reco`)", () => speech.SetGrammar(Speech.Choices(speechCommands.Select(kv => Speech.Phrase(kv.Key, Brief.Print(kv.Value))).ToArray())));
     machine.Context.AddWord20("window", "Show window in foreground by process name; optionally maximized (`window \"Skype\" true`)", (n, m) => Windows.ShowWindow(n, m));
     machine.Context.AddWord10("key", "Send key to forground app (`key '^{q}`)", k => Windows.SendKey(k));
     machine.Context.AddWord20("config", "Set configuration value (`config 'port 80`)", (k, v) => config[k] = v is IEnumerable <Word>?Brief.Print(v) : v.ToString());
     machine.Context.AddWord00("faces-train", "Create and train faces in Azure Cognitive Services (`faces-train \"myfaces/\")`", () => faces.TrainFaces());
     machine.Context.AddWord10("faces-reco", "Recognize faces in given image file (`faces-reco \"test.jpg\"`)", f => faces.RecoFaces((string)f, true));
     machine.Context.AddWord20("faces-watch", "Begin watching given directory and children for face images [debug mode optional] (`faces-watch \"c:/test\"` true)", (dir, debug) => WatchFaces(dir, debug, machine));
     machine.Context.AddWord10("nav", "Send relay to given place (`nav \"booth\"`)", p => Goto(p, config["relayQueueName"]));
     machine.Context.AddWord10("tour", "Send relay to given places (`tour [\"booth\",\"foo\",\"bar\"]`)", p => Wander(((IEnumerable <Word>)p).Reverse().Select(n => n.ToString()), config["relayQueueName"]));
     machine.Context.AddWord00("stop", "Stop relay by canceling previous task (`stop`)", () => Stop(config["relayQueueId"], false));
     machine.Context.AddWord00("cancel", "Cancel current task (`cancel`)", () => Stop(config["relayQueueId"], true));
 }