您的位置:首页 > 编程语言 > C#

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

2014-09-24 12:20 344 查看
说明:

(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)运行效果

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐