We're building a brand new version of the site, and we'd love to hear your ideas
Members
Technology Zones
IBM Learning Center
Articles
Hosted By
Info
|
[1989] Using Speech Recognition and Text to Speech
Last post 08-14-2007 7:31 AM by Amsakanna. 72 replies.
-
Advertisement
|
|
-
-
-
-
yogeshspsoft


- Joined on 07-20-2005

- Points 40
|
Speech Recognition not working
Hello,
I have tried all the steps as mentioned in the "Speech Recognition Program" but the things are not working.
on the form load the code is:
Private Sub Form_Load()
DirectSR1.GrammarFromFile App.Path & "\SpeechFile.txt"
DirectSR1.GrammarFromString (totaldata)
DirectSR1.Activate
End Sub
the file is placed in the application path & content of the file is as follows:
[<Start>]
<start>=Memo
<start>=Sound
<start>=New Media
<start>=Music
<start>=User Control
<start>=Options
<start>=Shut Down
<start>=Disable
<start>=View Logs
<start>=What Time Is It
<start>=Time
<start>=What Is Today's Date
<start>=Microsoft Word
<start>=Microsoft Excel
The code in "PhraseFinish" is as follows:
Private Sub DirectSR1_PhraseFinish(ByVal flags As Long, ByVal beginhi As Long, ByVal beginlo As Long, ByVal endhi As Long, ByVal endlo As Long, ByVal Phrase As String, ByVal parsed As String, ByVal results As Long)
If Phrase <> "" Then
Label1.Caption = "Matched word is " & Phrase
Else
Label1.Caption = "No word matched"
End If
Text1.Text = Phrase
End Sub
So, when i speak the words like Options, Sound, Disable, Time nothing is reflected in the textbox.
I do not get the option of "Control Panel > Speech" in my Control pannel. Hope this should not be the problem.
Hope you find something which will be a ray of hope for me. Thanks !!!!!
|
|
-
-
BumbleBee


- Joined on 07-20-2005

- Points 5
|
I had the problem that it wouldn't respond, however I figured out that I hadn't changed the following line to my name "BumbleBee".
Const YOURNAME = "Alex 'You can replace this with your name"
to
Const YOURNAME = "BumbleBee"
Works like a charm now
Btw, I added another line that acknowledges that the program heard something even if it didn't understand what is being said.
Private Sub vcrVoice_PhraseFinish(ByVal flags As Long, ByVal beginhi As Long, ByVal beginlo As Long, ByVal endhi As Long, ByVal endlo As Long, ByVal Phrase As String, ByVal parsed As String, ByVal results As Long)
Select Case Phrase
Case Is = YOURNAME
spkSpeak.Speak "Hello " & YOURNAME
Case Is = "What year is it?"
spkSpeak.Speak Year(Date)
Case Else
spkSpeak.Speak "What did you say?"
End Select
End Sub
Thank you Alex for this awesome tutorial!!!
|
|
-
-
-
vaijayanthi


- Joined on 09-04-2005

- Points 10
|
direct speech recognition code
i am doing a project on direct speech recognition . i found the code for my project on your website. in user comments i found some of them reply that this code is not working .
i would like to give some suggestions for it.i worked this code with a little modifications in my procedure.it worked
the code is:
Option Explicit
Private Declare Function ShellExecute Lib "shell32.dll" _
Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal _
lpOperation As String, ByVal lpFile As String, ByVal _
lpParameters As String, ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long
Private Sub Form_Load()
Dim totaldata As String
'define configuration
'[Grammer], set language to english (1033)
'[<Start>], define the words we are looking for
totaldata = "[Grammar]" & vbCrLf & _
"langid = 1033" & vbCrLf & _
"type=cfg" & vbCrLf & _
"[<Start>]" & vbCrLf & _
"<start>=Notepad" & vbCrLf & _
"<start>=Volume" & vbCrLf & _
"<start>=porta" & vbCrLf
Label1.Caption = totaldata
DirectSR1.GrammarFromString (totaldata)
''''DirectSR1.Activate
End Sub
Private Sub Command1_Click()
Dim totaldata As String
Dim phrase As String
Select Case Command1.Caption
Case "disable"
DirectSR1.Deactivate
Command1.Caption = "enable"
Label1 = "disabled"
Case "enable"
DirectSR1.Activate
Command1.Caption = "disable"
Label1 = "Ready"
''''Call DirectSR1_PhraseFinish(0, 0, 0, 0, 0, totaldata, phrase, 0)
End Select
End Sub
Private Sub DirectSR1_PhraseFinish(ByVal flags As Long, _
ByVal beginhi As Long, ByVal beginlo As Long, ByVal endhi As Long, _
ByVal endlo As Long, ByVal phrase As String, ByVal parsed As String, ByVal results As Long)
Dim sFile As String
Dim noth As Long
Select Case phrase
Case "Notepad"
sFile = "\system32\notepad.exe"
noth = ShellExecute(0, "OPEN", Environ("SystemRoot") & sFile, "", "", 1)
Case "Volume"
sFile = "\system32\sndvol32.exe"
noth = ShellExecute(0, "OPEN", Environ("SystemRoot") & sFile, "", "", 1)
Case "Mediaplayer"
sFile = "\system32\mediaplayer.exe"
noth = ShellExecute(0, "OPEN", Environ("SystemRoot") & sFile, "", "", 1)
End Select
If phrase <> "" Then
Label1.Caption = "Matched word is " & phrase
Else
Label1.Caption = "No word matched"
End If
End Sub
1. add the phrase used in this code in speech recognition dictionary by
selecting tools option in the language bar and by choosing add/delete words option.
2.check whether your speech recognition engine works perfectly.i used dragon natural speech recognition version 7, in addition to microsoft speech recognition engine. after installing the engine you would find dragon activex control in components property in visual basic.
In this method it opens the windows applications on telling the phrase.
|
|
-
-
-
-
-
-
-
Amsakanna


- Joined on 12-13-2006

- Points 5
|
Re: [1989] Using Speech Recognition and Text to Speech
hi,
me from INDIA..... wanna know abt speech recog vb soft..... tell me how to successfully run that....... i've problem with that line ["grammar"].... error: invalid outside procedure...... thanx........
|
|
|
Search
Code Samples
New Members
|