Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

[Vb script] Speech to text or speech recognition, help

this is Text to speech script, its very easy, just put this in notepad and save as anyname.vbs

CreateObject("SAPI.SpVoice").Speak"Hello"


open the file, the computer will say Hello






but how to do the opposite (Speech to text script or speech recognition), please help how is the script?


Comments

  • jojoalijojoali manaoagPosts: 1Member
    edited October 6

    you may try this code. . .

    Private Sub Form_Load()
    
        If App.PrevInstance Then
    
        MsgBox 'Sorry, but you have Voice Commander already started.', _ 
        bMsgBoxSetForeground + vbInformation, 'PC Alarm'
    
        End
    
    End If
    
    'populate form fields
    
        comboAction.AddItem 'KEYS'
        comboAction.AddItem 'EXECUTE'
        comboAction.AddItem 'HTML'
    
    
    'load voice commands
    
    ReDim gVoiceCmd(1)
    Dim tvc As VC
    tvc.cmd = 'close'
    tvc.action = KEYS
    ReDim tvc.data(0)
    tvc.data(0) = 18 & ' ' & vbKeyF4
    gVoiceCmd(0) = tvc
    tvc.cmd = 'IE Amazon'
    tvc.action = EXECUTE
    ReDim tvc.data(1)
    tvc.data(0) = 'C:\Program Files\Internet Explorer\iexplore.exe'
    tvc.data(1) = 'amazon.com'
    gVoiceCmd(1) = tvc
    gGrammarFile = '\g.xml'
    loadVC
    
    MsgBox 'g: ' & UBound(gVoiceCmd)
    
    'list voice commands
    
    g.Rows = UBound(gVoiceCmd) + 2
    
    g.Cols = 4
    g.TextMatrix(g.Row - 1, g.Col) = 'Command'
    g.TextMatrix(g.Row - 1, g.Col + 1) = 'Action'
    g.TextMatrix(g.Row - 1, g.Col + 2) = 'Data'
    
    gMaxWidth = 0
    Dim i, j, ts As String
    For i = 0 To UBound(gVoiceCmd)
        ts = gVoiceCmd(i).cmd & vbTab & gVoiceCmd(i).action & vbTab
        g.TextMatrix(g.Row + i, g.Col - 1) = i + 1
        listVC(0).AddItem gVoiceCmd(i).cmd
        g.TextMatrix(g.Row + i, g.Col) = gVoiceCmd(i).cmd
        listVC(1).AddItem getActionStr(gVoiceCmd(i).action)
        g.TextMatrix(g.Row + i, g.Col + 1) = getActionStr(gVoiceCmd(i).action)
    
        If UBound(gVoiceCmd(i).data) = 0 Then
            ts = gVoiceCmd(i).data(0)
        Else
            ts = ''
            For j = 0 To UBound(gVoiceCmd(i).data)
                    ts = ts & gVoiceCmd(i).data(j) & ' '
            Next j
    
        'get rid of trailing space
    
            ts = Left(ts, Len(ts) - 1)
        End If
    If gMaxWidth < p.TextWidth(ts) Then
        gMaxWidth = p.TextWidth(ts)
    End If
    
    listVC(2).AddItem ts
    
    g.AddItem (i + 1) & vbTab & gVoiceCmd(i).cmd & vbTab & _
        getActionStr(gVoiceCmd(i).action) & ts
    g.TextMatrix(g.Row + i, g.Col + 2) = ts
    
    Next i
    
    load skin
    
    gKeyMode = False
    
    comboAction.Text = 'EXECUTE'
    comboAction_Click
    gCounter = UBound(gVoiceCmd) + 2
    
    gFocusing = False
    
    writeGrammar
    
    
    
    round window
    
    Dim hrgn As Long
    
    hrgn = CreateRoundRectRgn(0, 0, ScaleX(Me.Width, vbTwips, vbPixels), _
    ScaleY(Me.Height, vbTwips, vbPixels), 30, 30)
    
    SetWindowRgn Me.hWnd, hrgn, True
    
    DeleteObject hrgn
    
    
    hrgn = CreateRoundRectRgn(0, 0, ScaleX(g.Width, vbTwips, vbPixels), _
    ScaleY(g.Height, vbTwips, vbPixels), 15, 15)
    SetWindowRgn g.hWnd, hrgn, True
    DeleteObject hrgn
    
    'make sure fields inside g are of good size
    Dim row_height, col_width
    
    col_width = g.Width / (g.Cols - 1)
    For i = 1 To g.Cols - 1
            g.ColWidth(i) = col_width
    Next
    
    '1st col is number column, so need only small width
    
    g.ColWidth(0) = 360
    g.ColWidth(2) = 900
    g.ColWidth(g.Cols - 1) = g.Width - g.ColWidth(0) - g.ColWidth(1) - _
    g.ColWidth(2) - 100
    g.ColWidth(g.Cols - 1) = gMaxWidth + 100
    
    load skin
    
    grad.MetalCylander RGB(25, 25, 25), RGB(215, 215, 215), RGB(50, 50, 50), _
    RGB(230, 230, 230), Width \ 2, (Width \ 2) + (Width \ 3), Width, Me
    
    grad.MetalCylander RGB(7, 145, 25), RGB(35, 53, 22), RGB(50, 177, 50), _
    RGB(18, 31, 23), Width \ 2, (Width \ 2) + (Width \ 3), Width, Me
    
    
    
    'create icon in the lower right corner =)
    
    gHW = Me.hWnd
    myNID.cbSize = Len(myNID)
    
    myNID.hWnd = gHW
    myNID.uID = uID
    myNID.uFlags = NIF_MESSAGE Or NIF_TIP Or NIF_ICON
    myNID.uCallbackMessage = cbNotify
    myNID.hIcon = vcImg
    myNID.szTip = 'Voice Commander' & Chr(0)
    
    ShellNotifyIcon NIM_ADD, myNID
    
    Hook
    
    'load grammar and start engine
    
    On Error GoTo Err_SAPILoad
    
         Set RC = New SpSharedRecoContext
            Set Grammar = RC.CreateGrammar(1)
            Grammar.CmdLoadFromFile App.Path & '\g.xml', SLODynamic
    
        loadGrammar
        activateVC
        gComputerOn = False
        Grammar.CmdSetRuleIdState 0, SGDSActive
    
        Exit Sub
    
    
    Err_SAPILoad:
        MsgBox 'Error loading SAPI objects! Please make sure SAPI5.1 _
        is correctly installed: ' & Error(Err), vbCritical
        'exit application
        End
    End Sub
    
  • 7amzawy7amzawy EgyptPosts: 1Member
Sign In or Register to comment.