c# 字符串转化成声音 分类: C# 2014-09-24 12:20 316人阅读 评论(0) 收藏

说明:

(1)支持Window 7系统,但是xp系统智能朗读英文和数字;

(2)添加引用 Interop.SpeechLib.dll;

(3)使用时调用StringToVoice(str)即可。

     using SpeechLib;

   /// <summary>
        /// 把字符串转换成声音
        /// </summary>
        /// <param name="str">要朗读的字符串</param>
        public static void StringToVoice(string str) {           
                if (str.Trim().Length > 0) {
                    SpVoiceClass svc = new SpVoiceClass();
                    SpeechVoiceSpeakFlags spFlags = SpeechVoiceSpeakFlags.SVSFlagsAsync;
                    svc.Speak(str, spFlags);
                }
图示:

(1)后台代码


(2)运行效果








版权声明:本文为博主原创文章,未经博主允许不得转载。

posted @ 2014-09-24 12:20  Jackerson  阅读(206)  评论(0编辑  收藏  举报