 |

06-19-2008, 07:22 AM
|
|
Newcomer
|
|
Join Date: Jun 2008
Posts: 6
|
|
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?
Thanks.
|
|

06-19-2008, 09:12 AM
|
 |
Senior Contributor
* Expert *
|
|
Join Date: May 2008
Posts: 1,012
|
|
Hi y4m4, welcome to the forum!
Other than the documentation included with the SDK, MSDN should be your primary source of information. I had a quick look at the SAPI section and it looks like it's meant more for professional app development than home use. Still, it seems there are also some basic examples included, specifically VB5/6 examples. I'd get started with those, that's what an SDK is there for, after all.
If you find the examples to be way over your head, you might want to switch to a different product, as you already mentioned.
|
__________________
"Lying in bed would be an altogether perfect and supreme experience if only one had a colored pencil long enough to draw on the ceiling."
Chesterton, "Tremendous Trifles"
|

06-19-2008, 01:29 PM
|
|
Newcomer
|
|
Join Date: Jun 2008
Posts: 6
|
|
I was looking at the SDK examples again, nothing that is particularly helpful to me; probably because I don't have VB6 installed. I found some code but it is mostly about adding items to a list and whatnot. And the help file isn't very useful either. Maybe I'm just lousy with help files? The MSDN is usually helpful for my general VBA questions but this one has me and the MSDN stumped.
So... I've been digging even more and I found this: http://www.codeguru.com/vb/gen/vb_mi...le.php/c11019/
It looks kinda like what I want to do is possible even though this is a VB6 example. I've been trying my hardest to get this to work.
What I've been trying to do is make this work when I click a button since I don't have a form load event(I'm trying to keep everything on a sheet. I wouldn't object to making a hidden form or something like that).
I've added a Vcommand class to my spreadsheet. I'm having all sorts of problems.
Code:
Private My_Menu As Long
Private Sub CommandButton1_Click()
VoiceCmd.Initialized = 1
' MenuCreate adds a command list to the collection and returns
' the menu list's ID
My_Menu = VoiceCmd.MenuCreate(App.EXEName, "Commands", 4)
VoiceCmd.Enabled = 1
' Addcommand (Menu list to use , Command ID , Command ,
' Description , Category , Action)
VoiceCmd.AddCommand My_Menu, 1, "Open", "Open", 0, ""
VoiceCmd.Activate My_Menu
End Sub
I get a "wrong number of arguments" error for
Code:
VoiceCmd.Activate My_Menu
I then remove the "My_menu" part from that last line and try to click the button again and get a "runtime 424" at the
Code:
My_Menu = VoiceCmd.MenuCreate(App.EXEName, "Commands", 4)
line. I think its because of the part but I don't know what to replace it with.
I also get an "Argument not optional" error at the
Code:
VoiceCmd.AddCommand My_Menu, 1, "Open", "Open", 0, ""
line.
Then I have this to hopefully trigger and event...
Code:
Private Sub Voicecmd_CommandRecognize(ByVal ID As Long, _
ByVal CmdName As String, _
ByVal flags As Long, _
ByVal action As String, _
ByVal NumLists As Long, _
ByVal ListValues As String, _
ByVal command As String)
Select Case command
Case "open"
Call CommandButton2_Click
End Select
End Sub
Any ideas?
|
|

06-19-2008, 02:17 PM
|
 |
Senior Contributor
* Expert *
|
|
Join Date: May 2008
Posts: 1,012
|
|
Don't you get intellisense to help you with the arguments? Do you have to use generic object types for some reason? Doesn't the object browser list the class and function definitions for the library? 
|
__________________
"Lying in bed would be an altogether perfect and supreme experience if only one had a colored pencil long enough to draw on the ceiling."
Chesterton, "Tremendous Trifles"
|

06-20-2008, 07:41 AM
|
|
Newcomer
|
|
Join Date: Jun 2008
Posts: 6
|
|
Intellisense isn't that helpful, it will give me a list of properties and methods. I also get a very basic description of the command when I start typing it in. I never get any flag options or autocomplete suggestions.
I've been using an old documentation to figure some stuff out but its tough. http://www.text-reader.com/ttshelp/
I feel like I'm getting closer, here is what I have now
Code:
Private Sub CommandButton1_Click()
Dim My_Menu2 As Long
VoiceCmd.Initialized = 1
' MenuCreate adds a command list to the collection and returns
' the menu list's ID
My_Menu2 = VoiceCmd.MenuCreate("Excel", "Main Menu", 4)
VoiceCmd.Enabled = 1
' Addcommand (Menu list to use , Command ID , Command ,
' Description , Category , Action)
VoiceCmd.AddCommand My_Menu2, 1, "Open", "Open", "Commands", 0, ""
VoiceCmd.Activate
MsgBox VoiceCmd.CountCommands(My_Menu2)
End Sub
I have that VoiceCmd.CountCommands(My_Menu2) line there to check and see if I'm actually creating the menu. It appears to be successful but I just can't make it respond.
Maybe it is because I can't tell VoiceCmd what menu to use since it won't allow VoiceCmd.Activate My_Menu2
I was hoping that I could get VoiceCmd.MimicCmd to work so I could test it further but the method fails.
Maybe I should jsut give up but if I figured it out I'd be a hero.
|
|

06-20-2008, 08:32 AM
|
 |
Senior Contributor
* Expert *
|
|
Join Date: May 2008
Posts: 1,012
|
|
|
I think the person to help you at this stage would have to be someone who's actually used the library themselves before, which unfortunately isn't me. I'll ask to have this thread moved to the General forum, where people who have used it in VB proper are more likely to notice it. I'm sure the differences to using it in VBA aren't that significant.
|
__________________
"Lying in bed would be an altogether perfect and supreme experience if only one had a colored pencil long enough to draw on the ceiling."
Chesterton, "Tremendous Trifles"
|

06-20-2008, 09:27 AM
|
|
Newcomer
|
|
Join Date: Jun 2008
Posts: 6
|
|
|
I appreciate your help, if nothing else it has stimulated my mind. I'm closer to my goal that I was yesterday.
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|