private async void StartListenMode()
{
while (listening)
{
string spokenText = await ListenForText();
while (string.IsNullOrWhiteSpace(spokenText) && listening)
spokenText = await ListenForText();
if (spokenText.ToLower().Contains("stop listening"))
{
speechRecognizer.UIOptions.AudiblePrompt = "Are you sure you want me to stop listening?";
speechRecognizer.UIOptions.ExampleText = "Yes/No";
speechRecognizer.UIOptions.ShowConfirmation = false;
//SpeakAsync(speechRecognizer.UIOptions.AudiblePrompt);
var result = await speechRecognizer.RecognizeWithUIAsync();
if (!string.IsNullOrWhiteSpace(result.Text) && result.Text.ToLower() == "yes")
{
await SetListening(false);
}
}
if (listening)
{
await SendMessage(spokenText, true);
}
}
}