代码改变世界

C#字符串转语音

2017-06-27 17:26  原生木  阅读(429)  评论(0)    收藏  举报

添加引用System.Speech程序集(VS2012以后自带直接引用即可);

using System;
using System.Speech.Synthesis;
 
namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
              
             
            SpeechSynthesizer speech1= new SpeechSynthesizer();
            string str = "你好";
            speech1.Speak(str); //语音方法调用
            
        }     
}
}