Announcement

Collapse
No announcement yet.

Recording System Script - Need some help

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Recording System Script - Need some help

    Hope it is OK to post this here. The HSPhone script forum hardly gets used and this script will need to use some Vbscript in homeseer.

    This is what I am trying to do.
    I have set up a cookie cutter type web site for several users. Everything is the same besides their basic info. Name, e-mail, etc.

    What I am working on now is where these users can call up a phone number, enter in their ID number and record their own personal message that will appear on the front of their website in real time. I am using flash that plays back the mp3 file and allows the end user to control it, (Pause, Play, etc.).

    I have it working but need to add some other features. I don't totally understand how you can use VBscripts in the IVR scripts to return values. After reading the Help file it is my understanding that I can only tell HomeSeer to run a script in homeseer or return only a TRUE or False statement. Is it possible to run some VBscript and actually get a value back? This is what I want and that would be great if anybody could help me.

    1. Right now when they enter in their ID number it will read it back as "One Thousand Five Hundred and Eighty Six" instead of "One Five Eight Six"
    How can I use a VBscript in IVR to do this?

    2. Simple password based on ID number.
    Right now the system allows you to punch in any ID number and put that recording on that persons website. After they enter in their ID number I want it so they have to put in a password for the ID number. I need some kind of algorithm where the password would be generated from the ID number. Something as simple as 9=0 8=1 7=2 6=3 5=4 would work. I do not need major security. I am not sure if I can do this in IVR with VBscript

    3. MP3 conversion
    Even though HomeseerPhone can save in MP3 format, you can not change the bitrate. it saves in 8khz but the file must be 11,22,44 for flash to stream it correctly (otherwise it plays back 6X as fast) - I was hoping that I could pass the path and filename onto a script in homeseer and have it run lame.exe (which homeseers uses, command line based) manually to set the correct bitrate.

    If you could help me out, that would be great.

    Below is the code that is currently working right now minus the speaking each digit back, password protection, and correct bitrate mp3 playback.

    Also note that you MUST have the latest version of hsphone installed or playback of wav files outside of the homeseer dir will not work.
    ftp://ftp.homeseer.com/updates/hsp176.zip

    <pre class="ip-ubbcode-code-pre">
    ###########################################################
    # ID number recorder #
    # Version 1.0 #
    ###########################################################

    LABEL:START

    CLEAR_KEY:
    SPEAK:Hello, Enter your ID Number. When you are finished, press the pound key.
    WAIT_KEY:#
    SPEAK:The Number you entered is
    SPEAK:$DTMF
    SET:$VAR1=$DTMF

    LABEL:RECORDING
    SPEAK:Start Recording.
    CLEAR_KEY:
    PLAY:beep.wav
    RECORD:c:\temp\phone\$VAR1.wav
    WAIT_KEY:#
    END_RECORD:
    CLEAR_KEY:

    LABEL:MENU1
    SPEAK:To hear your recording, press 1. To Try again Press 2. To save your recording, press 3 or hang up.
    WAIT_KEY:123456789#*
    IF:$DTMF_KEY=1;GOTO:HEAR_RECORDING;NEXT:
    IF:$DTMF_KEY=2;GOTO:RECORDING;NEXT:
    IF:$DTMF_KEY=3;GOTO:HANGUP;NEXT:
    SPEAK:Sorry, that key is not an option. Please try again.
    GOTO:MENU1

    LABEL:HANGUP
    SPEAK:Your Recording has been saved. Good Bye
    HANGUP:

    LABEL:HEAR_RECORDING
    CLEAR_KEY:
    PLAY:c:\temp\phone\$VAR1.wav
    GOTO:MENU1

    HANGUP:
    </pre>

    #2
    Making some progress. I now am using VBscript to run lame.exe and encode the wav to the correct mp3 setting that I need.

    Using IVR in HomeSeer Phone I can run a script using.

    VBSCRIPT:hs.run("password.txt");NEXT:;NEXT:

    but how can I pass a variable (such as $VAR1) into the script? Is this possible?

    I still need to add some kind of simple password that is based on the ID number entered (see above message) and figure out how to convert "4456" to "4 4 6 6" so it will read it back one number at time.

    Here is the latest code
    <pre class="ip-ubbcode-code-pre">
    ###########################################################
    # ID number recorder #
    # Version 1.1 #
    ###########################################################

    LABEL:START

    CLEAR_KEY:
    SPEAK:Hello, Enter your ID Number. When you are finished, press the pound key.
    WAIT_KEY:#
    SET:$VAR1=$DTMF
    SPEAK:The Number you entered is
    SPEAK:$VAR1

    LABEL:RECORDING
    SPEAK:Start Recording at the tone. Press any key on your telephone when you are done.
    CLEAR_KEY:
    PLAY:beep.wav
    RECORD:c:\temp\phone\$VAR1.wav
    WAIT_KEY:123456789#*
    END_RECORD:
    SPEAK:I am now converting the file to mp3.
    VBSCRIPT:hs.Launch("c:\temp\phone\lame", "-b 16 --resample 11.025 " & $VAR1 & ".wav " & $VAR1 & ".mp3", "c:\temp\phone\");NEXT:;NEXT:
    SPEAK:File Conversion is now done.
    CLEAR_KEY:

    LABEL:MENU1
    SPEAK:To hear your recording, press 1. To Try again Press 2. If you are done, press 3 or hang up.
    WAIT_KEY:123456789#*
    IF:$DTMF_KEY=1;GOTO:HEAR_RECORDING;NEXT:
    IF:$DTMF_KEY=2;GOTO:RECORDING;NEXT:
    IF:$DTMF_KEY=3;GOTO:HANGUP;NEXT:
    SPEAK:Sorry, that key is not an option. Please try again.
    GOTO:MENU1

    LABEL:HANGUP
    SPEAK:Your Recording has been saved. Good Bye
    HANGUP:

    LABEL:HEAR_RECORDING
    CLEAR_KEY:
    PLAY:c:\temp\phone\$VAR1.wav
    GOTO:MENU1

    HANGUP:
    </pre>

    Comment


      #3
      You can pass $VAR1 to your script like this:

      1) Change:
      sub main()
      ..
      end sub

      To this instead:
      sub main(InData)

      end sub

      2) In your IVR
      VBSCRIPT:hs.runex("password.txt","main",$VAR1);NEXT:;NEXT:

      The variable "InData" should contain the contents of $VAR1.

      Good Luck,
      Doug

      Comment


        #4
        Thank you for the reply. It works and now I can pass a variable to a script!

        A script can only return a True or False back to HSPhone but I can not figure out how to do this.

        Commands such as
        VBSCRIPT:hs.IsOn("B3");SPEAK:True;SPEAK:False

        will return a True or False but How would I make the script below return a true or false to HomeSeer Phone using
        VBSCRIPT:hs.runex("test.vbs","main",$VAR1);SPEAK:True;SPEAK: False

        <pre class="ip-ubbcode-code-pre">
        sub main(InData)

        if InData = 13 then
        password = True
        end if

        end sub
        </pre>

        Comment


          #5
          I could not figure how to get hs.runex to return a TRUE or FALSE from a IVR script in Homeseer Phone so this is what I did.

          I created a Virtual Device and when my IVR script first runs it sets the device to OFF.

          VBSCRIPT:hs.execx10 ("z20","off",0);NEXT:;NEXT:

          I needed to pass two variables to a script file but it seems you can only pass one (someone let me know if this is not correct), so I first run a script with Run.ex

          VBSCRIPT:hs.runex("writephoneid.vbs","main",$VAR1);NEXT:;NEX T:

          this script writes a text file with the value of my variable on the first line. I then run another script

          VBSCRIPT:hs.runex("password.vbs","main",$VAR2);NEXT:;NEXT:

          This loads the first line of the text file that "writephoneid.vbs" wrote so now I have my two variables that I need from my IVR script.

          The script then compares the two variables (one from the text file, the other one passed on via hs.Runex) and runs an IF statement and turns my virtual device (z20) ON or OFF depending if it was true or false.

          Back in my IVR script I then run this line

          VBSCRIPT:hs.IsOn("z20");SPEAK:Password is correct;SPEAK:Wrong Password

          This seems like a really screwball way of making it do what I want and was wondering if there might be a better way.

          It would be great if you could break into multiline VBscript right in IVR. It is kind of a pain and there are many limitations since there is no way to pass a variable (besides a simple true or false) back to your IVR script that you are doing with VBscript.

          Comment


            #6
            Ok, to go the other way you need to use a VBscript "Function" instead of a "Sub"routine.

            Instead of:
            sub main(InData)
            ...
            sub

            Use:
            function main(InData)
            main=True
            if I_WantToReturnFalse then
            main=False
            end if
            end function

            The function name is used just like a variable and that variable's value will be returned when the function finishes. NOTE: IVR currently only allows a True or False value to be returned!

            I'm not entirely sure that you can use the name "main" for a function. You may need to use a different name than that for it to work. Try it and let me know.

            This should return True or False back to the IVR when you use:

            VBSCRIPT:hs.runex("password.txt","main",$VAR1);GOTO:IT_WAS_T RUE;GOTO:IT_WAS_FALSE


            Hope this helps,
            Doug

            Comment


              #7
              Below is a small script that will take the 4 digit "code" and separate the digits with a ",". This way when it is read back, it goes a bit slower for the user to verify that they entered the number correctly. I hard coded the "code" at the top so you can see how it works. Simply change out the variable's to what you are using. I hope this helps.

              -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

              dim mycode
              dim mycodenew

              sub main()

              mycode=1234

              for x = 1 to 4
              mycodenew = mycodenew + mid(mycode,x,1) + ","

              next

              end sub

              -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
              Visit My Home Seer Site at:
              www.JohnWPB.com
              Created with LCARS

              Comment


                #8
                dwoolridge:
                Thanks for the info. It works great!

                This is a lot better than depending on the status of a virtual device.

                JohnWPB: thanks for letting me know about the "," trick, it does sound better.

                Comment


                  #9
                  Thanks everyone for your help. The system is pretty much done and works great.

                  I found a great command line based normalizer that works great and is very fast that I am using with my script.
                  http://www.neon1.net/prog/normalizer.html

                  This makes it so everybodys message is the same volume. If a person is on a quiet telephone line, it will boost it up. I think this method is a lot better than turning up the record volume in homeseer.

                  Comment

                  Working...
                  X