Sign in to follow this  
Followers 0
NELyon

Very bored script:PSP-Style TTS

8 posts in this topic

#1 ·  Posted (edited)

Yes, i was extremely bored. I had nothing else to do, so i created a Text-to-speech program in the shape of a PSP. I didn't like SAPI's voices, so i found CyberZeroCool's AT&T voices, and put it into a cool PSP Shape.

The screen is an Edit box. Press enter and wait a minute. It will say what you typed in AT&T's "Mike" voice.

A lot of credit goes to CyberZeroCool because i just built the PSP around his TTS script.

#include <GUIConstants.au3>
#Include <IE.au3>
HotKeySet("{enter}", "talk")
$gui = GUICreate("",541,235,-1,-1, $WS_POPUP)
$pic = GUICtrlCreatePic(@ScriptDir &"\psp.bmp",0,0,541,235, -1, $GUI_WS_EX_PARENTDRAG)
GUICtrlSetState($pic, $GUI_DISABLE)
$Data_Txt = GUICtrlCreateEdit("", 111, 16, 319, 188)




GUISetState()
While 1
    $msg = GUIGetMsg()
WEnd

Func talk()
$data_voice = "mike"; Or crystal
$ie = _IECreate( "http://www.research.att.com/~ttsweb/tts/demo.php", 0, 0 )
$form = _IEFormGetObjByName( $ie, "demoForm" )
$voice = _IEFormElementGetObjByName( $form, "voice" )
_IEFormElementSetValue( $voice, $data_voice )
$txt = _IEFormElementGetObjByName( $form, "txt" )
_IEFormElementSetValue( $txt, GUICtrlRead($data_txt) )
$submit = _IEFormElementGetObjByName( $form, "downloadButton" )
$submit.click
_IELoadWait( $ie )
$read = _IEBodyReadText( $ie )
_IEQuit( $ie )
$start = "Your audio can be found at "
$end = "To download, right-click the link above."
$url = extractString( $read, $start, $end )
$url = "http://192.20.225.55" & $url
ConsoleWrite( $url )
InetGet( $url, @TempDir & "\tts.wav", 1 )
SoundPlay( @TempDir & "\tts.wav", 1 )
EndFunc

Func extractString($string, $startString, $endString)
    ;this function returns the contents of a string between two substrings
    $startStringPos = StringInStr($string, $startString)
    $endStringPos = StringInStr($string, $endString)
    $startPos = $startStringPos + StringLen($startString) - 1
    $endPos = $endStringPos - 1
    $extractedString = StringLeft($string, $endPos)
    $extractedString = StringTrimLeft($extractedString, $startPos)
    Return $extractedString
EndFunc   ;==>extractString

Heres the ZIP with the image in it.

http://codemyster.zapto.org/psp.zip

Have fun!

Edited by D-Generation X

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

Just bored....

fixed it up a bit... rich edit, rounded corners...placed exit and talk buttons on screen

#include <GUIConstants.au3>
#Include <IE.au3>
#include <Misc.au3>

$struct_string = DllStructCreate("char[496]")
$color =  0xbebebe

HotKeySet("{F9}", "talk")


$gui = GUICreate("",539,233,-1,-1, $WS_POPUP) ;,0x00000020)

_GuiRoundCorners($gui, 1, 0, 160, 230)

GUISetBkColor("")
$pic = GUICtrlCreatePic(@ScriptDir &"\psp.bmp",-1,-1,541,235, -1, $GUI_WS_EX_PARENTDRAG)

GUICtrlSetState($pic, $GUI_DISABLE)
;$Data_List = GUICtrlCreateList("", 111, 15, 319, 190, BitOR($ES_MULTILINE, $ES_READONLY, $ES_AUTOVSCROLL,$WS_HSCROLL,$WS_VSCROLL))
;GUICtrlSetBkColor( -1, 0x0000FF)
;GUICtrlSetFont( -1, 12, 700)

$oRP = ObjCreate("RICHTEXT.RichtextCtrl.1")
$Data_Txt = GUICtrlCreateObj( $oRP, 10, 10 , 400 , 260 )
GUICtrlSetPos($Data_Txt,111, 15, 319, 190)

With $oRP; Object tag pool
.OLEDrag()
;.Font = 'Arial'
.SelFontSize = 12
.text = "Replace this text.... "
;.FileName = @ScriptDir & '\RichText.rtf'
.BackColor = $color
EndWith


$bpower = GUICtrlCreateLabel("", 470, 122, 22, 22)
GUICtrlSetTip( -1, "Power Off")
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$blist = GUICtrlCreateLabel("", 438, 91, 22, 22)
GUICtrlSetTip( -1, "Voice List?")
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$bedit = GUICtrlCreateLabel("", 500, 91, 22, 22)
GUICtrlSetTip( -1, "View Talk Box?")
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$bconsole = GUICtrlCreateLabel("", 470, 61, 22, 22)
GUICtrlSetTip( -1, "View Console?")
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$btalk = GUICtrlCreateLabel("", 50, 165, 22, 22)
GUICtrlSetTip( -1, "Speak Now")
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)

GUISetState()

$h_REdit = ControlGetHandle($gui,"","RichTextWndClass1")

_SendMessage($h_REdit, $WM_GETTEXT, 4096, DllStructGetPtr($struct_string))
ConsoleWrite(DllStructGetData($struct_string, 1) & @LF)

While 1
    $msg = GUIGetMsg()
    Switch $msg
            
        Case $blist
            MsgBox(0x0,"Test", "..... do domething here   ", 3)
        Case $bedit
            MsgBox(0x0,"Test", "..... do domething here   ", 3)
        Case $bconsole
            MsgBox(0x0,"Test", "..... do domething here   ", 3)            
        Case $bpower
            Exit
        Case $btalk
            talk()
    EndSwitch
WEnd

Func talk()
    _SendMessage($h_REdit, $WM_GETTEXT, 4096, DllStructGetPtr($struct_string))
    Local $speak_text = DllStructGetData($struct_string, 1)
$data_voice = "mike"; Or crystal
$ie = _IECreate( "http://www.research.att.com/~ttsweb/tts/demo.php", 0, 0 )
$form = _IEFormGetObjByName( $ie, "demoForm" )
$voice = _IEFormElementGetObjByName( $form, "voice" )
_IEFormElementSetValue( $voice, $data_voice )
$txt = _IEFormElementGetObjByName( $form, "txt" )
_IEFormElementSetValue( $txt, $speak_text )
$submit = _IEFormElementGetObjByName( $form, "downloadButton" )
$submit.click
_IELoadWait( $ie )
$read = _IEBodyReadText( $ie )
_IEQuit( $ie )
$start = "Your audio can be found at "
$end = "To download, right-click the link above."
$url = extractString( $read, $start, $end )
$url = "http://192.20.225.55" & $url
ConsoleWrite( $url )
InetGet( $url, @TempDir & "\tts.wav", 1 )
SoundPlay( @TempDir & "\tts.wav", 1 )
EndFunc

Func extractString($string, $startString, $endString)
    ;this function returns the contents of a string between two substrings
    $startStringPos = StringInStr($string, $startString)
    $endStringPos = StringInStr($string, $endString)
    $startPos = $startStringPos + StringLen($startString) - 1
    $endPos = $endStringPos - 1
    $extractedString = StringLeft($string, $endPos)
    $extractedString = StringTrimLeft($extractedString, $startPos)
    Return $extractedString
EndFunc   ;==>extractString
    
    
Func _GuiRoundCorners($h_win, $i_x1, $i_y1, $i_x3, $i_y3) ; thanks gafrost
    Local $XS_pos, $XS_ret, $XS_ret2
    $XS_pos = WinGetPos($h_win)
    $XS_ret = DllCall("gdi32.dll", "long", "CreateRoundRectRgn", "long", $i_x1, "long", $i_y1, "long", $XS_pos[2], "long", $XS_pos[3], "long", $i_x3, "long", $i_y3)
    If $XS_ret[0]Then
        $XS_ret2 = DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $h_win, "long", $XS_ret[0], "int", 1)
    EndIf
EndFunc   ;==>_GuiRoundCorners

8)

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites

@Valuater

I can't edit that text. Also, use $oRP.Text to get the text


My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

@Valuater

I can't edit that text. Also, use $oRP.Text to get the text

updated...

BTW... i tried that " use $oRP.Text to get the text "

it didn't work, so i found a post with that same question and gafrost created the controls to get the text

( i also used gafrost's round corners UDF )

8)

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites

I just noticed it was the listbox there. Thanks anyway


My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.

Share this post


Link to post
Share on other sites

Ugh. I'm still having the RichTextCtrl problem i was having with RazerM's au3 editor. FOr some reason, the control just won't register.

Share this post


Link to post
Share on other sites

I don't think it's really needed in this case anyway. I found something a while ago that says you should put richtx32.ocx in c:\windows\system and then register it


My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.

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