Jump to content

Voices


James
 Share

Recommended Posts

;Speak("text to speak", 1-10 rate of speaking,
;0 - 100 Colume
$input=InputBox("Text to Speak", "Type Text")
Dim $voice = ObjCreate("Sapi.SpVoice")
Func Speak($Text, $Rate, $Vol) 
$voice.Rate = $Rate
$voice.Volume = $Vol
$voice.Speak($Text)
EndFunc
Speak($input, 1, 100)


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Link to comment
Share on other sites

Hi,

sure, here is some code from the forum :

Global $voice = 3
Global $talkspeed = 5
Global $song = "no"
AutoItWinSetTitle("Talk2Me")
#NoTrayIcon
$oMyError = ObjEvent("AutoIt.Error","MyErrFunc"); Install a custom error handler
Opt("WinTitleMatchMode",4)
#include <Misc.au3>
#include <GUIConstants.au3>
$gui = GUICreate("Talk2Me 1.1",205, 225, 295, 195)
GUISetIcon(@scriptdir & "\talk2me.ico")
$whatsay= GUICtrlCreateEdit("", 2, 2, 200, 200, -1, $WS_EX_CLIENTEDGE)
$file=GUICtrlCreateMenu("File") ;^_^ There is some fun in creating comments...
$new=GUICtrlCreateMenuitem("New",$file)
$talk=GUICtrlCreateMenuitem("Talk!",$file) ;Three, two, one, TALK! Blablablabla!
$voicechoose=GUICtrlCreateMenuitem("Change voice",$file)
$import=GUICtrlCreateMenuitem("Import...",$file) ;Du bist im port...
$fromclip=GUICtrlCreateMenuitem("Import from clipboard",$file) ;What a clip do you want?
$export=GUICtrlCreateMenuitem("Export...",$file)
$exit=GUICtrlCreateMenuitem("Exit", $file)
$more=GUICtrlCreateMenu("More") ;More what?
$invisible=GUICtrlCreateMenuitem("Transparent window",$more)
$visible=GUICtrlCreateMenuitem("Solid window",$more)
$lesstrans=GUICtrlCreateMenuitem("Widget transparention",$more) ;Got it!
$play=GuiCtrlCreateMenuItem("Play MP3", $more)
$tshow=GuiCtrlCreateMenuItem("Show toolbox", $more)
$color=GUICtrlCreateMenuitem("Change color (border)", $more)
$font=GUICtrlCreateMenuitem("Change font (edit box)", $more)
GUISetState(@SW_SHOW)
;Create toolbox
$toolbox = GUICreate("Toolbox", 120, 106, 321, 150,-1, $WS_EX_TOOLWINDOW)
GUISetIcon(@scriptdir & "\talk2me.ico")
$ttalk = GUICtrlCreateButton("Talk", 6, 4, 42, 21)
$timport = GUICtrlCreateButton("Import", 55, 4, 53, 21)
$texport = GUICtrlCreateButton("Export", 6, 27, 42, 20)
$twidget = GUICtrlCreateButton("Widget transparency", 6, 51, 102, 22)
$tcloset = GUICtrlCreateButton("Close toolbox", 6, 79, 102, 19)
$tnew = GUICtrlCreateButton("New", 54, 27, 54, 20)
GUISetState(@SW_SHOW)
;Music toolbox - Not showed. It will be showed after call from function.
$mform = GUICreate("Music play", 121, 92, 256, 176, -1, $WS_EX_TOOLWINDOW)
$mplay = GUICtrlCreateButton("Play", 3, 3, 52, 22)
$mstop = GUICtrlCreateButton("Stop", 60, 3, 55, 22)
$mopen = GUICtrlCreateButton("Open", 30, 30, 52, 25)
$mclose = GUICtrlCreateButton("Close toolbox", 3, 60, 112, 25)
GUISetState(@SW_HIDE,$mform)
While 1
    $msg = GuiGetMsg()
    $string=GUICtrlRead($whatsay)
    Select
    ;music play
Case $msg = $mplay
    If $song = "no" Then
        MsgBox(16,"No opened song","You must open song for play")
    Else
        SoundPlay($song)
        SplashTextOn("","Now playing" & @CRLF & $song, 300,100,0,0,1)
        Sleep(2000)
        SplashOff()
    EndIf
Case $msg = $mstop
    SoundPlay("")
Case $msg = $mopen
    $whatplay=FileOpenDialog("Open song to play",@MyDocumentsDir,"MP3 files (*.mp3)|WAV files (*.wav)",1)
    If @error = 0 then
        $song = $whatplay
    EndIf
Case $msg = $mclose
    GuiSetState(@SW_HIDE, $mform)
    ;for everything
    Case $msg = $GUI_EVENT_CLOSE
        Exit
    ;Toolbox
    Case $msg = $tcloset
        GUISetState(@SW_HIDE,$toolbox)
    Case $msg = $tnew
        GUICtrlSetData($whatsay,"","")
    Case $msg = $texport
        $wheresave=FileSaveDialog("Export to TXT",@MyDocumentsDir,"Text files (*.txt)",18)
    If @error Then
        MsgBox(16,"You really think I am stupid?","You are entered bad value..." & @crlf & "Error: Path Must Exist")
    Else
        FileWrite($wheresave & ".txt", $string)
    EndIf
Case $msg = $timport
    $whatopen=FileOpenDialog("Import to Talk2Me",@MyDocumentsDir,"Text files (*.txt)", 1)
    If @error = 0 Then
    $read=FileRead($whatopen)
    GUICtrlSetData($whatsay,$read)
EndIf
    Case $msg = $twidget
        WinSetTrans("Talk2Me 1.1",$string,225)
    Case $msg = $ttalk
        _TalkOBJ($string, $voice,$talkspeed)
    ;Choose voice
    Case $msg = $voicechoose
        $voiceform = GUICreate("Change voice", 217, 227, 230, 148, $WS_POPUP, BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW))
        $vgroup = GUICtrlCreateGroup("Choose voice", 7, 6, 204, 88)
        $samchoose = GUICtrlCreateRadio("Microsoft Sam", 17, 20, 149, 26)
        GUICtrlSetState(-1, $GUI_CHECKED)
        $mikechoose = GUICtrlCreateRadio("Microsoft Mike (only if installed)", 17, 42, 171, 21)
        $marychoose = GUICtrlCreateRadio("Microsoft Mary (only if installed)", 17, 61, 191, 21)
        GUICtrlCreateGroup("", -99, -99, 1, 1)
        $test = GUICtrlCreateButton("Test!", 7, 166, 55, 22)
        $okay = GUICtrlCreateButton("OK", 122, 166, 71, 22)
        GUICtrlCreateLabel("Speed:", 6, 96, 38, 17)
        $speed = GUICtrlCreateSlider(0, 111, 211, 31)
        GUICtrlCreateLabel("Normal", 9, 141, 37, 17)
        GUICtrlCreateLabel("Maximum", 159, 141, 48, 17)
        GUISetState(@SW_SHOW)
        While 2
            $msg = GuiGetMsg()
            $getsam = GUICtrlRead($samchoose)
            $getmary = GuiCtrlRead($marychoose)
            $getmike = GuiCtrlRead($mikechoose)
            $getspeed = GUICtrlRead($speed)
            Select
            Case $msg = $GUI_EVENT_CLOSE
                GuiDelete($voiceform)
                ExitLoop
            Case $msg = $test
                If $getsam = $GUI_CHECKED Then _TalkOBJ("You have selected Microsoft Sam as the Talk2Me default voice",3,$getspeed)
                If $getmary = $GUI_CHECKED Then _TalkOBJ("You have selected Microsoft Mary as the Talk2Me default voice",1,$getspeed)
                If $getmike = $GUI_CHECKED Then _TalkOBJ("You have selected Microsoft Mike as the Talk2Me default voice",2,$getspeed)
            Case $msg = $okay
                If $getsam = $GUI_CHECKED Then Global $voice = 3
                If $getmary = $GUI_CHECKED Then Global $voice = 1
                If $getmike = $GUI_CHECKED Then Global $voice = 2
                If $getmike = $GUI_UNCHECKED Or $getmary = $GUI_UNCHECKED Or $getsam = $GUI_UNCHECKED Then Global $voice = 3
                $talkspeed = $getspeed
                GuiDelete($voiceform)
                ExitLoop
            EndSelect
            WEnd
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case $msg = $new
    GUICtrlSetData($whatsay,"","")
Case $msg = $fromclip
    $clipboard=ClipGet()
    $error = @error
    If $error = 1 Then ;If...
        MsgBox(16,"Error","Clipboard is empty. Error code: 1")
    ElseIf $error = 2 Then ;ElseIf...
        MsgBox(16,"Error","Clipboard contains non-text item. Error code: 2")
    ElseIf $error = 3 OR $error = 4 Then;ElseIf...
        MsgBox(16,"Error","Unable to access clipboard. Error code: 3") 
    ElseIf $error = 0 Then ;Again...
    GuiCtrlSetData($whatsay,$clipboard)
    EndIf
    Case $msg = $talk
    _TalkOBJ($string,$voice,$talkspeed)
    Case $msg = $import
    $whatopen=FileOpenDialog("Import to Talk2Me",@MyDocumentsDir,"Text files (*.txt)", 1)
    If @error = 0 Then
    $read=FileRead($whatopen)
    GUICtrlSetData($whatsay,$read)
    EndIf
    Case $msg = $export
    $wheresave=FileSaveDialog("Export to TXT",@MyDocumentsDir,"Text files (*.txt)",18)
    If @error Then
        MsgBox(16,"You really think I am stupid?","You are entered bad value..." & @crlf & "Error: Path Must Exist")
    Else
        FileWrite($wheresave & ".txt", $string)
    EndIf
    Case $msg = $exit
    Exit 0
    ;Here we go to MORE menu
Case $msg = $tshow
    GUISetState(@SW_SHOW,$toolbox)
    Case $msg = $lesstrans
    WinSetTrans("Talk2Me 1.1",$string,225)
    Case $msg = $invisible
    WinSetTrans("Talk2Me 1.1",$string,30)
    Case $msg = $visible
    WinSetTrans("Talk2Me 1.1",$string,255)
    Case $msg = $play
    GUISetState(@SW_SHOW, $mform)
    Case $msg = $color
    $colorRGB=_ChooseColor(2,0,2)
    GUISetBkColor($colorRGB,$gui)
    Case $msg = $font
    $font=_ChooseFont("Comic Sans MS",10)
    GUICtrlSetFont($whatsay,$font[3],$font[4],$font[1],$font[2])
    GUICtrlSetColor($whatsay,$font[7])
    EndSelect
WEnd
Exit
;Thanks gafrost on that functions. :-)
Func _TalkOBJ($s_text, $s_voice = 3,  $s_rate = 5)
    Local $o_speech = ObjCreate ("SAPI.SpVoice")
     $o_speech.Rate = $s_rate ;That idea th.meger
        Select
            Case $s_voice == 1
                $o_speech.Voice = $o_speech.GetVoices("Name=Microsoft Mary", "Language=409").Item(0)
            Case $s_voice == 2
                $o_speech.Voice = $o_speech.GetVoices("Name=Microsoft Mike", "Language=409").Item(0)
            Case $s_voice == 3
                $o_speech.Voice = $o_speech.GetVoices("Name=Microsoft Sam", "Language=409").Item(0)
            EndSelect
    $o_speech.Speak ($s_text)
EndFunc  ;==>_TalkOBJ
Func MyErrFunc()
   $HexNumber=hex($oMyError.number,8)
   Msgbox(0,"","We intercepted a COM Error !" & @CRLF & _
               "Number is: " & $HexNumber & @CRLF & _
               "Description is: " & $oMyError.description )

   SetError(1); something to check for when this function returns
Endfunc

So long,

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

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...