Welcome to Dream.In.Code
Become a VB Expert!

Join 149,979 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 1,374 people online right now. Registration is fast and FREE... Join Now!




voice command control

 
Reply to this topicStart new topic

voice command control, how can i use voice command control and speech recognition? please say

fahime
18 Jan, 2008 - 11:11 PM
Post #1

New D.I.C Head
*

Joined: 18 Jan, 2008
Posts: 2

CODE
Option Explicit

Dim objVCmd As Object
Dim objVMenu As Object



Private Sub cmdadd_Click()
    '
    ' add a new item to the menu
    '
    Dim x As Integer
    Dim lMenuIndex As Integer
        For x = 1 To 4
        lMenuIndex = x
        objVMenu.Add lMenuIndex, "open" & CStr(x), "Item List", "Make an Item List "
                  
        '
        objVMenu.hWndMenu = Me.hWnd ' for this window
        objVMenu.Active = True ' turn it on
        '
    Next x
    '
    MsgBox "Menu Complete"
    '

End Sub

Private Sub cmdawake_Click()
    '
    ' wake up the SR engine
    '
    objVCmd.Awake = True
    lblawake.Caption = "SR Engine is Awake"
    '
End Sub

Private Sub cmdCallBack_Click()
'
    ' register callback
    '
    objVCmd.Callback = "frmvcmd.clsCallBack"
    '
End Sub

Private Sub cmdcreate_Click()
    '
    ' create a new menu
    '
    Dim iType As Integer
    Dim cMenuCmd As String
    Dim cMenuState As String
    Dim lMenuLangID As Long
    Dim cDialect As String
    Dim cAppName As String
    '
    ' set default stuff
    cAppName = App.EXEName ' this app
    cMenuState = frmVCmd.Caption ' this window
    cDialect = "" ' use default
    lMenuLangID = 1033 ' US lang nbr
    '
    ' get menu creation type
    'iType = IIf(optMenuCmd(0), vcmdmc_CREATE_NEW, iType)
    'iType = IIf(optMenuCmd(1), vcmdmc_CREATE_ALWAYS, iType)
    'iType = IIf(optMenuCmd(2), vcmdmc_CREATE_TEMP, iType)
    'iType = IIf(optMenuCmd(3), vcmdmc_OPEN_ALWAYS, iType)
    'iType = IIf(optMenuCmd(4), vcmdmc_OPEN_EXISTING, iType)
    iType = 4
    ' now create an empty menu
       Set objVMenu = objVCmd.MenuCreate(cAppName, cMenuState, lMenuLangID, cDialect, iType)
    '
End Sub

Private Sub cmdList_Click()
    '
    ' add a list command
    ' build a list
    ' activate the menu
    '
    Dim lMenuIndex As Integer
        lMenuIndex = lMenuIndex + 1
    objVMenu.Active = False
    objVMenu.Add lMenuIndex, "Show <CustomerName>", "Name List", "Display Names"
    objVMenu.ListSet "CustomerName", 3, "Smith" & Chr(0) & "Lee" & Chr(0) & "Shannon" & Chr(0)
    objVMenu.Active = True
    '

End Sub

Private Sub cmdreg_Click()
'
    ' register w/ SR engine
    '
    objVCmd.Register "" ' use default location
    '
End Sub

Private Sub cmdRemove_Click()
'
    ' remove menus from the list
    '
    Dim lLoop As Long
    '
    For lLoop = lMenuIndex To 1 Step -1
        objVMenu.Remove (lLoop)
    Next lLoop
    '
    lMenuIndex = 0
    '
    MsgBox "Menus Removed"
    '
End Sub

Private Sub cmdsleep_Click()
    '
    ' tell SR engine to stop listening
    '
    objVCmd.Awake = False
    lblawake.Caption = "SR Engine is Sleeping"
    '
End Sub

Private Sub Form_Load()
    '
    ' create new voice command object
    '
    Set objVCmd = CreateObject("Speech.VoiceCommand")
    '
    Timer1.Interval = 5000
    Timer1.Enabled = True
    '
End Sub

Private Sub Form_Unload(Cancel As Integer)
'
    ' destroy the voice command objects
    '
    Set objVCmd = Nothing
    Set objVMenu = Nothing
    '

End Sub

Private Sub Timer1_Timer()
   '
    ' look for menu hit
    '
    Dim lHeard As Long
    '
    lHeard = objVCmd.CommandSpoken
    lblStatus = "Menu ID: [" & CStr(lHeard) & "]"
    '
    Select Case lHeard
        Case 0 ' no command
            ' na
        Case 1 ' beep command
            lblResults = "open 1"
        Case 2
            lblResults = "open 2"
        Case 3
            lblResults = "open 3"
        Case 4
            lblResults = "open 4"
      
    End Select
    '
    lHeard = 0
    objVCmd.CommandSpoken = 0
    '

End Sub

User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/8/09 07:02PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live VB Help!

VB Tutorials

Reference Sheets

VB Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month