/// <summary> /// Handle word detected event /// </summary> /// <param name="sender"></param> /// <param name="args"></param> void WordDetectedHandler(object sender, WordDetection.WordEventArgs args) { // skip detection while recording if (m_recordingSample) { return; } if (null == args.Details || string.IsNullOrEmpty(args.Details.Label)) { m_command = "Noise"; } else { m_command = args.Details.Label; if (m_command != "Noise") { m_timerClearMic = DateTime.Now + TimeSpan.FromMilliseconds(200); if (m_command == WordDetectionInput.KEY_FORWARD) { WordDetectionInput.TimerDetection[m_command.ToUpper()] = DateTime.Now + TimeSpan.FromMilliseconds(1500f); } else { WordDetectionInput.TimerDetection[m_command.ToUpper()] = DateTime.Now + TimeSpan.FromMilliseconds(200f); } } } }
// FUNGSI-FUNGSI ECKY // Handler untuk event word detection void WordDetectedHandler(object sender, WordDetection.WordEventArgs args) { if (string.IsNullOrEmpty(args.Details.Label)) { return; } //Debug.Log(string.Format("Detected: {0}", args.Details.Label)); }
/// <summary> /// Handle word detected event /// </summary> /// <param name="sender"></param> /// <param name="args"></param> void WordDetectedHandler(object sender, WordDetection.WordEventArgs args) { if (null == args.Details || string.IsNullOrEmpty(args.Details.Label)) { m_command = Commands.Noise; return; } m_command = (Commands)Enum.Parse(typeof(Commands), args.Details.Label, false); PlayAnimation(GetStateName(m_command)); }
/// <summary> /// Handle word detected event /// </summary> /// <param name="sender"></param> /// <param name="args"></param> void WordDetectedHandler(object sender, WordDetection.WordEventArgs args) { // skip detection while recording if (m_recordingSample) { return; } if (null == args.Details || string.IsNullOrEmpty(args.Details.Label)) { m_command = Commands.Noise; return; } m_command = (Commands)Enum.Parse(typeof(Commands), args.Details.Label, false); }
/// <summary> /// Handle word detected event /// </summary> /// <param name="sender"></param> /// <param name="args"></param> void WordDetectedHandler(object sender, WordDetection.WordEventArgs args) { if (null == args.Details) { return; } Debug.Log(args.Details.Label); if (args.Details.Label == GetWord(WORD_RESET).Label) { m_command = Commands.Reset; } else if (args.Details.Label == GetWord(WORD_GROW).Label) { m_command = Commands.Grow; } else if (args.Details.Label == GetWord(WORD_SHRINK).Label) { m_command = Commands.Shrink; } else if (args.Details.Label == GetWord(WORD_LEFT).Label) { m_command = Commands.Left; } else if (args.Details.Label == GetWord(WORD_RIGHT).Label) { m_command = Commands.Right; } else if (args.Details.Label == GetWord(WORD_UP).Label) { m_command = Commands.Up; } else if (args.Details.Label == GetWord(WORD_DOWN).Label) { m_command = Commands.Down; } }
/// <summary> /// Handle word detected event /// </summary> /// <param name="sender"></param> /// <param name="args"></param> void WordDetectedHandler(object sender, WordDetection.WordEventArgs args) { // skip detection while recording if (m_recordingSample) { return; } if (null == args.Details || string.IsNullOrEmpty(args.Details.Label)) { m_command = "Noise"; } else { m_command = args.Details.Label; if (m_command != "Noise") { m_timerClearMic = DateTime.Now + TimeSpan.FromMilliseconds(200); m_detected[m_command] = DateTime.Now + TimeSpan.FromSeconds(1); } } }
/// <summary> /// Handle word detected event /// </summary> /// <param name="sender"></param> /// <param name="args"></param> void WordDetectedHandler(object sender, WordDetection.WordEventArgs args) { if (null == args.Details) { return; } if (args.Details.Label == "Reset") { m_command = Commands.Reset; } else if (args.Details.Label == "Grow") { m_command = Commands.Grow; } else if (args.Details.Label == "Shrink") { m_command = Commands.Shrink; } else if (args.Details.Label == "Left") { m_command = Commands.Left; } else if (args.Details.Label == "Right") { m_command = Commands.Right; } else if (args.Details.Label == "Up") { m_command = Commands.Up; } else if (args.Details.Label == "Down") { m_command = Commands.Down; } }
/// <summary> /// Handle word detected event /// </summary> /// <param name="sender"></param> /// <param name="args"></param> void WordDetectedHandler(object sender, WordDetection.WordEventArgs args) { // skip detection while recording if (m_recordingSample) { return; } if (null == args.Details || string.IsNullOrEmpty(args.Details.Label)) { m_command = Commands.Noise; return; } if (m_modeTimer > DateTime.Now) { m_command = Commands.Noise; return; } //Debug.Log(args.Details.Label); switch (m_mode) { case Modes.Set1: if (args.Details.Label == Commands.Go.ToString()) { AudioWordDetection.Words = m_set2; m_mode = Modes.Set2; m_modeTimer = DateTime.Now + TimeSpan.FromMilliseconds(1000); Mic.ClearData(); m_wordsChanged = true; m_command = Commands.Noise; } break; case Modes.Set2: if (args.Details.Label == Commands.Back.ToString()) { AudioWordDetection.Words = m_set1; m_mode = Modes.Set1; m_modeTimer = DateTime.Now + TimeSpan.FromMilliseconds(1000); Mic.ClearData(); m_wordsChanged = true; m_command = Commands.Noise; } else if (args.Details.Label == Commands.Action.ToString()) { AudioWordDetection.Words = m_set3; m_mode = Modes.Set3; m_modeTimer = DateTime.Now + TimeSpan.FromMilliseconds(2000); Mic.ClearData(); m_wordsChanged = true; m_command = Commands.Noise; } else if (args.Details.Label == Commands.Misc.ToString()) { AudioWordDetection.Words = m_set4; m_mode = Modes.Set4; m_modeTimer = DateTime.Now + TimeSpan.FromMilliseconds(2000); Mic.ClearData(); m_wordsChanged = true; m_command = Commands.Noise; } break; case Modes.Set3: case Modes.Set4: if (args.Details.Label == Commands.Back.ToString()) { AudioWordDetection.Words = m_set2; m_mode = Modes.Set2; m_modeTimer = DateTime.Now + TimeSpan.FromMilliseconds(1000); Mic.ClearData(); m_wordsChanged = true; m_command = Commands.Noise; } else if (args.Details.Label != Commands.Noise.ToString()) { AudioWordDetection.Words = m_set1; m_mode = Modes.Set1; m_modeTimer = DateTime.Now + TimeSpan.FromMilliseconds(2000); Mic.ClearData(); m_wordsChanged = true; m_command = Commands.Noise; } break; } m_command = (Commands)Enum.Parse(typeof(Commands), args.Details.Label, false); PlayAnimation(GetStateName(m_command)); }