这个语音朗读功能是否非常基础简单?

更新于
2026-10-10 03:33:26
1阅读来源:SEO资源
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计249个文字,预计阅读时间需要1分钟。

这个语音朗读功能是否非常基础简单?

不知道大家有没有发现,在System.Speech.Synthesis命名空间下有一个SpeechSynthesizer类,它可以指定文本内容进行语音朗读。这个类用法简单,简单到什么程度呢?试试看。首先,。


这个语音朗读功能是否非常基础简单?

不知道大家有没有发现,在System.Speech.Synthesis命名空间下有一个SpeechSynthesizer类,它可以指定的文本内容进行语音朗读,而且,这个类用起来也严重简单,简单到什么程度? 试试看。

首先,新建一个项目,随便你建什么项目,反正能测试即可。

然后,添加对System.Speech程序集的引用,这个不用我教你了,你再菜,只要用VS都不可能不懂这个。

引入System.Speech.Synthesis命名空间,最后,看好了,几行代码搞定。

private void button1_Click(object sender, EventArgs e) { if (string.IsNullOrWhiteSpace(txtToRead.Text)) { return; } // 一new一speech就搞定 SpeechSynthesizer sp = new SpeechSynthesizer(); sp.SpeakCompleted += (s, arg) => button1.Enabled = true; // 开始读啦 button1.Enabled = false; sp.SpeakAsync(txtToRead.Text); }

本文共计249个文字,预计阅读时间需要1分钟。

这个语音朗读功能是否非常基础简单?

不知道大家有没有发现,在System.Speech.Synthesis命名空间下有一个SpeechSynthesizer类,它可以指定文本内容进行语音朗读。这个类用法简单,简单到什么程度呢?试试看。首先,。


这个语音朗读功能是否非常基础简单?

不知道大家有没有发现,在System.Speech.Synthesis命名空间下有一个SpeechSynthesizer类,它可以指定的文本内容进行语音朗读,而且,这个类用起来也严重简单,简单到什么程度? 试试看。

首先,新建一个项目,随便你建什么项目,反正能测试即可。

然后,添加对System.Speech程序集的引用,这个不用我教你了,你再菜,只要用VS都不可能不懂这个。

引入System.Speech.Synthesis命名空间,最后,看好了,几行代码搞定。

private void button1_Click(object sender, EventArgs e) { if (string.IsNullOrWhiteSpace(txtToRead.Text)) { return; } // 一new一speech就搞定 SpeechSynthesizer sp = new SpeechSynthesizer(); sp.SpeakCompleted += (s, arg) => button1.Enabled = true; // 开始读啦 button1.Enabled = false; sp.SpeakAsync(txtToRead.Text); }