Computer Talker with C# z
Using the Code
- Add a textbox named '
txtWords
' to a form. - Add a button named '
btnSpeak
' to a form. - Add a reference to
System.Speech
. - In the form's code-behind, add:
using System.Windows.Forms; using System.Speech.Synthesis; namespace Sample { public partial Class Form1: Form { public SpeechSynthesizer _synthesizer; private void btnSpeak_Click(object sender, EventArgs e) { _synthesizer = new SpeechSynthesizer(); var words = txtWords.Text; _synthesizer.Speak(Words); } public Form1() { InitializeComponent(); } } }
- Run. Text entered into the textbox will be spoken by the computer.
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步