MsAgents
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Thread: MsAgents

  1. #1
    Join Date
    Aug 2002
    Location
    Lucknow
    Posts
    129

    MsAgents

    hi gurus
    I am using msagent for text to speach and for speach commands.
    text to speach is working fine but it's not reacting for speach commands.
    when iam opening voice command window by right click on character say genie, awindow appears with text "Speach Input is Not Available in English"


    i am using following code taken from msdn.




    Private Sub Agent1_ActivateInput(ByVal CharacterID As String)
    Agent1.Characters.Character("genie").Play "Congratulate"
    Agent1.Characters.Character("genie").Play "Explain"
    Agent1.Characters.Character("genie").Speak "Hi I am Gin How R U"

    End Sub

    Private Sub Agent1_Click(ByVal CharacterID As String, ByVal Button As Integer, ByVal Shift As Integer, ByVal x As Integer, ByVal y As Integer)
    'Agent1.Characters.Character("genie").Activate

    End Sub

    Private Sub Agent1_Command(ByVal UserInput As Object)

    Select Case LCase(UserInput.Name)

    Case "bye bye"
    Agent1.Characters.Character("genie").Speak "Bye bye"""
    Agent1.Characters.Character("genie").Play "Wave"
    Set MyRequest = Agent1.Characters.Character("genie").Hide

    Case "down"
    Agent1.Characters.Character("genie").GestureAt Agent1.Characters.Character("genie").Left, Screen.Height / Screen.TwipsPerPixelY
    Agent1.Characters.Character("genie").Speak "All fall down."

    Case "happy"
    Agent1.Characters.Character("genie").Play "Pleased"
    Agent1.Characters.Character("genie").Speak "Iím happy."
    Case "Hello"
    Agent1.Characters.Character("genie").Speak "Hello Merlin."
    Agent1.Characters.Character("genie").Play "DoMagic1"
    Agent1.Characters.Character("genie").Speak "Abracadabra, hocus pocus."
    Agent1.Characters.Character("genie").Play "DoMagic2"
    Agent1.Characters.Character("genie").Speak "Visual Basic now can" & "\Map=""spoke ith""=""spoketh""\."""

    Case "left"
    Agent1.Characters.Character("genie").GestureAt 0, Agent1.Characters.Character("genie").Height
    Agent1.Characters.Character("genie").Speak "Left is that away."

    Case "move"
    Agent1.Characters.Character("genie").MoveTo Screen.Width / Screen.TwipsPerPixelX * Rnd, _
    Screen.Height / Screen.TwipsPerPixelY * Rnd
    Agent1.Characters.Character("genie").Speak "I Like flying."

    Case "Right"
    Agent1.Characters.Character("genie").GestureAt Screen.Width / Screen.TwipsPerPixelX, Agent1.Characters.Character("genie").Height
    Agent1.Characters.Character("genie").Speak "Keep to the right."
    Case "Sad"
    MsgBox "This is UP"
    Agent1.Characters.Character("genie").Play "Sad"
    Agent1.Characters.Character("genie").Speak "Iím sad."
    Case "Up"
    MsgBox "This is UP"
    Agent1.Characters.Character("genie").GestureAt Agent1.Characters.Character("genie").Left, 0
    Agent1.Characters.Character("genie").Speak "The sky is falling."
    Case Else
    Agent1.Characters.Character("genie").Speak "I didnít understand you."
    Agent1.Characters.Character("genie").Play "Confused"
    End Select


    End Sub

    Private Sub Agent1_DblClick(ByVal CharacterID As String, ByVal Button As Integer, ByVal Shift As Integer, ByVal x As Integer, ByVal y As Integer)
    Agent1.Characters.Character("genie").Play "Congratulate"
    Agent1.Characters.Character("genie").Play "Explain"
    Agent1.Characters.Character("genie").Speak "Hi I am Gin How R U"

    End Sub

    Private Sub Form_Load()
    Dim g_ctlAgent As Agent
    'Set the object variable for the Microsoft Agent ActiveX control.

    'set g_ctlAgent= new

    'Establish a connection to Microsoft Agent.
    Agent1.Connected = True

    'Load the character animation data file from the default folder.
    Agent1.Characters.Load "genie", _
    "D:\Users\Yv\SoundDump\Agents\genie.acs"

    'Set the object variable for the character.
    'Set genie = Agent1.Characters(CharacterID:="genie")
    Agent1.Characters.Character("genie").Show
    Agent1.Characters.Character("genie").LanguageID = &H409
    'Agent1.Characters.Character("genie"). = "MyAgent Commands"
    Agent1.Characters.Character("genie").Commands.Caption = "MyAgent Commands"
    Agent1.Characters.Character("genie").Commands.Visible = True
    Agent1.Characters.Character("genie").Commands.Voice = "MyAgent Commands"

    Agent1.Characters.Character("genie").Commands.Visible = True
    Agent1.Characters.Character("genie").Commands.Voice = "MyAgent Commands"
    Agent1.Characters.Character("genie").Commands.Add "Bye bye", "Bye bye", "... bye bye ...", True, True
    Agent1.Characters.Character("genie").Commands.Add "Down", "Down", "... down ...", True, True
    Agent1.Characters.Character("genie").Commands.Add "Happy", "Happy", "... happy ...", True, True
    Agent1.Characters.Character("genie").Commands.Add "Hello", "Hello", "Hello Merlin", True, True
    Agent1.Characters.Character("genie").Commands.Add "Left", "Left", "... left ...", True, True
    Agent1.Characters.Character("genie").Commands.Add "Move", "Move", "... move ...", True, True
    Agent1.Characters.Character("genie").Commands.Add "Right", "Right", "... right ...", True, True
    Agent1.Characters.Character("genie").Commands.Add "Sad", "Sad", "... sad ...", True, True
    Agent1.Characters.Character("genie").Commands.Add "Up", "Up", "... up ...", True, True


    End Sub




    thanx

  2. #2
    Join Date
    Nov 2003
    Location
    Seattle, WA
    Posts
    265
    There is a simpler way for speech commands.. If you want I can get you an example real fast..

  3. #3
    Join Date
    Nov 2003
    Location
    Seattle, WA
    Posts
    265
    Here..
    Code:
    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)
        Select Case LCase(Phrase)
            Case "up"
                MsgBox "You Said: Up"
            Case "down"
                MsgBox "You Said: Down"
            Case "hide"
                MsgBox "You Said: Hide"
        End Select
    End Sub
    
    Private Sub Form_Load()
         Dim Grammar As String
         
         'This is the grammar DirectSR will use it contains all the words it will recognize
         Grammar = "[Grammar]" & vbCrLf & _
                                             "langid = 1033" & vbCrLf & _
                                             "type=cfg" & vbCrLf & _
                                             "[<Start>]" & vbCrLf & _
                                             "<start>=Up" & vbCrLf & _
                                             "<start>=Down" & vbCrLf & _
                                             "<start>=Hide"
                                             
         DirectSR1.GrammarFromString Grammar    'Load up our grammar we created above
    End Sub
    Make sure you include the Microsoft Direct Speech Recognition Control

  4. #4
    Join Date
    Aug 2002
    Location
    Lucknow
    Posts
    129
    Thanx buddy for reply.
    direct speech recognition control is not working my side.I copied the code which u given.
    Is any addtional seeting required.I have tested my mike it's working.

  5. #5
    Join Date
    Nov 2003
    Location
    Seattle, WA
    Posts
    265
    Oops, sorry about that I forgot a line.
    This is how it should be.
    Code:
    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)
        Select Case LCase(Phrase)
            Case "up"
                MsgBox "You Said: Up"
            Case "down"
                MsgBox "You Said: Down"
            Case "hide"
                MsgBox "You Said: Hide"
        End Select
    End Sub
    
    Private Sub Form_Load()
         Dim Grammar As String
         
         'This is the grammar DirectSR will use it contains all the words it will recognize
         Grammar = "[Grammar]" & vbCrLf & _
                                             "langid = 1033" & vbCrLf & _
                                             "type=cfg" & vbCrLf & _
                                             "[<Start>]" & vbCrLf & _
                                             "<start>=Up" & vbCrLf & _
                                             "<start>=Down" & vbCrLf & _
                                             "<start>=Hide"
                                             
         DirectSR1.GrammarFromString Grammar    'Load up our grammar we created above
         DirectSR1.Activate   'Forgot this line.. Sorry about that
    End Sub
    Last edited by Jinto; January 6th, 2004 at 07:07 PM.

  6. #6
    Join Date
    Feb 2010
    Posts
    1

    Re: MsAgents

    I have been trying this code in a VBA environment, I loaded the speech recognition controls and it should work, but it's not responding to any input from the mic.

    I would appreciate any help

    Thanks

    Basem

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center