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