Shop OBEX P1 Docs P2 Docs Learn Events
SAY IT, I give up — Parallax Forums

SAY IT, I give up

paulvivepaulvive Posts: 35
edited 2012-01-27 16:05 in General Discussion
I followed the SAY IT instructions step by step and I got nowhere so I'm giving up on SAY IT (at least for now, I've spent too much time on it and got nothing in return except aggravation and frustration).

Thanks for all the help. I know I'm missing something but I'm not sure what, Maybe the trigger.

Comments

  • LeonLeon Posts: 7,620
    edited 2012-01-13 11:25
    Your other thread (http://forums.parallax.com/showthread.php?137207-SAY-IT-Help) was only started yesterday. Try something simpler, to start with.
  • paulvivepaulvive Posts: 35
    edited 2012-01-13 13:35
    Thanks for the support. I'm not giving up on the Boe bot And I know even though I said it I probably won't give up on SAY IT. In my younger days the more a project gave me problems the harder I worked at it. But these are not my younger days and I have to give my brain more down time than I used to.
  • skylightskylight Posts: 1,915
    edited 2012-01-14 07:08
    I know exactly how you feel paulvive, the old brain isn't as accomodating to problem solving as it was and what with all the other everyday problems, it gets harder to spare time for hobbies and impatience creeps in but with all the helpful folk on here you will get the support you need so don't give up just take a step back and take your time.
    There is nothing wrong with dropping a project for a while and working on simpler things, getting the entusiasm going again before having another go at the harder bits,
    It's surprising how sometimes with that approach things all of a sudden slot into place and you wonder why it was such a problem before.
    Good luck
  • paulvivepaulvive Posts: 35
    edited 2012-01-14 09:58
    WELL, THANKS FOR THE SUPPORT. i EVEN SENT AN EMAIL TO THE MANUFACTURER OF THE BOARD AND UNTIL i CAN GIVE THEM A DETAILED DESCRIPTION OF WHAT MY PROBLEM IS THEY CAN'T HELP, BUT THEY ARE WILLING TO. aS A LAST RESORT i CONTACTED pARALLAX SUPPORT WITH ALL OF THE DETAILS i HAD AND i WAIT TO SEE THEIR RESPONSE.i RAN ABOUT FOUR OR FIVE OF THE EASIER PROGRAMS WITH NO PROBLEMS SO I DON'T KNOW WHY I'M HUNG UP ON SAY IT. i'LL SIT BACK FOR AWHILE MAYBE RUN SOME OF THE OTHER PROGRAMS OVER AGAIN AND SIT OUT IN THE SUN AND READ MORE DOCUMENTATION.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-01-14 11:34
    I hope you noticed Martin_H's offer to help in your other thread.

    I've used the SayIt a bit with the Prop. I found it useful to monitor the communication between the PC and the SayIt while I used the SayIt GUI.

    The SayIt documentation list the various codes it uses. It's very possible to use the SayIt without the GUI at all.

    When you yell "i RAN ABOUT FOUR OR FIVE OF THE EASIER PROGRAMS WITH NO PROBLEMS", do you mean you ran easier SayIt programs? or BS2 programs or Boe-Bot programs?

    There are lots of people willing to help (some very patient) but it might take more than a day to hear from them.
  • paulvivepaulvive Posts: 35
    edited 2012-01-14 12:13
    The easier Boe Bot programs, Zeroing out the Servos, Getting the led's to blink in different sequences, Roaming with Whiskers
  • xanatosxanatos Posts: 1,120
    edited 2012-01-14 12:19
    Hi Paulvive,

    Do in fact expect that people on these boards who have much to offer are also not sitting on the boards waiting for questions. I often go for months at a time without attending here, as the skills I learn from, and offer to this forum are in use elsewhere frequently. That said, Here's what I can tell you about the SayIt module.

    First, when you post your code, the indentation provided by the code and /code tags on the forum will help members read your code. Do this by first typing the open-square-bracket character, followed by the word "code", then the close-square-bracket. Then paste your code in immediately after that. After the end of teh code you have pasted in, type the exact same character sequence as you did to open the code block, but this time put a / in front of the word "code", so it reads "/code". This will make your code usable to programmers here who may wish to run your code and debug it for you. We are happy to help you - help us to accomplish that goal.

    Next, as mentioned previously, you need to actually program in a command. If you use the SayIt module's programming GUI to program your module, you will soon notice that the code it generates is almost always identical in all parts with the exception of just a few lines which change based on what commands you are wishing to run.

    The first set is under the comment tag "Groups and Commands" as illustrated here:
    'Groups and Commands
    GROUP_0                             CON   0     '(Command count: 1)
    G0_COMPUTER                         CON   0
    GROUP_1                             CON   1     '(Command count: 15)
    G1_OUTSIDE_WATER_ON                 CON   0
    G1_OUTSIDE_WATER_OFF                CON   1
    G1_OUT_PEAK_LIGHT_ON                CON   2
    G1_OUT_PEAK_LIGHT_OFF               CON   3
    G1_SECURITY_LIGHT_ON                CON   4
    G1_SECURITY_LIGHT_OFF               CON   5
    G1_TABLE_LIGHT_ON                   CON   6
    G1_TABLE_LIGHT_OFF                  CON   7
    G1_ENT_CENTER_ON                    CON   8
    G1_ENT_CENTER_OFF                   CON   9
    G1_LANDSCP_LIGHTING_ON              CON   10
    G1_LANDSCP_LIGHTING_OFF             CON   11
    G1_WHAT_TIME_IS_IT                  CON   12
    G1_TEMPERATURE                      CON   13
    G1_WHAT_DAY_IS_TODAY                CON   14
    GROUP_16                            CON   16     '(Command count: 1)
    G16_XANATOS_ALPHA_ONE               CON   0
    

    This is where you will notice what you have trained the unit to recognize. In the above code, I have trained the unit to recognize "Computer" as the wake-up word. You will also notice that that is the only command in the GROUP_0 block. The module can only listen for commands within a single command group at a time, and the GROUP_0 block can only hold two words. The default is Robot, and there is one other you can train, as I did here.

    The system does not know what to do on its own, however, when it hears the GROUP_0 wake-up word, other than to turn on the LED, then time out. So you have to provide code to tell it what to do. You can tell it to either perform a hardware function (turn something on/off) or tell it to switch to a different command group. In my case (a home automation system), when it hears the GROUP_0 wake-up word, I tell the module to switch OUT of GROUP_0 and switch INTO GROUP_1 commands. This code is found a little further down in the listing in two parts, and looks like this:

    First, the main code:
    VR_Loop:
      DEBUG CR, DEC VRGROUP, " cmd: "
      LOW VRLED
      PAUSE 150
      IF VRGROUP > 0 THEN HIGH VRLED
      VRA1 = VRGROUP
      GOSUB VR_RecognizeSD
      '-- handle errors or timeout
      IF VRA1 = RES_ERROR THEN
        DEBUG "Er", CR
        'try again in the same group
        GOTO VR_Loop
      ENDIF
      IF VRA1 = RES_TIMEOUT THEN
        DEBUG "TO", CR
        VRGROUP = 0 ' back to trigger
        GOTO VR_Loop
      ENDIF
      IF VRA1 = RES_COMMFAIL THEN
        DEBUG "CF", CR
        'resync and try again
        GOSUB VR_Wakeup
        GOTO VR_Loop
      ENDIF
      '-- got a command
      VRCOMMAND = VRA1
    
      IF VRCOMMAND <= RES_BUILTIN THEN GOSUB VR_Action
      GOTO VR_Loop
    
    

    Then, a subroutine called VR_Action:
    VR_Action:
      DEBUG DEC VRCOMMAND
      SELECT VRGROUP
        CASE GROUP_0
          SELECT VRCOMMAND
            CASE G0_COMPUTER
             PAUSE 0
             HIGH VRLED
             GOSUB Listen_Tone
             VRGROUP = 1
          ENDSELECT
        CASE GROUP_1
          SELECT VRCOMMAND
            CASE G1_OUTSIDE_WATER_ON
             PAUSE 0
             state = 1
             s1 = state
             cmd = 2
             GOSUB Bank_Build
            CASE G1_OUTSIDE_WATER_OFF
             PAUSE 0
             state = 0
             s1 = state
             cmd = 2
             GOSUB Bank_Build
            CASE G1_OUT_PEAK_LIGHT_ON
             PAUSE 0
             state = 1
             s2 = state
             cmd = 3
             GOSUB Bank_Build
            CASE G1_OUT_PEAK_LIGHT_OFF
             PAUSE 0
             state = 0
             s2 = state
             cmd = 3
             GOSUB Bank_Build
            CASE G1_SECURITY_LIGHT_ON
             PAUSE 0
             state = 1
             s3 = state
             cmd = 4
             GOSUB Bank_Build
            CASE G1_SECURITY_LIGHT_OFF
             PAUSE 0
             state = 0
             s3 = state
             cmd = 4
             GOSUB Bank_Build
            CASE G1_TABLE_LIGHT_ON
             PAUSE 0
             state = 1
             s4 = state
             cmd = 5
             GOSUB Bank_Build
            CASE G1_TABLE_LIGHT_OFF
             PAUSE 0
             state = 0
             s4 = state
             cmd = 6
             GOSUB Bank_Build
            CASE G1_ENT_CENTER_ON
             PAUSE 0
             state = 1
             s5 = state
             cmd = 6
             GOSUB Bank_Build
            CASE G1_ENT_CENTER_OFF
             PAUSE 0
             state = 0
             s5 = state
             cmd = 6
             GOSUB Bank_Build
            CASE G1_LANDSCP_LIGHTING_ON
             PAUSE 0
             state = 1
             s6 = state
             cmd = 7
             GOSUB Bank_Build
            CASE G1_LANDSCP_LIGHTING_OFF
             PAUSE 0
             state = 0
             s6 = state
             cmd = 7
             GOSUB Bank_Build
            CASE G1_WHAT_TIME_IS_IT
             PAUSE 0
             GOSUB Get_Time
             GOSUB Show_Time
             PUT Speak, 102
             RUN SG
            CASE G1_TEMPERATURE
             PAUSE 0
             GOSUB Get_Temp
             GOSUB Show_Temp
             PUT Speak, 103
             RUN SG
            CASE G1_WHAT_DAY_IS_TODAY
             PAUSE 0
             GOSUB Get_Time
             GOSUB Show_Time
             PUT Speak, 101
             RUN SG
          ENDSELECT
        CASE GROUP_16
          SELECT VRCOMMAND
            CASE G16_XANATOS_ALPHA_ONE
             PAUSE 0
             cmd = 40
             RUN SG
          ENDSELECT
      ENDSELECT
      RETURN
    
    

    The main code just loops through listening until it hears something useful. The subroutine is where things really happen. In the very beginning of this, when it hears the GROUP_0 command, it turns on the VRLED, plays a little chirp-tone I write, and most importantly, it changes the command group to 1 with the line VRGROUP = 1.

    Subsequent sections in that subroutine instruct the system what to do when the specific keywords (such as "Outside Water On") are heard by the module. This code in here is entirely needing to be constructed by you. The SayIt GUI just outputs some line that says "put your code here" or something similar. All the code I have in there about state, s1, s2, cmd and Bank_Build are references to variables and subroutines that were built by me specifically for this application.

    My full code listings can be found on this forum by searching for "Speaking Voice Controlled Home Automation System" - but it is a very complex set of slot programs. What is listed above should be the answer to get you going on the module again, when you're ready to jump back in.

    The Say-It modules are fantastic. If you program them well with very auditorially-unique commands, and have them in an environment with a relatively controlled background, they will work very well - especially for the price. People are using these things all over the place - robots, home automation systems, etc. Once you get the hang of it, it'll become second nature to you, just give yourself the space and let it be fun. You can't kill these things with programming or lack of it - only bad wiring! :-) So feel free to experiment and have fun with it. I hope you get to have the same experience I did with these things - the first time in my life that I ever had a "conversation" with one of my electronics projects - asking it questions in plain english (Say-It Module) and hearing it speak the responses in equally plain english (V-Stamp Text-to-Speech module). That hooked me forever on voice recognition and speech generation...

    Good luck, and feel free to ask any question you like, just bear in mind it may take as much as a week sometimes before the person with the answer will actually come around to see your post. And if no one answers in two or three weeks, you can try again - but that kind of wait is rare (happens more during vacation season, oddly enough! :-) )

    Best of luck,

    Dave Xanatos
  • paulvivepaulvive Posts: 35
    edited 2012-01-14 12:24
    Isaid I give up but I haven't. Ive got to make this work I got a link to the Say It code from a place in France. I ran it and I got different information in the DEbug window. Instead of "waiting for command", this time it only asked for a trigger and thats where I'm stumped. I'm trying to use 2 Wordset and I can'i add a trigger to it, I don't know if it needs one. The module accepted the words in the wordset and it's responding back to me through the Debug window so I'm connected OK, I'm screwing up with the software. (Trigger)
  • paulvivepaulvive Posts: 35
    edited 2012-01-14 12:26
    I appreciate that Dave and I appreciate all of the help I've been getting. I've listed the code I'm using below.I tried pasting the code four times. When I edit and include the oode the code comes out right with the indentaions correct, but when I save it it loses all of the indentations as you see it. I tried putting the [Code] as you see it and I tried putting the code immediately after [code] and I ended with [/ code]

    {code]
    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    ' COM Parameters
    COM_RX PIN 0 ' rx pin
    COM_TX PIN 2 ' tx pin
    COM_SPEED CON 84 ' baud 9600
    COM_10MS CON 10 ' 10ms unit
    ' Protocol Command
    CMD_BREAK CON "b" ' abort recog or ping
    CMD_SLEEP CON "s" ' go to power down
    CMD_KNOB CON "k" ' set si knob <1>
    CMD_LEVEL CON "v" ' set sd level <1>
    CMD_LANGUAGE CON "l" ' set si language <1>
    CMD_TIMEOUT CON "o" ' set timeout <1>
    CMD_RECOG_SI CON "i" ' do si recog from ws <1>
    CMD_RECOG_SD CON "d" ' do sd recog at group <1> (0 = trigger mixed si/sd)
    ' Protocol Status
    STS_AWAKEN CON "w" ' back from power down mode
    STS_ERROR CON "e" ' signal error code <1-2>
    STS_INVALID CON "v" ' invalid command or argument
    STS_TIMEOUT CON "t" ' timeout expired
    STS_INTERR CON "i" ' back from aborted recognition (see 'break')
    STS_SUCCESS CON "o" ' no errors status
    STS_RESULT CON "r" ' recognised sd command <1> - training similar to sd <1>
    STS_SIMILAR CON "s" ' recognised si <1> (in mixed si/sd) - training similar to si <1>
    ' Protocol arguments are in the range 0x40 (-1) TO 0x60 (+31) inclusive
    ARG_MIN CON 64 ' 0x40
    ARG_MAX CON 96 ' 0x60
    ARG_ZERO CON 65 ' 0x41
    ARG_ACK CON 32 ' 0x20 'TO READ more status arguments
    'Groups and Commands
    GROUP_1 CON 1 '(Command count: 5)
    G1_AVANCE CON 0
    G1_STOP CON 1
    G1_RECULE CON 2
    G1_DROITE CON 3
    G1_GAUCHE CON 4
    RES_ERROR CON 255
    RES_TIMEOUT CON 254
    RES_COMMFAIL CON 253
    RES_BUILTIN CON 32

    'Robot Constant
    VRLED PIN 4
    'Global Variable
    VRA VAR Byte
    VRA1 VAR Byte
    VRGROUP VAR Byte
    VRCOMMAND VAR Byte
    ' Main Start
    INPUT COM_RX
    HIGH COM_TX
    Restart:
    LOW VRLED
    VRGROUP = 1
    DEBUG CR, "Setting up VRbot... "
    'Wake up or stop recognition
    GOSUB VR_Wakeup
    DEBUG "awake... "
    'Set SI Language
    VRA1 = 0
    GOSUB VR_SetLanguage
    DEBUG "language ", DEC VRA1, "... "
    'Set 5 seconds timeout
    VRA1 = 5
    GOSUB VR_SetTimeout
    DEBUG "timeout ", DEC VRA1, "... "
    DEBUG CR, "VRbot ready!"
    VR_Loop:
    DEBUG CR, "VRbot in group ", DEC VRGROUP, " waiting for command... "
    LOW VRLED
    PAUSE 150
    IF VRGROUP > 0 THEN HIGH VRLED
    VRA1 = VRGROUP
    GOSUB VR_RecognizeSD
    '-- handle errors or timeout
    IF VRA1 = RES_ERROR THEN
    DEBUG "error"
    'try again in the same group
    GOTO VR_Loop
    ENDIF
    IF VRA1 = RES_TIMEOUT THEN
    DEBUG "timed out"
    VRGROUP = 0 ' back to trigger
    GOTO VR_Loop
    ENDIF
    IF VRA1 = RES_COMMFAIL THEN
    DEBUG "comm failed"
    'resync and try again
    GOSUB VR_Wakeup
    GOTO VR_Loop
    ENDIF
    '-- got a command
    VRCOMMAND = VRA1
    IF VRCOMMAND <= RES_BUILTIN THEN GOSUB VR_Action
    GOTO VR_Loop
    VR_Action:
    SELECT VRGROUP
    CASE GROUP_1
    SELECT VRCOMMAND
    CASE G1_AVANCE
    DEBUG "La commande AVANCE a
  • xanatosxanatos Posts: 1,120
    edited 2012-01-14 12:45
    Now take a look at your VR_Action section and the one I posted above. I'm not seeing the section in your code that tells it, once it hears the GROUP_0 word, to change command sets. If that isn't present, the thing will do nothing. In your case, you want it to change to GROUP_1 so that it will recognize whatever words are in that set, assuming you've trained them. Not sure if you're French or not, but the module doesn't care as long as it hears the same sounds that you associated with a command. All of the commands available in your code above are in GROUP_1 - go, stop, right, left, etc. Right now, the only thing that will happen if you say those commands, and the unit it listening for them and recognizes them, is the system will echo the debug text. You can later replace that debug code with functional commands to control external stuff once you have this command-group switching function taken care of.

    Dave

    PS., I'm headed out the door now, so if I do not respond tonight, have patience...
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2012-01-14 13:19
    paulvive,

    You're getting closer, as far as posting code goes, but you used [noparse]{code] instead of
    and [/ code] instead of
    
    [/noparse]. You have to follow the syntax exactly for the tags to work.

    -Phil
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-01-14 13:19
    Paul,

    You're almost there with posting code. You have an s-bracket in "{code]". Both ends need square brackets "[". If you use the "Go Advanced" feature, you can "Preview Post" and see what it will look like. The "Go Advanced" also has a "#" button that will insert the code tags for you.

    Edit: You win this round Phil. But we'll meet again.
  • skylightskylight Posts: 1,915
    edited 2012-01-15 15:29
    Another method is to highlight the code text using your mouse and then click on the # button, this will automatically wrap your code in the tags and produce the correct format when you save such as below:
    this is my code
    this is more code
    and some more code
    and so on
    and so on
    
    
    above is now showing as it should

    I have also cut and pasted your code from above and then highlighted it and again clicked the # button , the result is below:

    [code]' {$STAMP BS2}
    ' {$PBASIC 2.5}
    ' COM Parameters
    COM_RX PIN 0 ' rx pin
    COM_TX PIN 2 ' tx pin
    COM_SPEED CON 84 ' baud 9600
    COM_10MS CON 10 ' 10ms unit
    ' Protocol Command
    CMD_BREAK CON "b" ' abort recog or ping
    CMD_SLEEP CON "s" ' go to power down
    CMD_KNOB CON "k" ' set si knob <1>
    CMD_LEVEL CON "v" ' set sd level <1>
    CMD_LANGUAGE CON "l" ' set si language <1>
    CMD_TIMEOUT CON "o" ' set timeout <1>
    CMD_RECOG_SI CON "i" ' do si recog from ws <1>
    CMD_RECOG_SD CON "d" ' do sd recog at group <1> (0 = trigger mixed si/sd)
    ' Protocol Status
    STS_AWAKEN CON "w" ' back from power down mode
    STS_ERROR CON "e" ' signal error code <1-2>
    STS_INVALID CON "v" ' invalid command or argument
    STS_TIMEOUT CON "t" ' timeout expired
    STS_INTERR CON "i" ' back from aborted recognition (see 'break')
    STS_SUCCESS CON "o" ' no errors status
    STS_RESULT CON "r" ' recognised sd command <1> - training similar to sd <1>
    STS_SIMILAR CON "s" ' recognised si <1> (in mixed si/sd) - training similar to si <1>
    ' Protocol arguments are in the range 0x40 (-1) TO 0x60 (+31) inclusive
    ARG_MIN CON 64 ' 0x40
    ARG_MAX CON 96 ' 0x60
    ARG_ZERO CON 65 ' 0x41
    ARG_ACK CON 32 ' 0x20 'TO READ more status arguments
    'Groups and Commands
    GROUP_1 CON 1 '(Command count: 5)
    G1_AVANCE CON 0
    G1_STOP CON 1
    G1_RECULE CON 2
    G1_DROITE CON 3
    G1_GAUCHE CON 4
    RES_ERROR CON 255
    RES_TIMEOUT CON 254
    RES_COMMFAIL CON 253
    RES_BUILTIN CON 32

    'Robot Constant
    VRLED PIN 4
    'Global Variable
    VRA VAR Byte
    VRA1 VAR Byte
    VRGROUP VAR Byte
    VRCOMMAND VAR Byte
    ' Main Start
    INPUT COM_RX
    HIGH COM_TX
    Restart:
    LOW VRLED
    VRGROUP = 1
    DEBUG CR, "Setting up VRbot... "
    'Wake up or stop recognition
    GOSUB VR_Wakeup
    DEBUG "awake... "
    'Set SI Language
    VRA1 = 0
    GOSUB VR_SetLanguage
    DEBUG "language ", DEC VRA1, "... "
    'Set 5 seconds timeout
    VRA1 = 5
    GOSUB VR_SetTimeout
    DEBUG "timeout ", DEC VRA1, "... "
    DEBUG CR, "VRbot ready!"
    VR_Loop:
    DEBUG CR, "VRbot in group ", DEC VRGROUP, " waiting for command... "
    LOW VRLED
    PAUSE 150
    IF VRGROUP > 0 THEN HIGH VRLED
    VRA1 = VRGROUP
    GOSUB VR_RecognizeSD
    '-- handle errors or timeout
    IF VRA1 = RES_ERROR THEN
    DEBUG "error"
    'try again in the same group
    GOTO VR_Loop
    ENDIF
    IF VRA1 = RES_TIMEOUT THEN
    DEBUG "timed out"
    VRGROUP = 0 ' back to trigger
    GOTO VR_Loop
    ENDIF
    IF VRA1 = RES_COMMFAIL THEN
    DEBUG "comm failed"
    'resync and try again
    GOSUB VR_Wakeup
    GOTO VR_Loop
    ENDIF
    '-- got a command
    VRCOMMAND = VRA1
    IF VRCOMMAND <= RES_BUILTIN THEN GOSUB VR_Action
    GOTO VR_Loop
    VR_Action:
    SELECT VRGROUP
    CASE GROUP_1
    SELECT VRCOMMAND
    CASE G1_AVANCE
    DEBUG "La commande AVANCE a
  • ercoerco Posts: 20,259
    edited 2012-01-15 15:40
    Really? I did not know that highlight # trick.
    
    Trying it now.
    

    Crazy cool stuff!
  • skylightskylight Posts: 1,915
    edited 2012-01-15 15:49
    That method is for the lazy ones amongst us :smile:
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2012-01-15 16:13
    skylight wrote:
    That method is for the lazy ones amongst us
    'Certainly not for us control freaks. I need to type and inspect every dot and tiddle that go into my posts, dagnabbit! :)

    -Phil
  • skylightskylight Posts: 1,915
    edited 2012-01-27 16:05
    lol @Phil
    paulvive, if you are still with us I may be able to help, I've just got myself a boe-bot with a say it module and like yourself I was having trouble getting the module to change groups at first but studying through the generated code and looking at the debug terminal I noticed that it was looking in group 0 (zero) I had trained a second trigger "computer" and noticed in the debug window if i said "Robot" the generated code replied in the debug window "got 32", If i said "Computer" the reply was "got 0" so lifted by this small progress I delved into the code more, found the VRGROUP =0 command and changed it to 1 which is Group 1 where i had my two trained commands of ON and OFF
    and low and behold I found that it was now listening to Group 1 and the command ON turned on the led connected to pin13 and OFF turned it back off!

    So now how do I move the group by voice rather than changing VRGROUP to 1?

    It turned out rather simple in the end, I changed VRGROUP back to 0 so that it would listen for either "Robot" or "Computer" and in the generated code under Case G0 COMPUTER
    I added a command to make VRGROUP now 1 and to GOTO VRLOOP so that it now waits in group 1 for the next voice command.

    It works a treat, once in group 1 if you speak before it has a chance to timeout you can say ON and then OFF as much as you like and the LED turns on and off forever,
    if you dont speak, after the timeout you simply say computer again to make it look at group 1 again.

    Hope I havnt confused you with the above, take a look at the posted code below and I've bolded the bits of interest, good luck.,
    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    ' COM Parameters
    COM_RX              PIN   0   ' rx pin
    COM_TX              PIN   2   ' tx pin
    COM_SPEED           CON   84  ' baud 9600
    COM_10MS            CON   10  ' 10ms unit
    ' Protocol Command
    CMD_BREAK           CON   "b" ' abort recog or ping
    CMD_SLEEP           CON   "s" ' go to power down
    CMD_KNOB            CON   "k" ' set si knob <1>
    CMD_LEVEL           CON   "v" ' set sd level <1>
    CMD_LANGUAGE        CON   "l" ' set si language <1>
    CMD_TIMEOUT         CON   "o" ' set timeout <1>
    CMD_RECOG_SI        CON   "i" ' do si recog from ws <1>
    CMD_RECOG_SD        CON   "d" ' do sd recog at group <1> (0 = trigger mixed si/sd)
    ' Protocol Status
    STS_AWAKEN          CON   "w" ' back from power down mode
    STS_ERROR           CON   "e" ' signal error code <1-2>
    STS_INVALID         CON   "v" ' invalid command or argument
    STS_TIMEOUT         CON   "t" ' timeout expired
    STS_INTERR          CON   "i" ' back from aborted recognition (see 'break')
    STS_SUCCESS         CON   "o" ' no errors status
    STS_RESULT          CON   "r" ' recognised sd command <1> - training similar to sd <1>
    STS_SIMILAR         CON   "s" ' recognised si <1> (in mixed si/sd) - training similar to si <1>
    ' Protocol arguments are in the range 0x40 (-1) TO 0x60 (+31) inclusive
    ARG_MIN             CON   64 ' 0x40
    ARG_MAX             CON   96 ' 0x60
    ARG_ZERO            CON   65 ' 0x41
    ARG_ACK             CON   32 ' 0x20    'TO READ more status arguments
    'Groups and Commands
    GROUP_0             CON   0    '(Command count: 1)
    G0_COMPUTER                         CON   0
    GROUP_1             CON   1    '(Command count: 2)
    G1_ON                               CON   0
    G1_OFF                              CON   1
    RES_ERROR           CON 255
    RES_TIMEOUT         CON 254
    RES_COMMFAIL        CON 253
    RES_BUILTIN         CON 32
    
    'Robot Constant
    VRLED               PIN   4
    'Global Variable
    VRA                 VAR   Byte
    VRA1                VAR   Byte
    VRGROUP             VAR   Byte
    VRCOMMAND           VAR   Byte
    ' Main Start
      INPUT COM_RX
      HIGH COM_TX
    Restart:
      LOW VRLED
     [SIZE=4][B] VRGROUP = 0               [/B]'This is where it initially tells what group to listen to [/SIZE]
      DEBUG CR, "Setting up VRbot... "
      'Wake up or stop recognition
      GOSUB VR_Wakeup
      DEBUG "awake... "
      'Set SI Language
      VRA1 = 0
      GOSUB VR_SetLanguage
      DEBUG "language ", DEC VRA1, "... "
      'Set 5 seconds timeout
      VRA1 = 5
      GOSUB VR_SetTimeout
      DEBUG "timeout ", DEC VRA1, "... "
      DEBUG CR, "VRbot ready!"
    VR_Loop:
      DEBUG CR, "VRbot in group ", DEC VRGROUP, " waiting for command... "
      LOW VRLED
      PAUSE 150
      IF VRGROUP > 0 THEN HIGH VRLED
      VRA1 = VRGROUP
      GOSUB VR_RecognizeSD
      '-- handle errors or timeout
      IF VRA1 = RES_ERROR THEN
        DEBUG "error"
        'try again in the same group
        GOTO VR_Loop
      ENDIF
      IF VRA1 = RES_TIMEOUT THEN
        DEBUG "timed out"
        VRGROUP = 0 ' back to trigger
        GOTO VR_Loop
      ENDIF
      IF VRA1 = RES_COMMFAIL THEN
        DEBUG "comm failed"
        'resync and try again
        GOSUB VR_Wakeup
        GOTO VR_Loop
      ENDIF
      '-- got a command
      VRCOMMAND = VRA1
      IF VRCOMMAND <= RES_BUILTIN THEN GOSUB VR_Action
      GOTO VR_Loop
    VR_Action:
      DEBUG "got ", DEC VRCOMMAND
      SELECT VRGROUP
        CASE GROUP_0
          SELECT VRCOMMAND
           [SIZE=4][B]CASE G0_COMPUTER    [/B]'after recognising "COMPUTER"
    [B]        PAUSE 0 '-- write your code here
             VRGROUP =1   [/B]'Tell it what group to look at next (group 1)
    [B]        GOTO VR_Loop     [/B]'Tell it to go back and listen to the next voice command(from group 1)[B] 
          ENDSELECT
        CASE GROUP_1
          SELECT VRCOMMAND
            CASE G1_ON
             PAUSE 0 '-- write your code here
             HIGH 13
            CASE G1_OFF
             PAUSE 0 '-- write your code here
             LOW 13
    [/B][/SIZE]  ENDSELECT
      ENDSELECT
      RETURN
    '=== VR Routines ===
    ' Wake up:
    VR_Wakeup:
      TOGGLE VRLED
      VRA = CMD_BREAK
      SEROUT COM_TX, COM_SPEED, [VRA]
      SERIN COM_RX, COM_SPEED, 100*COM_10MS, VR_Wakeup, [VRA]
      IF (VRA <> STS_SUCCESS) THEN GOTO VR_Wakeup
      LOW VRLED
      RETURN
    ' Inputs:
    '   VRA1 = language index (0 = english, ...)
    VR_SetLanguage:
      VRA = CMD_LANGUAGE
      SEROUT COM_TX, COM_SPEED, [VRA]
      VRA1 = VRA1 + ARG_ZERO
      SEROUT COM_TX, COM_SPEED, [VRA1]
      SERIN COM_RX, COM_SPEED, 20*COM_10MS, VR_CommFailed, [VRA]
      VRA1 = VRA1 - ARG_ZERO
      'IF (VRA <> STS_SUCCESS) THEN GOTO VR_Wakeup
      RETURN
    ' Inputs:
    '   VRA1 = timeout (in ms, 0=forever, 255=default)
    VR_SetTimeout:
      VRA = CMD_TIMEOUT
      SEROUT COM_TX, COM_SPEED, [VRA]
      VRA1 = VRA1 + ARG_ZERO
      SEROUT COM_TX, COM_SPEED, [VRA1]
      SERIN COM_RX, COM_SPEED, 20*COM_10MS, VR_CommFailed, [VRA]
      VRA1 = VRA1 - ARG_ZERO
      'IF (VRA <> STS_SUCCESS) THEN GOTO VR_Wakeup
      RETURN
    ' Inputs:
    '   VRA1 = SI knob (0=loosest, 2=normal, 4=tightest)
    VR_SetKnob:
      VRA = CMD_KNOB
      SEROUT COM_TX, COM_SPEED, [VRA]
      VRA1 = VRA1 + ARG_ZERO
      SEROUT COM_TX, COM_SPEED, [VRA1]
      SERIN COM_RX, COM_SPEED, 20*COM_10MS, VR_CommFailed, [VRA]
      VRA1 = VRA1 - ARG_ZERO
      'IF (VRA <> STS_SUCCESS) THEN GOTO VR_Wakeup
      RETURN
    ' Inputs:
    '   VRA1 = SD level (1=easy, 2=default, 5=hard)
    VR_SetLevel:
      VRA = CMD_LEVEL
      SEROUT COM_TX, COM_SPEED, [VRA]
      VRA1 = VRA1 + ARG_ZERO
      SEROUT COM_TX, COM_SPEED, [VRA1]
      SERIN COM_RX, COM_SPEED, 20*COM_10MS, VR_CommFailed, [VRA]
      VRA1 = VRA1 - ARG_ZERO
      'IF (VRA <> STS_SUCCESS) THEN GOTO VR_Wakeup
      RETURN
    ' Inputs:
    '   VRA1 = wordset (0=trigger)
    ' Ouputs:
    '   VRA1 = result (0-31=word, 32..=builtin, 253=comm err, 254=timeout, 255=error)
    VR_RecognizeSI:
      VRA = CMD_RECOG_SI
      GOTO VR_Recognize0
    VR_RecognizeSD:
      VRA = CMD_RECOG_SD
    VR_Recognize0:
      SEROUT COM_TX, COM_SPEED, [VRA]
      ' send Group/WS
      VRA1 = VRA1 + ARG_ZERO
      SEROUT COM_TX, COM_SPEED, [VRA1]
      ' wait for answer
      SERIN COM_RX, COM_SPEED, 600*COM_10MS, VR_CommFailed, [VRA]
      IF VRA = STS_RESULT THEN
        ' send ack
        VRA = ARG_ACK
        SEROUT COM_TX, COM_SPEED, [VRA]
        ' wait for recognised command code
        SERIN COM_RX, COM_SPEED, 20*COM_10MS, VR_CommFailed, [VRA1]
        VRA1 = VRA1 - ARG_ZERO
      ELSEIF VRA = STS_SIMILAR THEN
        ' send ack
        VRA = ARG_ACK
        SEROUT COM_TX, COM_SPEED, [VRA]
        ' wait for recognised command code
        SERIN COM_RX, COM_SPEED, 20*COM_10MS, VR_CommFailed, [VRA1]
        VRA1 = VRA1 - ARG_ZERO + RES_BUILTIN
      ELSEIF VRA = STS_TIMEOUT THEN
        VRA1 = RES_TIMEOUT
      ELSE
        VRA1 = RES_ERROR
      ENDIF
      RETURN
    VR_CommFailed:
      VRA1 = RES_COMMFAIL
      RETURN
    
Sign In or Register to comment.