Esempio n. 1
0
        public static void SpeakSsml(string ssml, string defaultVoiceName, MemoryStream memoryStream, SpeechSynthesizer speechSynthesizer = null)
        {
            speechSynthesizer = speechSynthesizer ?? SpeechSynthesizer;
            lock (speechSynthesizer)
            {
                if (!string.IsNullOrEmpty(defaultVoiceName))
                {
                    speechSynthesizer.SelectVoice(defaultVoiceName);
                }

                SpeechSynthesizer.SetOutputToAudioStream(memoryStream, new SpeechAudioFormatInfo(EncodingFormat.Pcm, SPEECH_SAMPLE_RATE, SPEECH_BITS_PER_SAMPLE, SPEECH_CHANNELS, SPEECH_SAMPLE_RATE * SPEECH_CHANNELS * SPEECH_BITS_PER_SAMPLE / 8, 2, null));
                //speechSynthesizer.SetOutputToWaveStream(memoryStream);

                speechSynthesizer.SpeakSsml(ssml);
            }
        }