Jump to content

Sample Script: Auto Talk


Recommended Posts

Being as how I can't post to the example scripts forum, I thought I'd put it here.

This is an edited combination of three scripts demonstrating command line parameters, speech, and network information grabbing. I played with it for awhile, and it's fun - to me, anyway. I only have one sapi voice, so I didn't bother with the add-ons that quickly spring to mind, such as changing the voice, volume, et cetera.

See what you think... zip file with code and sample readable text is attached (I hope - ain't never done no attaches in this forum, so maybe it's there, and maybe it ain't - I looked at the preview before posting, and I don't see it there, but maybe that's just the way preview works...).

Cheers.

; voice read text
; Author erifash ( and others )
; Editor longtex
; using default voice, "Terran" was rendered "Turrun"
; sometimes a little creative spelling works wunders, sum thymes knot

#include <File.au3>
;$cmdline[0] is the number of parameters passed
If $cmdline[0] <> 0 Then
   $filename = $cmdline[1]
Else 
   $filename = "autotalk.say"
EndIf
$file = FileOpen($filename, 0)

; Check if file opened for reading OK
If $file = -1 Then
     MsgBox(0, "Error", "Unable to open file: '"&$filename&"'")
     
    ; well, hell, let's read SOMEthing...
; default behavior
    Dim $temp
    Dim $adapter[10][10]

    getmyip()
    $myip =  $adapter[0][4] 
    _TalkOBJ("Thank you for choosing Earth as your home.")
    _TalkOBJ("Your location is at Eye Pee address "&$myip)
    _TalkOBJ("Unnnnn-authorized access has been attempted.")
    _TalkOBJ("You have contacted the Tair ane Occupation Government Treasurer's Office.")
    _TalkOBJ("Your telephone number and Gee Pee Ess coordinates have been recorded.")
    _TalkOBJ("This call may be monitored by Home Planet Security.")
    _TalkOBJ("Do not hang up, and do not move more than ten meters from your currently recorded location.")
    _TalkOBJ("Failure to comply may result in immediate termination with extreme prejudice.")
    _TalkOBJ("Every thing that is not required is prohibited.")
    _TalkOBJ("Your call may be important to us.")
    _TalkOBJ("A representative may be on the line shortly.")
    _TalkOBJ("This call may be recorded for quality control purposes or as evidence in hearings before the Military Tribunal.")
    _TalkOBJ("Do not hang up, or you may be charged with unnnnnn-authorized attempted access to government facilities.")
    _TalkOBJ("Every thing that is not required is prohibited.")
    _TalkOBJ("Long Live Our Glorious Leader!")

    MsgBox(0, "Talker", 'Command line parameters incorrect.' & @CRLF & 'Command line usage: "' & @ScriptName & '" "file to READ"')
    Msgbox(64,'Talker',  'Command line parameters incorrect.'&@CRLF& _
                    '----------------------------'&@crlf& _
                    'Command line usage: '&@crlf& _
                    '     talker <name of text file>'&@crlf& _
                    '----------------------------'&@crlf& _
                    'Program will read aloud the text'&@crlf& _
                    'stored in the file. '&@crlf& _
                    'have'&@crlf& _
                    'fun'&@crlf& _
                    'Bucko')
Else
                    
;$nlines = _FileCountLines($file)                      doesn't exist in my version of autoit 
;MsgBox(0,"Size of File","File contains "& $nlines)
; Read in lines of text until the EOF is reached

 While 1
    $line = FileReadLine($file)
    If @error = -1 Then ExitLoop
; speak the text
    _TalkOBJ($line)
    
  Wend
 ;MsgBox(0,"CmdLine","That's all the lines in the file...")
  FileClose($file)
 EndIf
 
    


Func _TalkOBJ($s_text)
    Local $o_speech
    $o_speech = ObjCreate("SAPI.SpVoice")
    $o_speech.Speak ($s_text)
    $o_speech = ""
EndFunc;==>_TalkOBJ



Func getmyip ()
    
RunWait(@ComSpec & " /c " & "IPCONFIG.EXE /all"  & " > " & "IPINFO.TXT", @MyDocumentsDir, @SW_HIDE)
_FileReadToArray(@MyDocumentsDir & "\IPINFO.TXT", $temp )
RunWait(@ComSpec & " /c " & "DEL.EXE IPINFO.TXT", @MyDocumentsDir, @SW_HIDE)
;$temp holds all IP info in a text array
$arraysize = ubound($temp)

$arraysize= $arraysize-1
$count =0;set up counter for other arrays
$adaptercount = 0;setup counter for # of adapters
For $n = 0 to $arraysize
 $temp[$n] = StringStripWS($temp[$n],4)
;locate the machine's name for display
    $result = stringinstr(  $temp[$n], "Host Name") 
    if $result <> 0 then 
    $machinename = stringstripcr(stringmid($temp[$n], 37))
    endif
;process adapter info  1st drop to next line
    $result = stringinstr(  $temp[$n], "Description") 
    if $result = 0 then
 continueloop
    else
    $adaptercount =$adaptercount +1; add to adapter count
;   msgbox (0,"", $adaptercount)
;load up the adapter array with info -- some may be bogus
;cycle through list pulling out info



    $adapter[$count][0] =stringstripcr(stringmid($temp[$n-3], 18));connection name
$lengthtemp = stringlen($adapter[$count][0])
$adapter[$count][0]= stringleft( $adapter[$count][0], $lengthtemp-1)
;msgbox (0, "", $adapter[$count][0])

    $adapter[$count][1] = stringstripcr(stringmid($temp[$n], 45)) ;adapter name
    $adapter[$count][2] = stringstripcr(stringmid($temp[$n+1], 45)) ; adpater mac address
    $adapter[$count][3] = stringstripcr(stringmid($temp[$n+2], 45)); DHCP enabled yes/no
if $adapter[$count][3] = "Yes" then 
;skip auto configure line for DHCP enabled 

    $adapter[$count][4] = stringstripcr(stringmid($temp[$n+4], 45)) ; adapter IP address
    $adapter[$count][7] = stringstripcr(stringmid($temp[$n+7], 45))  ;adapter DHCP Server
    $adapter[$count][5] = stringstripcr(stringmid($temp[$n+5], 45))  ;adapter subnet mask
    $adapter[$count][6] = stringstripcr(stringmid($temp[$n+6], 45))  ;adapter gateway
    $adapter[$count][8] = stringstripcr(stringmid($temp[$n+8], 45))  ;adapter DNS Server
;$n= $n +1
;not DHCP is the next stuff
else
    $adapter[$count][4] = stringstripcr(stringmid($temp[$n+3], 45))  ;adapter IP address if not DHCP
    $adapter[$count][7] = "None" ;NO DHCP SERVER
    $adapter[$count][5] = stringstripcr(stringmid($temp[$n+4], 45))  ;adapter subnet mask
    $adapter[$count][6] = stringstripcr(stringmid($temp[$n+5], 45))  ;adapter gateway
    if $n+6 <= $arraysize Then
    ;assume static IP has DNS server
        $adapter[$count][8] = stringstripcr(stringmid($temp[$n+6], 45))  ;adapter DNS Server
    EndIf
endif

    $count= $count +1 
    EndIf
Next
endfunc

autotalk.zip

Nobody needs a job. Not much, anyway. Before you need a job, there's a lot of other stuff you need. More or less in order of how badly you need them: AIR, WATER, FOOD, SHELTER, CLOTHING, COMPANIONSHIP, and ACTIVITY. You've been led to believe you need money to "pay" someone else to provide those for you - all but AIR, so far. How long is it going to be before you have to "pay" for AIR, too?

Link to comment
Share on other sites

Copy this to a file, like afd.txt; the easy thing to do might be to overwrite autotalk.say (the default text to read). Otherwise you can run it by --- duh --- command line: autotalk afd.txt

Say... besides being kinda funny, this might have some voicemail system implications, mightn't it?

EH, F, DEE 
Thank you for calling the Austin Fire Department.
Welcome to our new voice response system.
Please listen carefully to the menu options.
Press 1 if you see flames.
Press 2 if you see, or smell, smoke, but do not see flames.
Press 3 if you can smell smoke, and also see flames.
Press 4 if you can not smell smoke and can not see flames, but you do feel a burning sensation.
Press 5 if you think there is someone trying to break into your house,
and you know that EH, F, DEE will be there while the cops are trying to decide
between jelly filled or glazed with sprinkles, and arguing over who locked the keys in the patrol car.
Press 0 to repeat this menu.
Austin Fire Department, for all your fire control and rescue needs.
Edited by longtex

Nobody needs a job. Not much, anyway. Before you need a job, there's a lot of other stuff you need. More or less in order of how badly you need them: AIR, WATER, FOOD, SHELTER, CLOTHING, COMPANIONSHIP, and ACTIVITY. You've been led to believe you need money to "pay" someone else to provide those for you - all but AIR, so far. How long is it going to be before you have to "pay" for AIR, too?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...