private async void SpeakAppBr_Click(object sender, EventArgs e)
{
MessageBox.Show("Sorry! I only listen to you in English!");
strLngFrom = "en";
btnFrom.Content = "English";
this.speechRecognizer.Recognizer.Grammars.Clear();
this.speechRecognizer.Recognizer.Grammars.AddGrammarFromPredefinedType("message", SpeechPredefinedGrammar.Dictation);
await this.speechRecognizer.Recognizer.PreloadGrammarsAsync();
try
{
SpeechRecognitionUIResult recognitionResult = await this.speechRecognizer.RecognizeWithUIAsync();
if (recognitionResult.ResultStatus == SpeechRecognitionUIStatus.Succeeded)
{
strTextToTranslate = recognitionResult.RecognitionResult.Text;
String strTranslatorAccessURI = "https://datamarket.accesscontrol.windows.net/v2/OAuth2-13";
System.Net.WebRequest req = System.Net.WebRequest.Create(strTranslatorAccessURI);
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
IAsyncResult writeRequestStreamCallback = (IAsyncResult)req.BeginGetRequestStream(new AsyncCallback(RequestStreamReady), req);
txtToTrans.Text = recognitionResult.RecognitionResult.Text;
}
else
{
//MessageBox.Show("Sorry! I didn't catch you.");
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}