当前位置:编程学习 > C#/ASP.NET >>

C#中英文混合朗读

偶尔的项目需求里,要求可以应用程序朗读一段文字,如朗读验证码功能,这里做了一个简单的实现。

首先要引用一个类库SpeechLib.dll,具体代码如下:(本段程序是用winform实现的)

 

\代码
1 using System;
2  using System.Collections.Generic;
3 using System.Windows.Forms;
4 using SpeechLib;
5 namespace TestSpeaker1
6 {
7 static class Program
8 {
9 /// <summary>
10 /// 应用程序的主入口点。
11 /// </summary>
12 [STAThread]
13 static void Main()
14 {
15 Application.EnableVisualStyles();
16 Application.SetCompatibleTextRenderingDefault(false);
17 Application.Run(new Form1());
18 }
19 }
20 public class Speach
21 {
22 private static Speach _Instance = null;
23 private SpeechLib.SpVoiceClass voice = null;
24 private Speach()
25 {
26 BuildSpeach();
27 }
28 public static Speach instance()
29 {
30 if (_Instance == null)
31 _Instance = new Speach();
32 return _Instance;
33 }
34 private void SetChinaVoice()
35 {
36 voice.Voice = voice.GetVoices(string.Empty, string.Empty).Item(3);
37 }
38 private void SetEnglishVoice()
39 {
40 voice.Voice = voice.GetVoices(
补充:软件开发 , C# ,
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,