private static bool SetAudioFormat(string format)
        {
            int bitPerSample;

            System.Speech.AudioFormat.AudioBitsPerSample    sysAudioBitsPerSample;
            Microsoft.Speech.AudioFormat.AudioBitsPerSample msftAudioBitsPerSample;
            System.Speech.AudioFormat.AudioChannel          sysAudioChannel;
            Microsoft.Speech.AudioFormat.AudioChannel       msftAudioChannel;
            decimal rawInput;

            string[] parts = Regex.Split(format, "_");

            if (parts.Length != 3)
            {
                Console.WriteLine("Invalid Audio Format");
                return(false);
            }

            if (Decimal.TryParse(parts[0], out rawInput) && (rawInput % 1) == 0 && rawInput > 0)
            {
                bitPerSample = (int)rawInput;
            }
            else
            {
                Console.WriteLine("Invalid Audio Format: SamplePerSecond must be a positive integer");
                return(false);
            }


            if (Decimal.TryParse(parts[1], out rawInput) && (rawInput % 1) == 0 && rawInput > 0)
            {
                if (rawInput == 8.0M)
                {
                    sysAudioBitsPerSample  = System.Speech.AudioFormat.AudioBitsPerSample.Eight;
                    msftAudioBitsPerSample = Microsoft.Speech.AudioFormat.AudioBitsPerSample.Eight;
                }
                else if (rawInput == 16.0M)
                {
                    sysAudioBitsPerSample  = System.Speech.AudioFormat.AudioBitsPerSample.Sixteen;
                    msftAudioBitsPerSample = Microsoft.Speech.AudioFormat.AudioBitsPerSample.Sixteen;
                }
                else
                {
                    Console.WriteLine("Invalid Audio Format: BitsPerSample must be either 8 or 16");
                    return(false);
                }
            }
            else
            {
                Console.WriteLine("Invalid Audio Format: BitsPerSample must be either 8 or 16");
                return(false);
            }

            if (parts[2].Equals("Mono"))
            {
                sysAudioChannel  = System.Speech.AudioFormat.AudioChannel.Mono;
                msftAudioChannel = Microsoft.Speech.AudioFormat.AudioChannel.Mono;
            }
            else if (parts[2].Equals("Stereo"))
            {
                sysAudioChannel  = System.Speech.AudioFormat.AudioChannel.Stereo;
                msftAudioChannel = Microsoft.Speech.AudioFormat.AudioChannel.Stereo;
            }
            else
            {
                Console.WriteLine("Invalid Audio Format: AudioChannel must be either Mono or Stereo");
                return(false);
            }

            sysAF  = new System.Speech.AudioFormat.SpeechAudioFormatInfo(bitPerSample, sysAudioBitsPerSample, sysAudioChannel);
            msftAF = new Microsoft.Speech.AudioFormat.SpeechAudioFormatInfo(bitPerSample, msftAudioBitsPerSample, msftAudioChannel);

            return(true);
        }
        private static bool SetAudioFormat(string format)
        {
            
            int bitPerSample;
            System.Speech.AudioFormat.AudioBitsPerSample sysAudioBitsPerSample;
            Microsoft.Speech.AudioFormat.AudioBitsPerSample msftAudioBitsPerSample;
            System.Speech.AudioFormat.AudioChannel sysAudioChannel;
            Microsoft.Speech.AudioFormat.AudioChannel msftAudioChannel;
            decimal rawInput;

            string[] parts = Regex.Split(format, "_");

            if (parts.Length != 3)
            {
                Console.WriteLine("Invalid Audio Format");
                return false;
            }

            if (Decimal.TryParse(parts[0], out rawInput) && (rawInput % 1) == 0 && rawInput > 0)
            {
                bitPerSample = (int) rawInput;
            }
            else
            {
                Console.WriteLine("Invalid Audio Format: SamplePerSecond must be a positive integer");
                return false;
            }


            if (Decimal.TryParse(parts[1], out rawInput) && (rawInput % 1) == 0 && rawInput > 0)
            {
                if (rawInput == 8.0M)
                {
                    sysAudioBitsPerSample = System.Speech.AudioFormat.AudioBitsPerSample.Eight;
                    msftAudioBitsPerSample = Microsoft.Speech.AudioFormat.AudioBitsPerSample.Eight;
                }
                else if (rawInput == 16.0M)
                {
                    sysAudioBitsPerSample = System.Speech.AudioFormat.AudioBitsPerSample.Sixteen;
                    msftAudioBitsPerSample = Microsoft.Speech.AudioFormat.AudioBitsPerSample.Sixteen;
                }
                else
                {
                    Console.WriteLine("Invalid Audio Format: BitsPerSample must be either 8 or 16");
                    return false;
                }
            }
            else
            {
                Console.WriteLine("Invalid Audio Format: BitsPerSample must be either 8 or 16");
                return false;
            }

            if (parts[2].Equals("Mono"))
            {
                sysAudioChannel = System.Speech.AudioFormat.AudioChannel.Mono;
                msftAudioChannel = Microsoft.Speech.AudioFormat.AudioChannel.Mono;
            }
            else if (parts[2].Equals("Stereo"))
            {
                sysAudioChannel = System.Speech.AudioFormat.AudioChannel.Stereo;
                msftAudioChannel = Microsoft.Speech.AudioFormat.AudioChannel.Stereo;
            }
            else
            {
                Console.WriteLine("Invalid Audio Format: AudioChannel must be either Mono or Stereo");
                return false;
            }

            sysAF = new System.Speech.AudioFormat.SpeechAudioFormatInfo(bitPerSample, sysAudioBitsPerSample, sysAudioChannel);
            msftAF = new Microsoft.Speech.AudioFormat.SpeechAudioFormatInfo(bitPerSample, msftAudioBitsPerSample, msftAudioChannel);

            return true;

        }