Objective:To develop a windows application using the Microsoft Speech Object Library in C# .Net to wish a 'Happy New Year'.Steps:1. Goto 'Project' Menu -> Select 'AddReference'-> Click on 'COM' tab.Select 'Microsoft Speech Object Library' -> OK.Note: In order to make use of this COM component we have to include 'using SpeechLib' namespace in the code.2. Design: Design the form as shown above with one Label, one TextBox and three Buttons.3. Code: using System;using System.Windows.Forms;using SpeechLib;namespace newyearapp{ Public partial class newyearapp : Form { public newyearapp() { InitializeComponent(); } string str1 = "wish you a happy and prosperous new year ", str2; SpVoice obj = new SpVoice(); private void btnOK_Click(object sender, EventArgs e) { if (textBox1.Text.Trim().Length > 0) { str2 = str1 + textBox1.Text; obj.Speak(str2, SpeechVoiceSpeakFlags.SVSFDefault); } else obj.Speak(str1, SpeechVoiceSpeakFlags.SVSFDefault); } private void btnClear_Click(object sender, EventArgs e) { textBox1.Text = ""; } private void btnExit_Click(object sender, EventArgs e) { this.Close(); } }}
OutputWe will hear new year wishes.
You need to be a premium member to use this feature. To access it, you'll have to upgrade your membership.
Become a sharper developer and jumpstart your career.
$0
$
. 00
monthly
For Basic members:
$20
For Premium members:
$45
For Elite members: