惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - Franky
N
Netflix TechBlog - Medium
Google Online Security Blog
Google Online Security Blog
月光博客
月光博客
量子位
酷 壳 – CoolShell
酷 壳 – CoolShell
V
V2EX
腾讯CDC
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园 - 聂微东
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
M
MIT News - Artificial intelligence
Vercel News
Vercel News
The GitHub Blog
The GitHub Blog
Hugging Face - Blog
Hugging Face - Blog
博客园 - 【当耐特】
Apple Machine Learning Research
Apple Machine Learning Research
aimingoo的专栏
aimingoo的专栏
博客园 - 三生石上(FineUI控件)
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
MongoDB | Blog
MongoDB | Blog
H
Help Net Security
The Cloudflare Blog
Blog — PlanetScale
Blog — PlanetScale
F
Full Disclosure
G
Google Developers Blog
罗磊的独立博客
Jina AI
Jina AI
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Y
Y Combinator Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
J
Java Code Geeks
A
About on SuperTechFans
IT之家
IT之家
大猫的无限游戏
大猫的无限游戏
S
SegmentFault 最新的问题
有赞技术团队
有赞技术团队
GbyAI
GbyAI
雷峰网
雷峰网
T
The Blog of Author Tim Ferriss
The Register - Security
The Register - Security
U
Unit 42
D
Docker
Martin Fowler
Martin Fowler
L
LINUX DO - 热门话题
NISL@THU
NISL@THU
阮一峰的网络日志
阮一峰的网络日志
C
Cybersecurity and Infrastructure Security Agency CISA
博客园_首页
Google DeepMind News
Google DeepMind News

博客园 - 星期六

C# winform授权:获取cpu和硬盘的序列号,得到机器码 批量替换文本文件中的字符 获取主板及硬盘序列号 - 星期六 - 博客园 .net安装部署“Error 1001 在初始化安装时发生异常” 的解决方法 解决.net绘制的 WinForm 在 windows7下变形的方法。 如何使用 Visual C# 加密和解密文件 ppc通过蓝牙与电脑同步时无ActiveSync服务的解决方法。 winfrom中的几个界面皮肤控件 如何弹出一个模式窗口来显示进度条 .net 实现移动控件位置 如何在安装后自动运行程序? 调试自定义操作/安装程序类的方法 利用TimerCallback实现timer传递参数 网页中下载灰鸽子病毒的 SCRIPT 一段控制对象透明度的style. ASP.net 把 DataGrid 数据导出到 Excel . ASP.NET 用读取二进制代码的方法在页面上显示指定图片。 c# 8条语句实现屏幕抓图 几条SQLl查询语句
用C#实现语音技术
星期六 · 2006-12-27 · via 博客园 - 星期六

【IT168 编程开发】“电脑朗读”(英文)一个很好的触发点,通过它可以实现电子小说阅读、英文听力测试、英文单词学习...

  下面的Speech已对MSTTS作了简单封装。

  1.安装好MSTTS(如果你有装金山词霸,系统就已经安装了),可以在winnt\speech中打到vtxtauto.tlb文件;

  2.用.Net SDK自带的tlbimp工具把vtxtauto.tlb转换成.dll格式:

  tlbimp vtxtauto.tlb /silent /namespace:mstts /out:mstts.dll
  这时的mstts.dll已成为.net framework运行库的一个类。

  3.编写一个封装vtxtauto的简单类:Speech .

//========================Speech.cs======================
using System;
using mstts; //MSTTS名称空间
namespace Bedlang{ //定义名称空间
public class Speech{
private VTxtAuto VTxtAutoEx;
public Speech(){
VTxtAutoEx = new VTxtAuto();
VTxtAutoEx.Register(" "," "); //注册COM组件
}
public void Speak(String text){
VTxtAutoEx.Speak(text, 0); //发音
}
}
}
//========================Speech.cs======================

  4.编译Bedlang.Speech

  csc /target:library /out:Bedlang.dll speech.cs /r:mstts.dll
  如果用vs.net开发,可直接生成项目就可以了。

  5.发音实现

//========================demo.cs======================
分别加入Label,TextBox,Button控件各一个到windows Form中,修改它们的属性,源代码如下:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace Bedlang
{
///
/// Form1 的摘要说明。
///
public class demo : System.Windows.Forms.Form
{
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Button button1;
///
/// 必需的设计器变量。
///
private System.ComponentModel.Container components = null;
public demo()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}
///
/// 清理所有正在使用的资源。
///
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
///
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
///
private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.textBox1 = new System.Windows.Forms.TextBox();
this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// label1
//
this.label1.Location = new System.Drawing.Point(24, 16);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(120, 23);
this.label1.TabIndex = 0;
this.label1.Text = "输入要朗读的文字:";
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(24, 48);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(248, 21);
this.textBox1.TabIndex = 1;
this.textBox1.Text = "";
//
// button1
//
this.button1.Location = new System.Drawing.Point(112, 112);
this.button1.Name = "button1";
this.button1.TabIndex = 2;
this.button1.Text = "朗读";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// demo
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(292, 197);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.button1,
this.textBox1,
this.label1});
this.Name = "demo";
this.Text = "demo";
this.ResumeLayout(false);
}
#endregion
///
/// 应用程序的主入口点。
///
[STAThread]
static void Main()
{
Application.Run(new demo());
}
private void button1_Click(object sender, System.EventArgs e)
{
Speech s=new Speech(); //创建一个Speech对象
if(textBox1.Text.Length==0)
s.Speak("Please input letter."); //发音
else
s.Speak(textBox1.Text);
}
}
}
//========================demo.cs======================

  6.编译demo.cs

  csc demo.cs /r:bedlang.dll

  Vs.net环境下可直接编译成exe文件。

  7.运行demo.exe

  输入要要朗读的文字,程序就可朗读了啦.