Wednesday, 4 September 2013

Text-To-Speech .NET

This post is to introduce you with SAPI that allows a user to make an automated system that will send the input given by user to speakers and then Speakers will speak or output that text

* SAPI Stands for Speech Application Programming Interface . It is an API developed by Microsoft
to allow users to develop speech recognition systems. 

* The first version of SAPI was released in 1995. This is a program that offers Text-To-Speech and speech Recognition Capabilities. 

* SAPI interfaces are provided for C,C++,C# and visual Basic Languages. 

* SAPI is most widely used application program interface ( API ) used today

CODE For Text - To - Speech in  VB.NET 


Dim SAPI
SAPI = CreateObject ( "sapi.spvoice" ) 
SAPI.speak( TextBox2.Text )

In order to Use SAPI we have to create object of SAPI . In Code Above in line 2 we have created object assigned it SAPI . SAPI is a simple variable nothing more than that there is no need to be confused about that . Then we have used speak ( )  method to give or direct the input to speakers to speak or output all given input.


DEMO APPLICATION FOR SAPI

DEMO APPLICATION 1


DOWNLOAD DEMO APPLICATION FROM LINK BELOW


CODE  FOR DEMO APPLICATION :- 


Public Class Form1

    Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress

        Dim i As Integer
        i = 0
        Dim ch As Char
        ch = e.KeyChar

        If ch = " " Then
            Dim SAPI
            SAPI = CreateObject("sapi.spvoice")
            SAPI.speak(TextBox2.Text)
            TextBox2.Text = ""

        Else
TextBox2.text = TextBox2.text + ch;
        End If

    End Sub

Explanation Of Code

In this code I have taken a variable i of type integer and initialized it to Zero . I have taken a  char type variable that will take character typed or cached by keypress event. 

First in If ( ) codition  i have checked whether the entered character is a blank space or not .If entered character is not a blank space then this code just add the entered character to the TextBox and If user has pressed a space then the complete word will be spoken by SAPI object .

This code spoke the words not only characters entered by user it first takes the characters and then collect them and after completion of word it passes it to SAPI object and SAPI will give that word as output to speaker to spoke it

DEMO APPLICATION 2


DOWNLOAD DEMO APPLICATION 2 FROM LINK BELOW




DEMO APPLICATION 3


DOWNLOAD DEMO APPLICATION 3 FROM LINK BELOW
https://docs.google.com/file/d/0ByR2IblIaEGyOGpuT0NiaTZIZHM/edit



Share this

0 Comment to "Text-To-Speech .NET"

Post a Comment