private async Task<string> ListenForText()
{
string result = "";
await InitSpeech();
try
{
Listening.IsActive = true;
text.Text = "Listening...";
SpeechRecognitionResult speechRecognitionResult = await speechRecognizer.RecognizeAsync();
if (speechRecognitionResult.Status == SpeechRecognitionResultStatus.Success)
{
result = speechRecognitionResult.Text;
}
}
catch (Exception ex)
{
Debug.WriteLine(ex.Message);
}
finally
{
Listening.IsActive = false;
text.Text = "";
}
return result;
}