In this article I will show you how to convert text to speech using namespace System.Speech in .Net framework.
Here i am going to implement text to speech in c# using asp.net web application.
Create a web form and named as TextToSpeech. Before designing the UI for Text to speech module, first of all download the system.speech dll from below link.
You can download the System.Speech.dll from the link.
Step 1: Copy and paste the following design code in web form asp.net.
<form id="form1" runat="server">
<div style="border: 1px solid #357ae8; padding-top: 15px; width: 500px; height: 350px">
<h1 style="color: #3d75bd;">Asp .net text to speech using c#</h1>
<br />
<asp:TextBox ID="txtContent" runat="server" TextMode="MultiLine" Width="400px" Height="100px">
</asp:TextBox>
<br />
<asp:Button ID="btnSpeak" runat="server" Text="Click To Speak" OnClick="btnSpeak_Click" />
<br />
</div>
</form>
Step 2: Copy and paste the following code in code behind page. It is necessary to Import the following namespaces,
using System.Speech.AudioFormat;
using System.Speech.Synthesis;
protected void btnSpeak_Click(object sender, EventArgs e)
{
SpeechAudioFormatInfo info = new SpeechAudioFormatInfo(6, AudioBitsPerSample.Sixteen, AudioChannel.Mono);
using (var ss = new SpeechSynthesizer())
{
ss.Volume = 100;
ss.SelectVoiceByHints(VoiceGender.Female,VoiceAge.Adult);
ss.Speak(txtContent.Text);
}
}
Ouput:
Below video explains how to convert text to speech in asp.net using c#
Post your comments / questions
Recent Article
- How to get domain name information from a Domain using Python
- ModulenotFoundError: no module named 'debug_toolbar' -SOLUTION
- How to create superuser in django project hosted in cPanel without terminal
- CSS & images not loading in django admin | cpanel without terminal
- Could not build wheels for mysqlclient, which is required to install pyproject.toml-based projects
- How to sell domain name on Godaddy (2023)
- TemplateSyntaxError at / Could not parse the remainder: ' + 1' from 'forloop.counter0 + 1'
- urllib3 v2.0 only supports OpenSSL 1.1.1+, currently the 'ssl' module is compiled with 'OpenSSL 1.0
Related Article