Jump to content
Sign in to follow this  

Speech UDF

Recommended Posts

hi guys, check out this little udf. it's not much, but at least it's not just sapi.

;speech udf

;uses either sapi or google speech.


;name: _SpeechGet

;description: generates speech and outputs it to the speakers.

;usage: _SpeechGet($Text, $Engine)

;$Text = the text to speak.

;$Engine = the speech engine to use, 0 = microsoft speech API 5x, 1 = Google translation API. 0 is default.

;returns 0 if no errors, 1 for errors.

Func _SpeechGet($Text, $Mode = "0")

if $Text = "" then Return 1

if $Mode > 1 or $Mode < 0 then Return 1

if $Mode = "0" then

;create speech object

Local $Voice = ObjCreate("Sapi.SpVoice")

if not IsObj($Voice) then Return 1


if $Mode = "0" then

;speak the text


Return 0


;use the google translation api to get the speech

InetGet("http://translate.google.com/translate_tts?q=" & $Text, @TempDir & "\tempspeech.mp3", 1)

;play the downloaded speech

SoundPlay(@TempDir & "\tempspeech.mp3", 1)

;delete the temporary file

FileDelete(@TempDir & "\tempspeech.mp3")

Return 0



let me know if you enjoy it, or if you know of any other web based speech services i could add support for.

Please note: If you plan on submitting any code snippits to my posts, please refrain from using the code tags as i use a screen reader and can't read the code properly, let alone copy it the way it should be.Thanks for your understanding.Best regardsXY16

Share this post

Link to post
Share on other sites

kid1232 please do not resurrect old threads, especially when not adding anything benefiicial. If you had bothered to look you would see that the OP has not been active on the forum in two years.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...