1024祝各位程序员节日快乐!
PS:大佬勿喷,新人上路
第一步:应用程序
打开你的VS(visual studio)
我用的版本是vs2019版本
选择创建新项目
搜索窗体
选择Windos 窗体应用(.net frameword)
第二步 引用
右击以在解决方案中添加引用
[En]
Right-click to add a reference in the solution
第一步点击COM
第二部点击搜索
搜索栏搜索: Speech
当你放上鼠标时,会有一个提示,然后检查勾号以确保
[En]
When you put the mouse on, there will be a prompt, and then check the tick to make sure
第三步 命名空间引用
打开我们创建项目时系统默认的FORM1(自己创建也可以)
在窗体添加一个文本框
此文本框是您要大声朗读的文本。
[En]
This text box is the text you want to read aloud.
创建好了文字时候在创建一个点击事件,这里我用Button
现在我们双击button按钮进入代码,进入代码选项时会默认生成点击事件
我们在项目引用刚刚的插件Speech,导入命名空间
using  SpeechLib
在这一点上,我们可以引用该方法。
[En]
At this point, we can quote the method.
下面的代码我直接复制
//接受文本框的文字
string text = textBox1.Text;
SpVoice voice = new SpVoice();
//音量
voice.Volume = 100;
//语速
voice.Rate = 2;
//朗读内容
voice.Speak(text);
创建它并直接保存,然后转到我们刚刚制作的插件来查看效果。
[En]
Create it and save it directly, and then go to the plug-in we just made to see the effect.
输入文字,直接点击按钮即可生成效果!
[En]
Enter the text and click the button directly to generate the effect!
Original: https://blog.csdn.net/Yu_yoyo/article/details/120892850
Author: 于悠悠.
Title: VS 创建C# winfrom 语音播报(文字朗读),无需下载插件
原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/512213/
转载文章受原作者版权保护。转载请注明原作者出处!