0% found this document useful (0 votes)
38 views35 pages

A Report On

Uploaded by

Arshpreet Brar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views35 pages

A Report On

Uploaded by

Arshpreet Brar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 35

y 1903107

A REPORT ON

Speech Recognition System

PROJECT REPORT

SUBMITTED IN PARTIAL FULFILLMENT OF THE REQUIREMENT


FOR THE AWARD OF THE DEGREE OF

BACHELOR OF TECHNOLOGY
(Computer Science & Engineering)

SUBMITTED BY
(Arshpreet Singh, rollno1903107, SEMESTER-3 & GROUP-Z1)
UNDER THE GUIDANCE OF

Geetanjali babbar
(Assistant Professor)

Department of Computer Science & Engineering Chandigarh


Engineering College
Kharar-Banur Highway, Sector-112 Greater Mohali,
Punjab – 140307 (INDIA)

(Approved by AICTE, New Delhi and Affiliated to IKGPTU, Jalandhar)

1
y 1903107

CHANDIGARH ENGINEERING COLLEGE,


CGC- LANDRAN, MOHALI

CANDIDATE'S DECLARATION

I hereby certify that the work which is being presented in the project report entitled
“COLLEGE ERP SYSTEM ” by “Arshpreet Singh” in partial fulfillment of
requirements for the award of degree of B.Tech. (CSE) submitted in the Department of
CSE at Chandigarh Engineering College under PUNJAB TECHNICAL
UNIVERSITY, JALANDHAR is an authentic record of my own work carried
out during a period from SEP 2019 to NOV 2023 under the supervision of
Geetanjali babbar .

Arshpreet Singh
(Name & Signature of the Student)

This is to certify that the above statement made by the candidate is correct to the
best of my/our knowledge.
The B.Tech Viva –Voce Examination of Arshpreet Singh
has been held on
and accepted.

Geetanjali babbar (Assistant Professor)

(Name & Sign of Project Guide Designation)


What is
2
y 1903107

Speech Recognition System

Introduction

Speech Recognition (SR) is the ability to translate a dictation or spoken word


to text.
Speech Recognition known as “automatic speech recognition“ (ASR),or speech to
text(STT)
• Speech recognition is the process of converting an acoustic signal, captured by
a microphone or any peripherals , to a set of words .
• To achieve speech understanding we can use linguistic processing
• The recognized words can be an end in themselves, as for applications such as
commands & control data entry and document preparation.

In the society every one either human or animals wish to interact with each other and
tries to convey own message to others . The receiver for messages may get the exact
and full idea of the senders, or may get the partial idea or sometimes can not
understand anything out of it.
In some cases may happen when there is some lacking in communication (i.e when a
child convey message, the mother can understand easily while others can not )

Project overview

This thesis report considers an overview of speech recognition technology,


software development , and its applications . The first section deals with the
descriptions of speech recognition process , its applications in different sectors, its
flaws and finally the future of technology. Later part of report covers the speech
recognition process, and the code for the software and its working. Finally the report
concludes at the different potentials uses of the application and further
improvements and considerations.

Existing System (History)


3
y 1903107

The concept of speech recognition started somewhere in 1940s, practically the


first speech recognition program was appeared in 1953 at the bell labs, that was
about recognition of a digit in a noise free environment.
1940s and 1950s consider as the foundational period of the speech recognition
technology, in this period work was done on the of the speech recognition that is
automation and information theoretic models.
In the 1960’s we were able to recognize small vocabularies (order of 10-100
words) of isolated words , based on simple acoustic-phonetic properties of speech
sounds. The key technologies that were developed during this decade were, filter
banks and time normalization methods.

In 1970s the medium vocabularies (order of 100-100 words) using simple


template-based, pattern recognition methods were recognized.

In 1980s large vocabularies (1000-unlimited) were used and speech recognition


problems based on statistical, with a large range of networks for handling language
structures were addressed. The key invention of this era were hidden mark model
(HMM) and the stochastic language model , which together enabled powerful new
methods for handling continuous speech recognition problem efficiently and with
high performance.
In 1990s the key technologies developed during this period were the methods for
stochastic language understanding, statistical learning of acoustic and language
models, and the methods for implementation of large vocabulary speech
understanding systems.

After the five decades of research, the speech recognition technology has finally
entered marketplace, benefiting the users in variety of ways. The challenge of
designing a machine that truly functions like an intelligent human is still a major one
going forward.

4
y 1903107

System Requirements:

An overview of Speech Recognition


Speech recognition is a technology that able a computer to capture the words
spoken by a human with a help of microphone. These words are later on recognized
by speech recognizer , and in the end, system outputs the recognized words.
An ideal situation in the process of speech recognition is that, a
speech recognition engine recognizes all words uttered by a human but, practically
the performance of a speech recognition engine depends on number of factors.
Vocabularies, multiple users and users and noisy environment are the major factors
that are counted in as the depending factors for a speech recognition engine.
Types of speech recognition
Speech recognition systems can be divided into the number of classes based
on their ability to recognize that words and list of words they have. A few classes of
speech recognition are classified as under:
Isolated Speech

Isolated words usually involve a pause between two utterances; it doesn’t


mean that it only accepts a single word but instead it requires one utterance at a
time.
Connected Speech
Connected words or connected speech is similar to isolated speech but allow
separate utterances with minimal pause between them.
Continuous speech

Continuous speech allow the user to speak almost naturally , it is also called
the computer dictation.
Spontaneous Speech

At a basic level, it can be thought of as speech that is natural sounding and not
rehearsed. An ASR system with spontaneous speech ability should be able to handle a
variety of natural speech features such as words being run together, “ums” and
“ahs”, and even slight stutters.

speech while a machine requires training, computer requires help for separating the
speech sound from the other sounds.
Factors on the speech recognition:
Homonyms: are the words that are differently spelled and have the
different meaning but acquires the same meaning, for example “there” “their”
5
y 1903107

“be” and “bee”, “cool” and “coal”. This is a challenge for computer machine to
distinguish between such types of phrases that sound alike.

Overlapping speeches: a second challenge in the process, is to


understand the speech uttered by different users, current systems have a
difficulty to separate simultaneous speeches form multiple users.

Noise factor: the program requires hearing the words uttered by a human
distinctly and clearly. Any extra sound can create interference, first you
need to place system away form noisy environments and the n speak
clearly else the machine will confuse and will mix up the words.
The future of speech recognition :
• Dictation speech recognition will gradually become accepted.
• Accuracy will become better and better.
• Microphone and sound systems will be designed to adapt more
quickly to changing background noise levels, different environments,
with better recognition of extraneous material to be discarded.

• Greater use will be made of “intelligent systems” which will attempt


to guess what the speaker intended to say, rather than what was
actually said, as people often misspeak and make unintentional
mistakes.

Methodology
As an emerging technology , not all developers are familiar with speech recognition
technology . While the basic functions of both speech synthesis and speech
recognition takes only few minutes to understand (after all, most people learn to
speak and listen by age two), there are subtle and powerful capabilities provided by
computerized speech that developers will want to understand and utilize.
An understanding of the capabilities and limitations of speech technology is also
important for developers in making decisions about whether a particular applications
will benefit from the use of speech input and output.

6
y 1903107

System Requirnment Table:

Component Minimum Recommende


d
CPU 1.6Ghz 2.53Ghz
RAM 2 GB 4 GB
Microphone Mic High quality
Microphone
Sound card Sound card High quality CPU:
earphones
Our
Application depend on efficiency of CPU(central processing unit).

This is because a large amount of digital filtering and signal processing can take
place in ASR(Automated Speech Recognition ).

7
y 1903107

Existing System

Speech recognition is a vast research field for researchers in modern era. Earlier,
the human language was processed by the computer system for speech
recognition. ... In the existing systems, the recognition rate is very less and the
noise ration during the recognition process creates a problem.Sep 28, 2020

Proposed System

Automatic Speech Recognition. Many researchers have proposed ASR system using a
traditional feature like MFCC, LPC, linear predictive cepstral coefficient (LPCC), and PLP
(perceptual linear prediction) [26–28]. It is challenging to develop an
automatic speech recognizer in presence of noise.

8
y 1903107

Feasibility Study :

Feasibility Study has several aspects:

Technical Feasibility
Scheduling Feasibility
Financial Feasibility
Operational Feasibility
Social and Ethical Considerations
Legal Feasibility

Through these studies were obtained on the conclusions and proposals for the project
:

Technical Feasibility
There are many of components that can build our system :( hardware
,software , and human components ).
Hardware components
Network communication
M odem for connecting to internet , Connecting Wires .

Computer components :
computer devices which are use to implements the application
(Speech Recognition System )

Component Minimum Recommended


CPU 1.6 GHz 2.53GHz
RAM 2 GB 4gb

Human Components Programmers, Analyzers, Designers and etc...

9
y 1903107

Software Requirement Specifications (SRS)

General working mechanism of speech recognition

When one thinks about speaking to computers, the first image is usually
speech recognition, the conversion of an acoustic signal to a stream of
words. After many years of research, speech recognition technology is
beginning to pass the threshold of practicality. The last decade has
witnessed dramatic improvement in speech recognition technology, to the
extent that high performance algorithms and systems are becoming
available.

Wide varieties of techniques with different levels of speech recognition are


used to perform speech recognition. The speech recognition process is
performed by a software component known as the speech recognition
engine. The primary function of the speech recognition engine is to process
spoken input word and translate it into text that an application understood.
The application can be work in two different mode Command and control
mode some times referred as voice navigation and Dictation mode.

10
y 1903107

Flowchart of a speech recognition

Speach Speech Vectors


Robust
analysis
processing

Model Feature vectors Result


Speech
Recognition

11
y 1903107

12
y 1903107

UserInterface

MainForm

Code the main window and movement between the windows by voice
Option Strict On

ImportsSystem.Speech.Recognition
' Add reference Assemblies Framework
System.Speech
ImportsSystem.Speech.Recognition.SrgsGrammar
' Adding this is unnecessary on
my PC

ImportsSystem.Runtime.InteropServices
'For Monitor Command
ImportsSystem.Speech
ImportsSystem.Drawing.Drawing2D
ImportsSystem.ComponentModel
ImportsDMSoft
Public ClassForm5
13
y 1903107

Dim a As New Speech.Synthesis.SpeechSynthesizer


Private WithEvents OutputListBox As New ListBox With {.Dock =
DockStyle.Fill, .IntegralHeight = False, .ForeColor = Color.AntiqueWhite,
.BackColor = Color.Green}
Private WithEvents SpeechEngine As New
System.Speech.Recognition.SpeechRecognitionEngine(System.Globalization.Cult
ureInfo.GetCultureInfo("en-us"))
Dim tms As Integer = 0
Dim st As String
Dim WithEvents recognizer As SpeechRecognitionEngine

Dim Neuro As New Speech.Synthesis.SpeechSynthesizer


Public SkinOb As DMSoft.SkinCrafter

Private Sub Form5_Load(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles MyBase.Load
Me.CenterToScreen()
a.SpeakAsync("my name is report")
a.SpeakAsync("welcome by you tell your computer what do you want ")
' The code in CODE SECTION has to be called before InitializeComponent()
function
' --------- Begin of CODE SECTION ----------- '
DMSoft.SkinCrafter.Init()
SkinOb = New DMSoft.SkinCrafter
'These function parameters are used for Skincrafter DEMO
SkinOb.InitLicenKeys("SKINCRAFTER", "SKINCRAFTER.COM",
"support@skincrafter.com",
"DEMOSKINCRAFTERLICENCE")
SkinOb.InitDecoration(CBool(1))
' --------- End of CODE SECTION ---------- '

SkinOb.LoadSkinFromFile("C:\Users\fathail\Desktop\vb\project\A_67.skf")
SkinOb.ApplySkin()
Me.Text = "Speech recognition, by Doc Oc, version:" &
My.Application.Info.Version.ToString & " , say hello to piss the pc off"

Controls.Add(OutputListBox)
SpeechEngine.LoadGrammar(New
System.Speech.Recognition.DictationGrammar) 14
SpeechEngine.SetInputToDefaultAudioDevice()
y 1903107

SpeechEngine.RecognizeAsync(Speech.Recognition.RecognizeMode.Multiple)
recognizer = New SpeechRecognitionEngine()
recognizer.SetInputToDefaultAudioDevice()

End Sub

Private Sub Form5_FormClosing(sender As Object, e As EventArgs) Handles


Me.FormClosing
Try
SpeechEngine.RecognizeAsyncCancel()
SpeechEngine.Dispose()
Catch ex As Exception
End Try
End Sub

Private Sub SpeechEngine_SpeechRecognized(sender As Object, e As


System.Speech.Recognition.SpeechRecognizedEventArgs) Handles
SpeechEngine.SpeechRecognized
OutputListBox.Items.Add("You said: " & e.Result.Text)
' a.SpeakAsync("You said: " & e.Result.Text)
' If e.Result.Text.ToLower.Contains("add") = True Or
e.Result.Text.ToLower.Contains("her") = True Or
e.Result.Text.ToLower.Contains("hello") = True Or
e.Result.Text.ToLower.Contains("o") = True Or
e.Result.Text.ToLower.Contains("who") = True Or
e.Result.Text.ToLower.Contains("will") = True Or
e.Result.Text.ToLower.Contains("hole") = True Or
e.Result.Text.ToLower.Contains("whole") = True Or
e.Result.Text.ToLower.Contains("hold") Or e.Result.Text.ToLower.Contains("se")
= True Or e.Result.Text.ToLower.Contains("c") = True Then st
= e.Result.Text
Label2.Text = e.Result.Text

Select Case e.Result.Text


Case "add"
Dim MyForm As New Form1 15
MyForm.Show()
y 1903107

Case "view"
Dim MyForm As New Form2
MyForm.Show()
Case "speech"
Dim MyForm As New Form3

16
y 1903107

MyForm.Show()
Case "close"
Me.Close()
Case "maximize"
Me.WindowState = FormWindowState.Maximized
Case "minimize"
Me.WindowState = FormWindowState.Minimized
End Select
' End If
End Sub

Private Sub AddCommandsToolStripMenuItem_Click(senderAs Object , e As


EventArgs ) Handles AddCommandsToolStripMenuItem.Click
Dim MyForm As New Form1
MyForm.Show()
End Sub

Private Sub ViewCommandsToolStripMenuItem_Click(sender As Object , e As


EventArgs ) Handles ViewCommandsToolStripMenuItem.Click
Dim MyForm As New Form2
MyForm.Show()
End Sub

Private Sub SpeachRecognationToolStripMenuItem_Click(senderAs Object , e


As EventArgs ) Handles SpeachRecognationToolStripMenuItem.Click
Di m MyForm As New Form3
MyForm.Show()
End Sub

Private Sub ExitToolStripMenuItem_Click(sender As Object , e As EventArgs )


Handles ExitToolStripMenuItem.Click
Me.Close()
End Sub

End Class

17
y 1903107

Add Commands

Code add commands To Database


Imports System.Data.OleDb
Imports System.IO. StreamReader

Imports System.Drawing.Drawing2D
Imports System.ComponentModel
Imports DMSoft

18
Public Class Form1
y 1903107

Dim CnString As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data


Source=C:\Users\fathail\Desktop\vb\project\project\db2.accdb;
Persist Security Info=False;"

Dim Conn As New OleDbConnection(CnString)


Dim DataSet1 As New DataSet
Dim DataAdapter1 As OleDbDataAdapter
Dim CMD As New OleDbCommand
Dim SQLstr As String = "SELECT * FROM CustomCommands"
Dim sqcomand As OleDbCommand
Public SkinOb As DMSoft.SkinCrafter

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles


MyBase.Load
Me.CenterToScreen()

' ////////////////////////////////////////////////////////

' The code in CODE SECTION has to be called before InitializeComponent()


function
' --------- Begin of CODE SECTION ----------- '
DMSoft.SkinCrafter.Init()
SkinOb = New DMSoft.SkinCrafter
'These function parameters are used for Skincrafter DEMO
SkinOb.InitLicenKeys("SKINCRAFTER", "SKINCRAFTER.COM",
"support@skincrafter.com",
"DEMOSKINCRAFTERLICENCE")
SkinOb.InitDecoration(1)
' --------- End of CODE SECTION ---------- '

SkinOb.LoadSkinFromFile("C:\Users\fathail\Desktop\vb\project\A_67.skf")
SkinOb.ApplySkin()
Try
19
Conn.Open()
Dim DataAdapter1 As New OleDbDataAdapter(SQLstr, Conn)
y 1903107

DataAdapter1.Fill(DataSet1, "CustomCommands")

dataGridView1.DataSource = DataSet1
dataGridView1.DataMember = "CustomCommands"

20
y 1903107

dataGridView1.Refresh()
Conn.Close()
Catch e1 As Exception
Console.WriteLine(e1)
End Try

End Sub

Private Sub btnSave_Click(sender As Object , e As EventArgs ) Handles


btnSave.Click

If Trim(text1.Text) <> "" And Trim( text2.Text) <> "" And Trim(text3.Text)
<> "" Then

sqcomand = New OleDbCommand("insert into CustomCommands


(CommonField ,Command,Result)values ('" & text1.Text & "','" & text2.Text &
"','" & text3.Text & "')", Conn)
Conn.Open()
sqcomand.ExecuteNonQuery()
Conn.Close()
MsgBox( "save is done", MsgBoxStyle .Information +
MsgBoxStyle .MsgBoxRight, "save done")

Else
MsgBox( "please enter field data"
, MsgBoxStyle .Critical, "wrong in data
enter")
Exit Sub
End If

End Sub

Private Sub radioButton1_CheckedChanged(senderAs Object , e As EventArgs )


Handles radioButton1.CheckedChanged
If radioButton1.Checked = True Then

btnOpen.Visible = False
text2.Text = "http://www." 21
text2.Focus()
y 1903107

End If
End Sub

Private Sub radioButton2_CheckedChanged(senderAs Object, e As EventArgs )


Handles radioButton2.CheckedChanged
If radioButton2.Checked =True Then

btnOpen.Visible = True
text2.Text = ""
End If
End Sub

Private Sub btnOpen_Click(senderAs Ob ject, e As EventArgs ) Handles


btnOpen.Click
Dim dlg As New OpenFileDialog
dlg.ShowDialog()

' If dlg.ShowDialog = Windows.Forms.DialogResult.OK Then


Dim fileName As String
fileName = dlg.FileName
MsgBox(fileName)
'End If
End Sub

Private Sub btnToListbox_Click(sender As Object, e As EventArgs ) Handles


btnToListbox.Click

Dim MyForm As New Form2


MyForm.Show()

End Sub

Private Sub button1_Click(senderAs Object, e As EventArgs ) Handles


button1.Click
Me.Close()
End Sub

Private Sub Button2_Click(sender As Object, e As EventArgs ) Handles


Button2.Click
sqcomand =New OleDbCommand("delete from CustomCommands" , Conn)
Conn.Open()
sqcomand.ExecuteNonQuery() 22
Conn.Close()
y 1903107

MsgBox( "delete is done", MsgBoxStyle .Information +


MsgBoxStyle .MsgBoxRight, "delet ")
End Sub

Private Sub Button3_Click(sender As Object , e As EventArgs ) Handles


Button3.Click
text1.Text = ""
text2.Text = "http://www."
text3.Text = ""
text1.Focus.Equals( True)
End Sub
End Class

View commands

23
y 1903107

Code view commands:


ImportsSystem.Data.OleDb
ImportsSystem.IO.StreamReader

Public Class Form2


Dim CnString As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data
Source=C:\Users\fathail\Desktop\vb\project\project\db2.accdb;
Persist Security Info=False;"

Dim Conn As New OleDbConnection(CnString)


Dim DataSet1As New DataSet
Dim DataAdapter1As OleDbDataAdapter
Dim CMD As New OleDbCommand
Private SubForm2_Load(senderAs Object, e As EventArgs) Handles
MyBase.Load
Conn.Open()

Dim dt1 As New DataTable


Dim dlebgrabAs String = "SELECT * FROM CustomCommands"
Dim cmd As New OleDbCommand(dlebgrab, Conn)
Dim adtpAs New OleDbDataAdapter(cmd)
adtp.SelectCommand = cmd
adtp.Fill(dt1)
ListBox1.DataSource = dt1
ListBox1.DisplayMember ="CommonField"
ListBox2.DataSource = dt1
ListBox2.DisplayMember ="Command"
ListBox3.DataSource = dt1
ListBox3.DisplayMember ="Result"
End Sub
End Class

24
y 1903107

.Grammar is loading

25
y 1903107

Imports System.Speech.Recognition ' Add reference Assemblies Framework


System.Speech
Imports System.Speech.Recognition.SrgsGrammar ' Adding this is unnecessary
on my PC

Imports System.Runtime.InteropServices 'For Monitor Command


Imports System.Speech

Public Class Form3


Dim a As New Speech.Synthesis.SpeechSynthesizer
Private WithEvents OutputListBox As New ListBox With {.Dock =
DockStyle.Fill, .IntegralHeight = False, .ForeColor = Color.AntiqueWhite,
.BackColor = Color.Green}
Private WithEvents SpeechEngine As New
System.Speech.Recognition.SpeechRecognitionEngine(System.Globalization.Cult
ureInfo.GetCultureInfo("en-us"))
Dim tms As Integer = 0
Dim st As String
Dim WithEvents recognizer As SpeechRecognitionEngine

Dim Neuro As New Speech.Synthesis.SpeechSynthesizer

Private Sub Form3_Load(sender As Object, e As EventArgs) Handles


MyBase.Load

Me.Text = "Speech recognition, by Doc Oc, version:" &


My.Application.Info.Version.ToString & " , say hello to piss the pc off"

Controls.Add(OutputListBox)
SpeechEngine.LoadGrammar(New
System.Speech.Recognition.DictationGrammar)
SpeechEngine.SetInputToDefaultAudioDevice()

SpeechEngine.RecognizeAsync(Speech.Recognition.RecognizeMode.Multiple)

recognizer = New SpeechRecognitionEngine()


recognizer.SetInputToDefaultAudioDevice() 26
y 1903107

' Voice commands in Commands.txt are Hello mister monkeyboy, Goodbye


and What is up.
Dim ReadLines As New
System.IO.StreamReader("C:\Users\fathail\Desktop\vb\project\Command.txt")

Do Until ReadLines.EndOfStream
Dim NewGrammar As New Grammar(New Choices(New
String(CType(ReadLines.ReadLine(), Char()))))
recognizer.LoadGrammarAsync(NewGrammar)
Loop

ReadLines.Close() recognizer.RecognizeAsync(RecognizeMode.Multiple)

End Sub

Private Sub Form3_FormClosing(sender As Object, e As EventArgs) Handles


Me.FormClosing
Try
SpeechEngine.RecognizeAsyncCancel()
SpeechEngine.Dispose()
Catch ex As Exception
End Try
End Sub
Private Sub SpeechEngine_SpeechRecognized(sender As Object, e As
System.Speech.Recognition.SpeechRecognizedEventArgs) Handles
SpeechEngine.SpeechRecognized
OutputListBox.Items.Add("You said: " & e.Result.Text)
' a.SpeakAsync("You said: " & e.Result.Text)
If e.Result.Text.ToLower.Contains("home") = True Or
e.Result.Text.ToLower.Contains("her") = True Or
e.Result.Text.ToLower.Contains("hello") = True Or
e.Result.Text.ToLower.Contains("o") = True Or
e.Result.Text.ToLower.Contains("who") = True Or
e.Result.Text.ToLower.Contains("will") = True Or
e.Result.Text.ToLower.Contains("hole") = True Or
e.Result.Text.ToLower.Contains("whole") = True Or
e.Result.Text.ToLower.Contains("hold") Or e.Result.Text.ToLower.Contains("se")
= True Or e.Result.Text.ToLower.Contains("c") = True Then st 27
= e.Result.Text
y 1903107

Select Case e.Result.Text.ToUpper

28
y 1903107

Case Is = "open facebook"


a.SpeakAsync( "now")
' Shell("notepad.exe", AppWinStyle.NormalFocus, False)
System.Diagnostics. Process.Start("http://www.facebook.com")

Case Is = "open google"


' Application.Exit()
System.Diagnostics. Process.Start("http://www.google.com")
Case Is = "open yahoo"
Case Is =”yahoo”
System.Diagnostics. Process.Start("http://www.yahoo.com")
Case Is = "open pandora"
System.Diagnostics. Process.Start("http://www.pandora.com ")
Case Is = "open thepiratebay"
System.Diagnostics. Process.Start("http://www.thepiratebay.s
e")
Case Is = "SIX"
'System.Diagnostics.Process.Start("http://www.youtube.com")
OutputListBox.Text = " "

Case Is = "Open notepad"


a.Speak("Running Notepad.")
Shell( "notepad.exe", AppWinStyle .NormalFocus, False )
Case Is = "EIGHT"
a.S peak("CLOSE Notepad." )
' Application.Exit()
Case Is = "shutdown"
a.Speak("shutdown")
System.Diagnostics. Process.Start("shutdown", "-s")

Case Is = "RESTART"
a.Speak("restart")
System.Diagnostics. Process.Start("shutdown", "-r")

Case Is = "LOG OFF"


a.Speak("log off" )
System.Diagnostics. Process.Start("shutdown", "-l" )
Case Is = "WHAT TIME IS IT"

a.Speak(Format(Now, "Short Time" ))


Case Is = "C"
29
a.Speak("which color you want")
y 1903107

Timer1.Enabled True
=
Timer1.Start()

Case Is= "HOWS THE WEA


THER"

System.Diagnostics.
Process.Start("h ps:// w.google.com/webhp? o
m -instant&ion=1&ie=UTF tt ww sourceid=chr
-8#output=search&sclient=psy
-
eab&q=weather&oq=&gs_l=&pbx=1&bav=on.2,or.r_cp.r_qf.&bvm=bv.47008514,
d.eWU&fp=6c7f8a5fed4db490&biw=1366&bih=643&ion=1&pf=p&pdl=300"
)
a.Speak("Searching for local weather"
)
Case Is= "HELLO "
a.Speak("Hello sir")
Case Is= "GOODBYE "
a.Speak("Until next time" )
Me.Close()
Case Is= "OPEN DISK DRIVE"
'Case Is = "NINE"
a.Speak("Its now open" )
DimoWMP = CreateObject( "WMPlayer.OCX.7"
)
DimCDROM = oWMP.cdromCollection
If CDROM.Count =Then 2
CDROM.Item(1).Ejec t()

End If

End

EndSelect
EndIf
EndSub

30
y 1903107

Private Sub recognizer_LoadGrammarCompleted(sender


As Object, e As
LoadGrammarCompletedEventArgs) Handles
recognizer.LoadGrammarCompleted

Dim grammarNameAs String = e.Grammar.Name


Dim grammarLoadedAs Boolean = e.Grammar.Loaded

If e.[Error] IsNot Nothing Then


' Add exception handling code here.
Label1.Text = "LoadGrammar for "& grammarName &" failed with a " &
e.[Error].[GetType]().Name & "."
End If

Label1.Text = ( "Grammar " & grammarName &" " & If (( grammarLoaded),


"Is", "Is Not") & " loaded.")

End Sub

Private Sub recognizer_SpeechRecognized(sender


As Object, e As
SpeechRecognizedEventArgs) Handles recognizer.SpeechRecognized

Label2.Text = "Grammar "& e.Result.Grammar.Name& " " & e.Result.Text

Select Case e.Result.Text.ToUpper


Case Is = "HELLO MISTER MONKEYBOY"
Neuro.SpeakAsync("Hello Mister Monkeyboy!")
Process.Start("Notepad")
Case Is = "GOODBYE"
Neuro.SpeakAsync("Goodbye!")
Me.Close()
End
Case Is = "WHAT IS UP"
Neuro.SpeakAsync("Whaas up?")
End Select

End Sub

Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles


Timer1.Tick
' Select Case e.Result.Text
'Case Is = "red"
OutputListBox.BackColor = Color.Yellow 31
OutputListBox.BackColor = Color.Red
y 1903107

' Case Is = "white"


OutputListBox.BackColor = Color .White
' Case Is = "Yellow"

'End Select
OutputListBox.BackColor = Color .Red
End Sub
End Class

9.4. Changing the theme for all windows(forms):

Code for changing the themes :


Option Strict On

Imports System.Speech 32
Imports System.Speech.Recognition
y 1903107

Imports System.Speech.Recognition.SrgsGrammar

Public Class Form4

Dim WithEvents reco As New SpeechRecognitionEngine


Dim synth As New Synthesis. SpeechSynthesizer

Private Sub Form4_Load( ByVal sender As System.Object, ByVal e As


System.EventArgs ) Handles MyBase .Load

Try

Dim gram As New SrgsDocument


Dim colorRule As New SrgsRule ( "color")
Dim colorsList As New SrgsOneOf ( "red", "green", "Yellow" , "Black" )

colorRule.Add(colorsList)
gram.Rules.Add(colorRule)
gram.Root = colorRule
reco.LoadGrammarAsync( New Recognition. Grammar( gram))
reco.SetInputToDefaultAudioDevice()
reco.RecognizeAsync( RecognizeMode .Multiple)

Catch s As Exception
MessageBox .Show(s.Message)
End Try

End Sub

Private Sub reco_SpeechDetected(ByVal sender As Object , ByVal e As


System.Speech.Recognition. SpeechDetectedEventArgs) Handles
reco.SpeechDetected
Label1.Text = "Speech Detected"
End Sub

Private Sub reco_SpeechRecognized(ByVal sender As Object , ByVal e As


System.Speech.Recognition. RecognitionEventArgs ) Handles
reco.SpeechRecognized
Label2.Text = e.Result.Text
Select Case e.Result.Text
Case "red" 33
SetColor( Color .Red)
y 1903107

Case "green"
SetColor( Color .Lime)
Case "Yellow"
SetColor( Color .Yellow)
Case "black"
SetColor( Color .Black)
Case "blue"
SetColor( Color .Blue)
End Select
End Sub

Private Sub SetColor( ByVal color As System.Drawing. Color )


reco.RecognizeAsyncCancel()
reco.RecognizeAsyncStop()
synth.Speak("setting the back color to " & color.ToString)
Me.BackColor = color
reco.RecognizeAsync( RecognizeMode .Multiple)
End Sub

End Class

34
y 1903107

35

You might also like