Results 1 to 13 of 13

Thread: [RESOLVED] speech SDK grammar HOW TO?

Threaded View

  1. #1

    Thread Starter
    Frenzied Member wpearsall's Avatar
    Join Date
    Feb 2002
    Location
    England / UK
    Posts
    1,065

    Resolved [RESOLVED] speech SDK grammar HOW TO?

    hi guys.

    im using a couple of commands
    [search name, volume up / down / mute, mode day / night]

    i cant seem to get the application to listen correctly.

    ive tried adding the
    .addpronunciation "volume"
    etc line, but it still doesnt work

    it runs through, detects speech
    but it is nothing like what is being said. if i say hello, it thinks i said hawaii??? ive run through the training sessions, with no luck.

    how hard is it to get this working, ive seen most ppl use the version four controls, which i cant find anywhere. i have downloaded and installed the sapi sdk5.1 suite from ms rebooted and everything but no ocx controls show

    btw, i am using win xp pro version.

    cheers guys.


    vbcode Code:
    1. Option Explicit
    2.  
    3. Dim WithEvents RecoContext As SpSharedRecoContext
    4. Dim Grammar As ISpeechRecoGrammar
    5.  
    6. Dim m_bRecoRunning As Boolean
    7.  
    8. Public Sub LoadVoice()
    9.  
    10.         ' just a note as we a loading the API
    11.         btnStart.Caption = "Loading sAPI..."
    12.         DoEvents
    13.        
    14.        
    15.         ' load some custom commands
    16.         'Dim addlex As SpUnCompressedLexicon
    17.         Dim addlex As SpLexicon
    18.        
    19.         Set addlex = New SpLexicon
    20.        
    21.         'Set addlex = New SpLexicon
    22.         Set RecoContext = New SpSharedRecoContext
    23.         Set Grammar = RecoContext.CreateGrammar(1)
    24.        
    25.         ' load the dictation application
    26.         Grammar.DictationLoad
    27.        
    28.         addlex.AddPronunciation "Search", 1 ', SPSNoun
    29.         addlex.AddPronunciation "Search Artist", 1 ', SPSNoun
    30.         addlex.AddPronunciation "Search Album", 1 ', SPSNoun
    31.        
    32.         addlex.AddPronunciation "Volume Mute", 1 ', SPSNoun
    33.         addlex.AddPronunciation "Volume On", 1 ', SPSNoun
    34.         '
    35.         addlex.AddPronunciation "Volume Up", 1 ', SPSNoun
    36.         addlex.AddPronunciation "Volume Down", 1 ', SPSNoun
    37.         addlex.AddPronunciation "Volume One Percent", 1 ', SPSNoun
    38.         addlex.AddPronunciation "Volume Twenty Percent", 1 ', SPSNoun
    39.        
    40.         addlex.AddPronunciation "Player Play", 1 ', SPSNoun
    41.         addlex.AddPronunciation "Player Pause", 1 ', SPSNoun
    42.         addlex.AddPronunciation "Player Next", 1 ', SPSNoun
    43.         addlex.AddPronunciation "Player Previous", 1 ', SPSNoun
    44.        
    45.         addlex.AddPronunciation "Mode Day", 1 ', SPSNoun
    46.         addlex.AddPronunciation "Mode Night", 1 ', SPSNoun
    47.         addlex.AddPronunciation "Voice OFF", 1 ', SPSNoun
    48.        
    49.         addlex.AddPronunciation "View rear camera", 1 ', SPSNoun
    50.         addlex.AddPronunciation "View front camera", 1 ', SPSNoun
    51.        
    52.         addlex.AddPronunciation "Help", 1 ', SPSNoun
    53.        
    54.         ' say the voice commands are now listening
    55.         RecoContext.Voice.Speak "Hello.  I am " & App.Title & ". " & _
    56.                                 "If you require help just say help. " & _
    57.                                 "Don't forget to press the command button before speaking."
    58.                                
    59.  
    60. End Sub
    61.  
    62. Private Sub btnExit_Click()
    63.  
    64.    
    65.     If m_bRecoRunning = True Then
    66.    
    67.         Grammar.DictationUnload
    68.         Set Grammar = Nothing
    69.         Set RecoContext = Nothing
    70.  
    71.     End If
    72.    
    73.     Unload Me
    74.  
    75.  
    76. End Sub
    77.  
    78. Private Sub btnListen_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    79.  
    80.     If RecoContext Is Nothing Then LoadVoice
    81.    
    82.     btnListen.BackColor = vbGreen
    83.        
    84.     ' Start the dictation.
    85.     Grammar.DictationSetState SGDSActive
    86.  
    87.     Debug.Print "mouse down event..."
    88.  
    89. End Sub
    90.  
    91. Private Sub btnListen_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    92.    
    93.    
    94.     Debug.Print "mouse up event..."
    95.    
    96.     ' stop it
    97.     Grammar.DictationSetState SGDSInactive
    98.    
    99.     btnListen.BackColor = clBack
    100.  
    101. End Sub
    102.  
    103. ' This function handles Recognition event from the reco context object.
    104. ' Recognition event is fired when the speech recognition engines recognizes
    105. ' a sequences of words.
    106. Private Sub RecoContext_Recognition(ByVal StreamNumber As Long, _
    107.                                     ByVal StreamPosition As Variant, _
    108.                                     ByVal RecognitionType As SpeechRecognitionType, _
    109.                                     ByVal Result As ISpeechRecoResult _
    110.                                     )
    111.                                    
    112.     Dim strText As String
    113.     strText = Result.PhraseInfo.GetText
    114.    
    115.     Debug.Print "Recognition: " & strText & ", " & _
    116.         StreamNumber & ", " & StreamPosition
    117.  
    118. End Sub

    like i said, its working... just not how i want it to... i kinda remember playing with the controls in college, and it worked pretty well, but for some reason i dont have the ocx files like i said.. BUT i do have voice recognition - as i said, it is writing out, no errors, just complete dutch... lol
    Last edited by wpearsall; Aug 26th, 2009 at 07:25 PM. Reason: added vbcode
    Wayne

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width