码迷,mamicode.com
首页 > 其他好文 > 详细

c# 字符串转化成声音

时间:2014-09-24 15:18:27      阅读:194      评论:0      收藏:0      [点我收藏+]

标签:c#   字符串转换成声音   

说明:

(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)后台代码

bubuko.com,布布扣

(2)运行效果

bubuko.com,布布扣







c# 字符串转化成声音

标签:c#   字符串转换成声音   

原文地址:http://blog.csdn.net/u013816709/article/details/39521627

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!