C#C
C#3y ago
JustiPhi

❔ MAUI Community Toolkit Speech Recognition issue

on windows 10 I am getting a network failure with the following code:
        private async Task Listen()
        {
            var isGranted = await SpeechToText.Default.RequestPermissions(tokenSource.Token);
            if (!isGranted)
            {
                await Toast.Make("Permission not granted").Show(tokenSource.Token);
                return;
            }
            var recognitionResult = await SpeechToText.Default.ListenAsync(
                                                CultureInfo.GetCultureInfo("en-au"),
                                                new Progress<string>(partialText =>
                                                {
                                                    RecognitionText += partialText + " ";
                                                }), tokenSource.Token);
            if (recognitionResult.IsSuccessful)
            {
                RecognitionText = recognitionResult.Text;

                await TextToSpeech.Default.SpeakAsync(recognitionResult.Text);
            }
            else
            {
                await Toast.Make(recognitionResult.Exception?.Message ?? "Unable to recognize speech").Show(tokenSource.Token);
            }
        }


the code appears to be working fine on windows 11 and android
Was this page helpful?