When I try to set a language to SpeechRecognize (WP 8.1) doesn't work

63 Views Asked by At

When I try to set a language to SpeechRecognize (Windows Phone 8.1) it runs an exception. But in documentation tells me to do the way I'm doing D;

This works:

private async void Button_Click_1(object sender, RoutedEventArgs e)
        {
            var rec = new SpeechRecognizer();
            await rec.CompileConstraintsAsync();
            rec.UIOptions.AudiblePrompt = "Aguardando o comando";
            var stream = await rec.RecognizeWithUIAsync();

        }

This doesn't work:

private async void Button_Click_1(object sender, RoutedEventArgs e)
        {
             var rec = new SpeechRecognizer(new Windows.Globalization.Language("pt-BR"));
            await rec.CompileConstraintsAsync();
            rec.UIOptions.AudiblePrompt = "Aguardando o comando";
            var stream = await rec.RecognizeWithUIAsync();

        }

Someone PLEASE could help me ?

1

There are 1 best solutions below

0
On

I think that is because your Locale you have installed is not that language. If you want to know for sure, try this:

private async void Button_Click_1(object sender, RoutedEventArgs e)
    {
           try(){
         var rec = new SpeechRecognizer(new Windows.Globalization.Language("pt-BR"));
        await rec.CompileConstraintsAsync();
        rec.UIOptions.AudiblePrompt = "Aguardando o comando";
        var stream = await rec.RecognizeWithUIAsync();
            }
         catch(Exception e)
           {
             Debug.WriteLine(e);
            }

    }