Jump to content

Change SAPI Voice Output?


Gui
 Share

Recommended Posts

I don't know if this is remotely close to what you are looking for but this function sends text to google then downloads mp3 and plays the voice then deletes the mp3.

I got this off the forums I don't remember who did it, but I thought it was nice.

While 1
    $Input = InputBox("Input", "What to say?")
    If @error > 0 Or $Input = "" Then Exit
    Speech($Input)
WEnd

Func Speech($gspeech)
    Local $temp, $File
    $temp = StringReplace($gspeech, " ", "+")
    $File = StringRegExpReplace($gspeech, "([ .!])", "") 
    If Not FileExists(@TempDir & "\" & $file & ".mp3") Then _
    InetGet("http://translate.google.com/translate_tts?q=" & $temp, _
    @TempDir & "\" & $file & ".mp3")
    SoundPlay(@TempDir & "\" & $file & ".mp3", 1)
    Sleep(1000)
    FileDelete(@TempDir & "\" & $file & ".mp3")
    Return
EndFunc
Edited by rogue5099
Link to comment
Share on other sites

  • 1 month later...

It is possible through the use of sapi objects.

I ran across the parts of this code awhile back and included the ideas in my code.

Cheers :)

Global $SPEECH = ObjCreate("Sapi.SPVoice")

$SPEECH.voice = $SPEECH.GetVoices("Name= Microsoft mike" ).Item(0)

Sleep(800)

$SPEECH.Rate = -4

$SPEECH.Speak($TIME & $H & " " & $MIN)

Sleep(100)

$SPEECH.Rate = 2

$SPEECH.Speak($ND)

Sleep(100)

$SPEECH.Rate = -4

$SPEECH.SpeakCompleteEvent()[/autoit]

Link to comment
Share on other sites

rogue5099: wrote a function which I use to get the google voice for my program Doctor Doctor.

Global $File, $gspeech

;#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 633, 454, 192, 114)
GUISetBkColor(0xA6CAF0)
$Label1 = GUICtrlCreateLabel("The Doctor is in...Select your problem", 40, 16, 524, 36)
GUICtrlSetFont(-1, 20, 800, 0, "Bodoni MT Black")
$Button1 = GUICtrlCreateButton("Headack", 120, 104, 75, 25, $WS_GROUP)
GUICtrlSetBkColor(-1, 0xFFFF00)
$Button2 = GUICtrlCreateButton("Backack", 120, 176, 75, 25, $WS_GROUP)
GUICtrlSetBkColor(-1, 0xFFFF00)
$Button3 = GUICtrlCreateButton("stomach", 120, 240, 75, 25, $WS_GROUP)
GUICtrlSetBkColor(-1, 0xFFFF00)
$Button4 = GUICtrlCreateButton("Footack", 120, 304, 75, 25, $WS_GROUP)
GUICtrlSetBkColor(-1, 0xFFFF00)
$Button5 = GUICtrlCreateButton("Angina", 344, 104, 75, 25, $WS_GROUP)
GUICtrlSetBkColor(-1, 0xFFFF00)
$Button6 = GUICtrlCreateButton("Depressed", 344, 176, 75, 25, $WS_GROUP)
GUICtrlSetBkColor(-1, 0xFFFF00)
$Button7 = GUICtrlCreateButton("Chiles and fever", 336, 240, 91, 25, $WS_GROUP)
GUICtrlSetBkColor(-1, 0xFFFF00)
$Button8 = GUICtrlCreateButton("Can't sleep", 344, 304, 75, 25, $WS_GROUP)
GUICtrlSetBkColor(-1, 0xFFFF00)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

$File = "tempspeak"

;Funtion written by rogue5099:  
Func speech()
    Local $temp, $file1
    $temp = StringReplace($gspeech, " ", "+")
    InetGet("http://translate.google.com/translate_tts?q=" & $temp, "\" & $File & ".mp3")
    $file1 = "\" & $File & ".mp3"
        SoundPlay($file1, 1)
    Return
EndFunc



While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            $gspeech = "ou!, you poor baby, take 2 aspirins and call me in the morning"
            speech()
        Case $Button2
            $gspeech = "eat some prunes. and try! to relax"
            speech()
        Case $Button3
            $gspeech = "drink a glas of alka selzer and go to bed"
            speech()
        Case $Button4
            $gspeech = "soak your foot in hot water and epson salts"
            speech()
        Case $Button5
            $gspeech = " take your nitroglycerin pill right away, an call 9 1 1"
            speech()
        Case $Button6
            $gspeech = " talk to a friend, then, See a psychiatrist, and get some happy pills"
            speech()
        Case $Button7
            $gspeech = "ou!, you poor baby, take 2 aspirins and contact your family doctor"
            speech()
        Case $Button8
            $gspeech = "Drink ae, tall glass of old grandad, with a twist of lime, and go to bed"
            speech()

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