Sign in to follow this  
Followers 0
Skrip

Make This Script Faster?

10 posts in this topic

#1 ·  Posted (edited)

Is there a way to make this script 'speak' faster?

Main Code:

#include <talk.au3>


hotkeyset('{esc}', 'halt')
func halt()
    exit
endFunc
;----------------------Variables------------------------------------
#cs
Total Keys:
36
#ce
Global $freq
Global $delay=50
;----------------------------Default-----------------------------------

;---------------------------_IsPressed Function----------------------------
Func _IsPressed($hexKey)
; $hexKey must be the value of one of the keys.
; _IsPressed will return 0 if the key is not pressed, 1 if it is.
; $hexKey should entered as a string, don't forget the quotes!
; (yeah, layer. This is for you)

  Local $aR, $bO

  $hexKey = '0x' & $hexKey
  $aR = DllCall("user32", "int", "GetAsyncKeyState", "int", $hexKey)
  If Not @error And BitAND($aR[0], 0x8000) = 0x8000 Then
     $bO = 1
  Else
     $bO = 0
  EndIf

  Return $bO
EndFunc;==>_IsPressed
;----------------------------What The Whole script is------------------
While 1
;~~~Numbers
If _IsPressed(30) then;0

   While _IsPressed(30)
   _Talk("0")
   Wend
Endif
If _IsPressed(31) then;1

      While _IsPressed(31)
   _Talk("1")
   WEnd
Endif
If _IsPressed(32) then;2

         While _IsPressed(32)
   _Talk("2")
   WEnd
Endif
If _IsPressed(33) then;3

      While _IsPressed(33)
   _Talk("3")
   WEnd
Endif
If _IsPressed(34) then;4

      While _IsPressed(34)
   _Talk("4")
   WEnd
Endif
If _IsPressed(35) then;5

      While _IsPressed(35)
   _Talk("5")
   WEnd
Endif
If _IsPressed(36) then;6

      While _IsPressed(36)
   _Talk("6")
   WEnd
Endif
If _IsPressed(37) then;7

      While _IsPressed(37)
   _Talk("7")
   WEnd
Endif
If _IsPressed(38) then;8

      While _IsPressed(38)
   _Talk("8")
   WEnd
Endif
If _IsPressed(39) then;9

      While _IsPressed(39)
   _Talk("9")
   WEnd
Endif
;~~~Letters----------------------------------

If _IsPressed(41) then;a

      While _IsPressed(41)
   _Talk("a")
   WEnd
Endif
;~~~~~~
If _IsPressed(42) then;b

      While _IsPressed(42)
   _Talk("b")
   WEnd
Endif
;~~~~~~
If _IsPressed(43) then;c

      While _IsPressed(43)
   _Talk("c")
   WEnd
Endif
;~~~~~~
If _IsPressed(44) then;d

      While _IsPressed(44)
   _Talk("d")
   WEnd
Endif
;~~~~~~
If _IsPressed(45) then;e

      While _IsPressed(45)
   _Talk("e")
   WEnd
Endif
;~~~~~~
If _IsPressed(46) then;f

      While _IsPressed(46)
   _Talk("f")
   WEnd
Endif
;~~~~~~
If _IsPressed(47) then;g

      While _IsPressed(47)
   _Talk("g")
   WEnd
Endif
;~~~~~~
If _IsPressed(48) then;h

         While _IsPressed(48)
   _Talk("h")
   WEnd
Endif
;~~~~~~
If _IsPressed(49) then;i

         While _IsPressed(49)
   _Talk("i")
   WEnd
Endif
;~~~~~~
If _IsPressed("4A") then;j

         While _IsPressed("4A")
   _Talk("j")
   WEnd
Endif
;~~~~~~
If _IsPressed("4B") then;k

         While _IsPressed("4B")
   _Talk("k")
   WEnd
Endif
;~~~~~~
If _IsPressed("4C") then;l

         While _IsPressed("4C")
   _Talk("l")
   WEnd
Endif
;~~~~~~
If _IsPressed("4D") then;m

         While _IsPressed("4D")
   _Talk("m")
   WEnd
Endif
;~~~~~~
If _IsPressed("4E") then;n

         While _IsPressed("4E")
   _Talk("n")
   WEnd
Endif
;~~~~~~
If _IsPressed("4F") then;o

        While _IsPressed("4F")
   _Talk("o")
   WEnd
Endif
;~~~~~~
If _IsPressed(50) then;p

         While _IsPressed(50)
   _Talk("p")
   WEnd
Endif
;~~~~~~
If _IsPressed(51) then;q

         While _IsPressed(51)
   _Talk("q")
   WEnd
Endif
;~~~~~~
If _IsPressed(52) then;r

         While _IsPressed(52)
   _Talk("r")
   WEnd
Endif
;~~~~~~
If _IsPressed(53) then;s

         While _IsPressed(53)
   _Talk("s")
   WEnd
Endif
;~~~~~~
If _IsPressed(54) then;t

         While _IsPressed(54)
   _Talk("t")
   WEnd
Endif
;~~~~~~
If _IsPressed(55) then;u

         While _IsPressed(55)
   _Talk("u")
   WEnd
Endif
;~~~~~~
If _IsPressed(56) then;v

         While _IsPressed(56)
   _Talk("v")
   WEnd
Endif
;~~~~~~
If _IsPressed(57) then;w

         While _IsPressed(57)
   _Talk("w")
   WEnd
Endif
;~~~~~~
If _IsPressed(58) then;x

         While _IsPressed(58)
   _Talk("x")
   WEnd
Endif
;~~~~~~
If _IsPressed(59) then;y

         While _IsPressed(59)
   _Talk("y")
   WEnd
Endif
;~~~~~~
If _IsPressed("5A") then;z

         While _IsPressed("5A")
   _Talk("z")
   WEnd
Endif
;~~~~~~

Wend

Talk.au3

#cs
Name: _Talk 1.0
Author: El-Trucha <eltrucha14@gmail.com>
Date|Time: 2/25/05 | 10:44 PM
Dev Tool: AutoIt v3.1.0
Requirements: WSH 5.6 ENABLED!!
Description: This function speaks whatever 
    string you specify in $sText
#ce

Func _Talk($sText)
    $tempFile = @TempDir & '\talktemp.vbs'  ; Set the temp file
    FileWriteLine($tempFile, 'Dim Talk' & @CRLF & _
    'Set Talk = WScript.CreateObject("SAPI.SpVoice")' & _
    @CRLF & 'Talk.Speak "' & $sText & '"'); Add contents to the temp file
    RunWait('Wscript.exe talktemp.vbs', @TempDir); Run the VBScript
    FileDelete($tempFile)
EndFunc
Edited by Firestorm

[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

still not as fast as i would like

HotKeySet('{esc}', 'halt')

;----------------------Variables------------------------------------
$oi_speech = ObjCreate("SAPI.SpVoice")
$P_key = StringSplit("30,31,32,33,34,35,36,37,38,39", ",")
$S_Key = StringSplit("0,1,2,3,4,5,6,7,8,9", ",")
$dll = DllOpen("user32.dll")

;----------------------------What The Whole script is------------------
While 1
;~~~Numbers1234
    For $x = 1 To $P_key[0]
        $a_R = DllCall($dll, "int", "GetAsyncKeyState", "int", '0x' & $P_key[$x])
        If Not @error And BitAND($a_R[0], 0x8000) = 0x8000 Then $oi_speech.Speak ($S_Key[$x])
    Next
WEnd

Func halt()
    $dll = ""
    $oi_speech = ""
    Exit
EndFunc ;==>halt

8)

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites

C:\autoit\testtalk.au3 (5) : ==> Unknown function name.: 
$oi_speech = ObjCreate("SAPI.SpVoice") 
$oi_speech = ^ ERROR

Error?

(Tried with beta and 3)


[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

Share this post


Link to post
Share on other sites

try this

Speak_Now("How are you")

Func Speak_Now($Now_text)
    Local $oi_speech = ObjCreate("SAPI.SpVoice")
    $oi_speech.Speak ($Now_text)
    $oi_speech = ""
EndFunc   ;==>Speak_Now

Exit

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

C:\autoit\testtalk.au3 (5) : ==> Unknown function name.: 
$oi_speech = ObjCreate("SAPI.SpVoice") 
$oi_speech = ^ ERROR

Error?

(Tried with beta and 3)

thats a beta issue...

you are not running the beta version

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

I updated and it didn't quite work (the script). Please help.


[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

I updated and it didn't quite work (the script). Please help.

1

copy the script to scite

2

in scite...

press tools > Beta Run

8)

PS i am sure of the beta issue because your error says that function is not recognized

Unknown function name.:

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites

works for me with beta 123. Key delay is pretty bad though, instant is always better :) cept if yo lovemaking.


~Projects~1. iPod Ejector 1.0 - Tool Used To Eject iPod in Windows - Uses DevEject.exe :P2. SmartFTP Close Popup Tool - Closes reminders from freeware SmartFTP.~Helpful Links For New Users~1. LXP's Learning AutoIT PDF Guide - <<< Go here for a PDF Guide on learning AutoIT from the ground up!<<<2. AutoIt 1-2-3 <<<Want to learn more about AutoIT quickly? Go Here<<<3. How To Install The Beta And Production Versions Of AutoIT / SciteAutoIT

Share this post


Link to post
Share on other sites

Some more options including speed

_Talk( 'Fast Talking Computer Voice', 5 )

Func _Talk( $sText, $iRate = 1, $iVolume = 100 )
    If $iRate > 10 Or $iVolume > 100 Then Return
    Local $oTalk = ObjCreate( 'SAPI.SpVoice' )
    If Not @error Then
        $oTalk.Rate = $iRate
        $oTalk.Volume = $iVolume
        $oTalk.Speak( $sText )
    EndIf
EndFunc

Use latest AutoIt Beta :)

Share this post


Link to post
Share on other sites

1

copy the script to scite

2

in scite...

press tools > Beta Run

8)

PS i am sure of the beta issue because your error says that function is not recognized

Turns out the beta was installed into the wrong folder...

Testing your script now.


[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

Share this post


Link to post
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
Sign in to follow this  
Followers 0