Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  HOME    TRACKER    Visual Basic

Sapi 5 Add Words To Voice Recognition Dictionary

Hello, I am using the SAPI5.3 api in a sample vb app...the app has the following code:
'=============================================================================' This sample demonstrates how to do simple dictation in VB with SAPI 5.1.'' It uses shared reco context object, uses the default audio input, loads in' dictation grammar, sets up event handlers, and shows the recognized text in' the dialog text box.'' Note: since the text box is using system locale, it may not correctly show' characters in other languages. For example, if you use Chinese Speech' Recognition engine as the default engine on your English OS, the text box' may show garbage even though the engine recognizes Chinese.'' Copyright @ 2001 Microsoft Corporation All Rights Reserved.''=============================================================================Option ExplicitDim WithEvents RecoContext As SpSharedRecoContextDim Grammar As ISpeechRecoGrammarDim Voice As SpVoiceDim m_bRecoRunning As BooleanDim m_cChars As IntegerPrivate Sub Form_Load() SetState False m_cChars = 0 Set Voice = New SpVoice Timer1.Enabled = TrueEnd SubPrivate Sub btnStart_Click() Debug.Assert Not m_bRecoRunning ' Initialize recognition context object and grammar object, then ' start dictation If (RecoContext Is Nothing) Then Debug.Print "Initializing SAPI reco context object..." Set RecoContext = New SpSharedRecoContext Set Grammar = RecoContext.CreateGrammar(1) Grammar.DictationLoad End If Grammar.DictationSetState SGDSActive SetState TrueEnd SubPrivate Sub btnStop_Click() Debug.Assert m_bRecoRunning Grammar.DictationSetState SGDSInactive SetState FalseEnd Sub' This function handles Recognition event from the reco context object.' Recognition event is fired when the speech recognition engines recognizes' a sequences of words.Private Sub RecoContext_Recognition(ByVal StreamNumber As Long, _ ByVal StreamPosition As Variant, _ ByVal RecognitionType As SpeechRecognitionType, _ ByVal Result As ISpeechRecoResult _ ) Dim strText As String strText = Result.PhraseInfo.GetText Debug.Print "Recognition: " & strText & ", " & _ StreamNumber & ", " & StreamPosition ' Append the new text to the text box, and add a space at the end of the ' text so that it looks better txtSpeech.SelStart = m_cChars txtSpeech.SelText = strText & " " m_cChars = m_cChars + 1 + Len(strText) Debug.Assert m_bRecoRunning Grammar.DictationSetState SGDSInactive SetState False Voice.Speak strText txtSpeech.Text = "" Debug.Print "Initializing SAPI reco context object..." Set RecoContext = New SpSharedRecoContext Set Grammar = RecoContext.CreateGrammar(1) Grammar.DictationLoad Grammar.DictationSetState SGDSActive SetState TrueEnd Sub' This function handles the state of Start and Stop buttons according to' whether dictation is running.Private Sub SetState(ByVal bNewState As Boolean) m_bRecoRunning = bNewState btnStart.Enabled = Not m_bRecoRunning btnStop.Enabled = m_bRecoRunningEnd Sub
This program will add any text spoken to the problem is some words are not there a way to add these to a 'dictionary' like you can with ms words voice recognition?

View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
SAPI Speech Recognition
SAPI speech recognition ...?

Voice Recognition, Not Speach Recognition..
hi everyone!^^

hope you could help me out a bit..^^

1. do any of you know of any algorithm on voice recognition? not the speach-to-text/text-to-speach thingy.. i want an algorithm that could determine whose voice it was which was played.. for example, i would have a database of wav files of different people and when i receive a voice from the mic, the algo could determine, based on the current database, whose voice it was.. is this possible?

2. is it possible to detect and delete the start and end of a wav file which has no sound? like for example, from wav file recorded from a mic.. there is bound to be some part at the start and end of the wav file that has no sound right?


Voice SAPI
Im totally new to VB. The following code works on Windows XP but not on Windows 2000. I'm thinkng windows 2000 has some outdated version of VB or Voice SAPI. I searched around MSDN but I didn't really find anything about what OS has what version.

All I am trying to do is to make a script say something. Does anyone know the corresponding VB code that would work on Win 2000 or tell me what I need to install on Win 2000 to make the following work?

Set ISpeechVoice = CreateObject("SAPI.SpVoice")
varname = ISpeechVoice.Speak("Hello", 0)

Voice Recognization With SAPI

I have downloaded SAPI and I want to use it to recognize speech.
Can anybody give me a sample to recognize speech. Or something else for speech to text operation thank you.

I have done text to speech by xcommand.oca file but I want to do opposite(sp to txt)

Please help any one.
Thank you.

SAPI 5.1 Voice Recording
I am using SAPI 5.1 for TTS and wants to add another feature - voice recording.
I want to know how to record voice and save to WAV file using the SAPI 5.1 SDK

/edit moved to VB general by johnminkjan edit/

Edited by - johnminkjan on 12/11/2004 11:50:01 AM

Voice Recognition
Hi i know this is a very complicated subject but i wonder does somone tried to do it in VB?

If yes please give me ideas how to ,waht you tried what worked what can work.

If no why what was the reason it seemed not worth trying.

I want to do a simple Voice Recognition Program (as simple as a voice recognition can be ).

Any sugestions are welcomed.

Voice Recognition
someone knows how to do or what tool I can use to do a voice recognition divise...
how can I calculate the wave leght of a record file??

THANK's you again!!
Lucas from Argentina!
forgive my english!

Voice Recognition :(
does anyone remember the component name of voice recognition thanks,cause i'm a bit confused

Voice Recognition
Anybody knows how to get documentation on Microsoft Direct Voice Recognition ActiveX control?
I am trying to record some audio and then try to recognize some phrases in the file, may be the fileName property could help but I dont know how to use it!!!

Voice Recognition
Hello Folks!
Is it possible to record some audio into a file and then analyze it (recognize some phrases in it?)
Please note that I need to save the recording first

Voice Recognition
Hi all
I have this video database proggy that im trying to run on my dvd computer.
Now my dvd computer sits in the lounge room with a tv as a monitor and i watch my dvd collection from the hard drive.
Now I though it would be very cool and impressive when ppl come over is to add voice recognition
Now i have no problem working the VoiceRec it works fine. My problem is this...

when i add a movie title to the database in order for the VoiceRec to recognize the movie title i have to add the following:

the gramma file is linked to a txt file so updating that is no problem and easy

However i came to relize this

VB Code:
Private Sub reco_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 = "Show me top 10" And Disallow Then        Bot.Play "DoMagic1"        Bot.Play "DoMagic2"     End If     '''''''''' PHRASE 2    If Phrase = "Play Pretty Woman" Then        Bot.Play "DoMagic1"        Bot.Play "DoMagic2"            Bot.Play "Idle1_1"        Bot.Speak "Launching Movie"        Exit Sub        ' This will launch the RAW DvD file with the default application        Shell "C:prettywoman.vob", vbNormalFocus    End If

My question is how can i run phrase 2 and all of its coresponding code from a database
and not have to update the code manually every time a new entry is submitted.

I hope this makes sense
thanks in advance

Voice Recognition
Using the Microsoft Direct Voice Recognition component how would i make it my word appear in a text box on the form....

Voice Recognition
Anyone have a simple way to output EVERYTHING I say to say... A textbox?

I've used the Direct Speech Recognition and stuff to handle certian keywords, But I want everything.

Any ideas/code? Thanks.

Voice Recognition...
HOw can I use voice recognition in my program?

Voice Recognition
Anyone successfully incorporated voice recognition into their apps.

As I understand it voice recognition is in its infancy, so the quality available is dubious, approx 60% success, even with trained engines.

Can anyone suggest an accurate voice recognition engine, or should I avoid trying to incorporate this feature?

Voice Recognition
pls tell me if there is a difference between MSAgent and Direct Speech recognition control. and i downloaded a couple of speech recognition and MSAgent examples but when i said stuff, nothing happened. I tested my microphone with Netmeeting 3.01 and it's working. Something wrong???

pls reply asap,


Voice Recognition
how easy is it to get voice recognition working with VB. Does anybody have any examples or code I could use.


Voice Recognition Help
Hi all,
I'm new to these forums and very new to VB I'm currently writing an app that requires Voice recognition I only require two commands:


I downloaded the Microsoft Voice Recognition Software at

And I don't have a clue how to use It I would really Aprecitte It if someone could point me in the right direction and maybe a bit of code

Voice Recognition
Does anyone know where I can find a beginner to intermediate course for VB's voice recognition online?


Voice Recognition
I read the article "Writing your first speech recognition program", and was intrigued enough to try it. But I'm having problems with the code...

Private Sub Form_Load()
Dim totaldata As String
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
    totaldata = totaldata _
    & "<start>=Notepad" & vbCrLf _
    & "<start>=Volume" & vbCrLf _
    & "<start>=Media Player" & vbCrLf
    DirectSR1.GrammarFromString (totaldata)
    DirectSR1.Activate 'start engine to begin recognizing voice commands
End Sub

I believe this code is to load an API function ShellExecute() when a voice match occurs.

The italicized is where I am getting the error "Compile error: Only comments may appear after End Sub, End Function, or End Property". Is the code in the proper module? The article states: "To declare the API put the following code on top of the form module". The code being referred to is the function line that is getting the error. So, I thought maybe I had it in the wrong module.

I hope this is enough to go on. Please help.

Best regards,


Voice Recognition Ocx
Does anyone knows a good ocx for voice recognition

Voice Recognition
hi there,

i have a prob, don't know how to do? it is easy to convert a text to voice with components, how i can read a voice with a microphone and then convert it into text, is there any components in vb6 to do that job?

thanx anyway, bye.


Voice Recognition
Has anyone done anything with voice recogition and VB? I am going to be creating an application
that will be used for dictation. It is supposed to be able to plug in the tape recorder output
to the Audio In for the sound card and they can play their tape of dictation and it will read in
all the words and put it into this special documentation software. If anybody has any ideas
or has done something similar please let me know.

Software Engineer

Words Dictionary
Hi all

I would like to know if it is possible to access MS Word's dictionary and review the words that they have listed there. Basically what I would like is to attain as many 5 letter words as possible for a game I am building.


Voice Recognition Device
Im trying to make a voice recognition device in vb. ive done all the subs for changing filename and deleting things and all that, but i havent made it recognise someones voice. I have no idea about how to do this, is there some sort of control i can use?

Using Voice Recognition With VBEditor?
Does anyone have any experience using voice recognition as a way to enter code inside the VB Editor? I am a programmer with tendonitis and I am wondering if this might be a way to alleviate my condition while I work. I am considering Dragon Naturally Speaking but the professional version (which allegedly works with the Excel VBE) is $695!

I am doing mostly Excel VBA for Excel 2000. I am using Windows XP Professional.


Voice Recognition And Comparison?

I'm interesting in playing around with voice recognition. What I'd eventually like to create is basically a voice-authorization console where it takes a short speech recording of a preset phrase and compares it to a pre-recorded sample to see if it is the same person.

Now, I'm at a loss as to how this should be gone about.

I believe I read somewhere that voice comparison is done through numerous different aspects of the Voice, such as Pitch, Tone, and/or Frequency. I'm unsure where I read this, and if it's even true, so if anyone could give some insight here, that would be great.

What I was basically thinking, in pseudo-code, would be the following sort of path:

1) Prompt user to Say String, and hit a key (To stop recording)
2) Extract Needed information from recorded sample (Pitch/tone/whatever?)
3) Compare these to known values, and if they are in a set threshold, grant access (Within a few points, allowing for fluctuations of the voice), or else deny it.

Any help on the subject would be great.


Voice Recognition Where To Start
hi guys,
i am a newbie and I really need your help.
I have developed some in interest in voice recognition or speaker identification but I Have no idea on where to start.
My desire is to be able to have the computer store voice files in database, compare them and retrieve them in a way that when i input it can discern that it is i , and when somebody else does input their voice it can identify the person; in case there is an input of a non registered it will give a notification of no match.

Voice Recognition Controls
Hey, I have been using Voice Tools 7.3 to do voice recognition in my Visual Basic programs, but i've been pretty unsatisfied with it. Does anyone else have any suggestions for voice recognition tools to use that are better? Thanks, Adam

Speech/voice Recognition
is there any Good speech/voice recognition that can recognize words through a microphone???

PLEASEE let me know! aSAP


Voice Recognition Question
Hello Pals;
I have got a project of Voice Recognition that uses 'Microsoft Direct Speech Recognition' and DirectSR Object .. I tried the code, but it does work with me, i dont know why?
Check Up the code please, or Try the project in the attached files.
How to use it? i used the mic to use my voice to send Oral Commands, but no results!

Option Explicit

Private Sub btnExit_Click()

Unload Me

End Sub

Private Sub btnExit_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Label2.ForeColor = vbBlack
End Sub

Private Sub Form_Load()

On Local Error Resume Next

'Load the voice commands from the commands text file...
Call LoadVoiceCommands(lstCommands)

'Setup the voice recognition control...
Call VR.Deactivate
Call VR.GrammarFromFile(App.Path & "Commands.Txt")
Call VR.Activate

End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Label2.ForeColor = vbRed
End Sub

Private Sub Label2_Click()
Shell = ("start")
End Sub

Private Sub lstCommands_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Label2.ForeColor = vbBlack
End Sub

Private Sub VR_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)

On Local Error Resume Next

'Check to see if we have a matching word...
If Trim$(Phrase) <> "" Then
Me.Caption = Phrase
Call ExecuteVoiceCommand(Me, Phrase)
Me.Caption = "Unrecognized Command..."
End If

End Sub

and a module;

Option Explicit

Function LoadVoiceCommands(lstBox As Control) As Boolean

On Local Error GoTo LoadVoiceCommandsError

Dim sNam As String
Dim FileFree As Integer

FileFree = FreeFile

'Check for voice commands text file...
If Dir$(App.Path & "Commands.Txt") = "" Then
Exit Function
End If

'Open the commands.txt file...
Open App.Path & "Commands.Txt" For Input As #FileFree
Line Input #FileFree, sNam
If InStr(LCase$(sNam), "<start>") > 0 And InStr(sNam, "[") = 0 Then
lstBox.AddItem Mid$(sNam, InStr(LCase$(sNam), "=") + 1)
End If
Loop Until EOF(FileFree)
Close #FileFree

LoadVoiceCommands = True
Exit Function

Exit Function

End Function
Function ExecuteVoiceCommand(Who As Form, sPhrase As String) As Boolean

On Local Error GoTo ExecuteVoiceCommandError

Dim X

'Carry out command...
Select Case LCase$(sPhrase)
Case "exit"
SendKeys "%x"
Case "maximize"
Who.WindowState = vbMaximized
Case "minimize"
Who.WindowState = vbMinimized
Case "restore"
Who.WindowState = vbNormal
Case "start notepad"
X = Shell("c:windows
otepad.exe", vbMaximizedFocus)
Case "down"
SendKeys vbKeyDown
Case "up"
SendKeys vbKeyUp
Case "right"
SendKeys vbKeyRight
Case "left"
SendKeys vbKeyLeft
End Select

ExecuteVoiceCommand = True
Exit Function

Exit Function

End Function

Voice Recognition Download?
where do i find that microsoft direct speech component download? i've did searches but am confused as to which is the right thing to download so i could start workin with some examples


Voice Recognition Analysis?
Hey all,

I have a functional program I built in VB6 which uses Directspeech recognition. I have my system configured to utilize audio files in the recognition engine as opposed to using a microphone. The problem is, I need it to analize the voice patterns of the speakers on the wav files (there are always at least 2 speakers) and be able to recognize that a new speaker is talking. Is this possible?? I used the SimpleDict code from the MS Speech SDK 5.1.


Voice Recognition Programming Using VB.
Hi all,
I'm a newbie for VB programming. I'm now doing a Voice recognition program. However, i'm facing some problem rite now. Hope that some kind soul out there can enlighten me.

In my form, i have this following component:
- textfield.

According to some other Vb forum that i have been to, i've managed to get the following code.

To be entered into the button command:

Private Sub btnSpeak_Click()
spkSpeak.Speak txtText.Text
End Sub

My program doesn't work! The program suppose to read out whatever is typed into the textfield. I know there are much more to the coding.

Hope someone can help me out with this. I've installed the speech engine and SAPI 4 runtime program. Is there anything else that need to be done and yet i have not do?

PLS help.... thanks .......

Voice Recognition And Commands
Im trying to get into voice recognition and am looking for a place to start.

I am trying to write an app that will play mp3s on voice command.

Any help would be appreciated

Prince Monkey

Help! MS Agent Voice Recognition
Im using visual basic 6.0 and I can create an agent but I cant make it respond to voice recognition, hers' my code(simple program):

Dim Merlin
Sub form_Load()
Agent1.Characters.Load "Merlin", _
Set Merlin = Agent1.Characters("Merlin")

Merlin.Commands.Add "Goodbye", "Goodbye", _
"...Goodbye...", True, True

End Sub
Sub merlin_Command(ByVal UserInput)
MsgBox "hey!" '(or if statement)
End Sub

I also have all of the voice recognition files, all of the coor files, all of the agent files, all of the text to speach files, and there all the current version

the problem is a message box wont pop up if I select Goodbye or say it, can someone help?

[Edited by Mike202 on 12-17-2000 at 02:44 PM]

German Voice Recognition
I downloaded the MS Speech controls and played around with Sound Recognition. All works fine, but I only found an english voice recognition engine. Is there a german one anywhere? (Doesn't matter if it's not from MS, but should be free)

ActiveX Voice Recognition
Hi all, I would like to know if there is anywhere I can download an active X control dealing with voice recognition within Visual Basic. Also if someone has some code of information on how I might be able to create a voice password?

List Of Dictionary Words
Hey, does anyone know where i can get a full list of dictionary words in a text file?, i need this before i can carry on with my projecty, i googled but i didnt get anything worthwhile

Generating Words...for Dictionary

I am working on a dictionary there are thousand's of words to write ...but instead of that i was thinking that through VB i can generate words from like aaaa to zzzz...

Please help me ...i really want to speed up the process of getting the words...if i get the words file then it will take less time to pick out the proper words...

can anyone help ?


Is There Are A Dictionary For Words Reserved In Vb
Is there are a dictionary for words reserved in vb
like properties TAG ,text,setfocus, path...etc

Using 'microsoft Words' Dictionary
is there a way that i can get all the words from the 'microsoft word' dictionary and list them in a file or a listbox so that i can refer to them in my prgram. I have written a small word game and i would like the program to randomly extract a word from the dictionary to be used in the game.

any help appreciated


Generating Words...for Dictionary

I am working on a dictionary there are thousand's of words to write ...but instead of that i was thinking that through VB i can generate words from like aaaa to zzzz...

Please help me ...i really want to speed up the process of getting the words...if i get the words file then it will take less time to pick out the proper words...

can anyone help ?


Voice Recognition To Trigger Functions
I have a sheet with a bunch of buttons and I want to be able to trigger them using speech commands.

I've installed the Speech SDK and the engine. Once that was sorted out I managed to add a bunch of references; VoiceCommand 1.0 Type Library, Microsoft Voice Commands and a few other text-speech related items.

I have no idea what functions to use to make voice commands work. I've looked extensively on the internet and I've managed to find some examples for VB2008 and VC++ but nothing for VBA. Maybe it can't be done but could anyone point me in the right direction? Maybe I Dragon NaturallySpeaking can get this done?


Using Voice Recognition(ViaVoice) In A VB Application
Hi there,

Im trying to include voice recognition into a VB application I am writing. I have no idea how to use the components. I have Microsoft Voice Dictation, Microsoft Direct Speech Recognition, IBM ViaVoice Word Dictation control componets. I don't know how to use these within my program.

Specifically, how do I write code to activate the speech recognition and collect the text that it has translated.

Thanks in advance for any help.

Voice Commands -- Speech Recognition..
I am using the following code:

Option Explicit

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)
'this event fires when directSR comes up with a result
'the word that has been recognised is stored
'in the Phrase argument
Select Case Phrase
Case Is = "red"
MsgBox "you said red"
Case "green"
MsgBox "you said green"
Case Is = "blue"
MsgBox "you said blue"
Case Else
MsgBox "what the?!"
End Select
End Sub

Private Sub Form_Load()

Dim GrammarStr As String

'this is the list of words that directSR will
GrammarStr = "[Grammer]" + vbNewLine + _
"type=cfg" + vbNewLine + _
"[<start>]" + vbNewLine + _
"<start>=red" + vbNewLine + _
"<start>=green" + vbNewLine + _
"<start>=blue" + vbNewLine

'load the words to recognise
DirectSR1.GrammarFromString GrammarStr

'start listening

End Sub

when I run my app, it doesn't even recognise me saying anything!!
it doens't even bring up the msgbox with WHAT THE?!

what is going wrong??


My Voice Recognition Application Is Not Responding
i am M.Tech Student
working on the voice recognition project in VB-6.0, with SDK5.1 and SDK 4 for speech recognition
i am trying to execute the video clips via my voice command
but still no result, kindly tell me how can i develop this application plz guide me and give me some codes and steps links
i will be very thankfull to u


Edited by - rani_tiwari on 3/31/2004 2:42:27 AM

List Of Words (english Dictionary)
does anyone know if there is a list of all the words in the english dictionary??

if yes, where can i get it from?

Ms Word : List Of All The Words In Dictionary

I was wondering is it possible to list all the words that are within the MS word dictionary. (MSWORD 2000)


Copyright 2005-08, All rights reserved