private async void MicButton_Click(object sender, System.Windows.RoutedEventArgs e) { if (AccessToken == null) { WitLog.Log("WitMicButton", "Did you set your AccessToken propeply?"); return; } IsToggled = !IsToggled; if (IsToggled) { if (CaptureVoiceIntentStarted != null) { CaptureVoiceIntentStarted(this, EventArgs.Empty); } wit = new Wit(AccessToken, DetectSpeechStop); WitResponse witResponse = await wit.CaptureVoiceIntent(); IsToggled = false; if (CaptureVoiceIntentCompleted != null) { CaptureVoiceIntentCompleted(this, witResponse); } } else { if (wit != null) { wit.StopCaptureVoiceIntent(); } if (CaptureVoiceIntentStopped != null) { CaptureVoiceIntentStopped(this, EventArgs.Empty); } } }