private void Start() { Advertise("VoicePub", "/hololens/audio/user_transcript", 1, out pub); voicebox = gameObject.GetComponent <TextToSpeech>(); // Activation phrase for dictation Keywords.Add("Hello", () => { ros.std_msgs.String msg = new ros.std_msgs.String("Hello!"); if (pub != null) { pub.SendMessage(msg); } voicebox.StartSpeaking("Hello"); }); Keywords.Add("record this", () => { PhraseRecognitionSystem.Shutdown(); StartBeep.Play(); dictationRecognizer.Start(); }); dictationRecognizer = new DictationRecognizer(); dictationRecognizer.DictationComplete += DictationComplete; dictationRecognizer.DictationError += DictationError; dictationRecognizer.DictationHypothesis += DictationHypothesis; dictationRecognizer.DictationResult += DictationResult; keywordRecognizer = new KeywordRecognizer(Keywords.Keys.ToArray()); keywordRecognizer.OnPhraseRecognized += KeywordRecognizer_OnPhraseRecognized; keywordRecognizer.Start(); }
// Throttles message publishing rate to a defined period, to be used within the Update function protected bool Publish <T>(RosPublisher <T> publisher, T data) where T : IRosClassInterface, new() { System.Double currTimeStamp = Time.unscaledTime; if (currTimeStamp - prevTimeStamp[publisher.name] > period[publisher.name]) { publisher.SendMessage(data); prevTimeStamp[publisher.name] = currTimeStamp; return(true); } return(false); }