asp.net引用System.Speech实现语音提示

using System;
using System.Speech.Synthesis;

namespace testvoice
{
    class Program
    {
        static void Main(string[] args)
        {
            SpeechSynthesizer synth = new SpeechSynthesizer();

            //获取本机上所安装的所有的Voice的名称
            string voicestring = "";

            foreach (InstalledVoice iv in synth.GetInstalledVoices())
            {
                voicestring += iv.VoiceInfo.Name + ",";
            }
            //voicestring的值是Microsoft Lili,Microsoft Anna
            synth.Volume = 100;
            synth.Rate = -5;
            //根据Voice的name属性确定要使用的Voice
            //synth.SelectVoice("Microsoft Anna");//美式发音,但只能读英文
            synth.SelectVoice("Microsoft Lili");//能读中英文
            //根据文字内容合成语音
            synth.Speak("你好");
            Console.Read();
        }
    }
}

 

posted @ 2018-09-30 15:28  一指流砂~  阅读(1905)  评论(0编辑  收藏  举报