0

I get that expection and cannot figure how to solve it.

I've tried changing culture to fi-FI, en-EN, en-GB, en-US it always gives that expection.

I also tried Culture is not supported solution and Go to Debug -> Options -> Debugging and tick "Enable Just My Code" this.

.NET Framework 4.7.2 Visual studio 2019 Reference System.Speech

using System;
using System.Speech.Recognition;

namespace SpeechRecognition3
{
    class Program
    {
        static void Main(string[] args)
        {
            // Create an in-process speech recognizer for the en-US locale.  
            using (SpeechRecognitionEngine recognizer =
              new SpeechRecognitionEngine(
                new System.Globalization.CultureInfo("fi-FI")))
            {

                // Create and load a dictation grammar.  
                recognizer.LoadGrammar(new DictationGrammar());

                // Configure input to the speech recognizer.  
                recognizer.SetInputToDefaultAudioDevice();

                // Modify the initial silence time-out value.  
                recognizer.InitialSilenceTimeout = TimeSpan.FromSeconds(5);

                // Start synchronous speech recognition.  
                RecognitionResult result = recognizer.Recognize();

                if (result != null)
                {
                    Console.WriteLine("Recognized text = {0}", result.Text);
                }
                else
                {
                    Console.WriteLine("No recognition result available.");
                }
            }

            Console.WriteLine();
            Console.WriteLine("Press any key to continue...");
            Console.ReadKey();
        }
    }
}

0LL1
  • 1
  • 1

2 Answers2

0

I would recommend looking at the documentation for it https://learn.microsoft.com/en-us/dotnet/api/system.globalization.cultureinfo?view=netcore-3.1

"The format for the culture name based on RFC 4646 is languagecode2>-country/regioncode2, where languagecode2 is the two-letter language code and country/regioncode2 is the two-letter subculture code. "

RadiantMin3
  • 103
  • 1
  • 8
  • umm, i didnt quite understand what should i do now. isnt fi-FI or en-US in right form? – 0LL1 May 04 '20 at 12:16
0

I had the same issue neither fi-Fi or en-US would work. If someone is still having this problem the following might help.

The fix was to install English (US) language package to windows as a "primary language" since the local language version of Windows does not include it automatically.

After installing the package System.Globalization.CultureInfo("en-US") worked.

Unfortunately this might also mean that your local language is not a supported natively.

Ossi H.
  • 84
  • 6