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();
        }
    }
}

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM