Sign in to follow this  
Followers 0
QuimiQ

TTS script using google Translator

1 post in this topic

Hey Guys

For a Project of mine I want the nice lady from google translator to read out short text passages for me (just a few words). For a previous project I used this UDF. Now google has changed some things and it's not working anymore. So I googled for a solution and got it sort of running again. The problem I have though is, it only works when I run it the first time. After that it is just mute. When I type in the link manually however it still works. Can anyone help me?

Func _Say($parText,$parLanguage)
        $UDF_SPEAK_baseurl = "https://translate.google.com/translate_tts?ie=UTF-8&q="&_INetExplorerCapable($parText)&"&tl="&$parLanguage&"-TW&client=tw-obt"
        ConsoleWrite($UDF_SPEAK_baseurl&@CRLF&@ScriptDir&"\test.mp3"&@CRLF)
        $UDF_SPEAK_filename = "txt2spch.mp3"
        FileDelete( @TempDir & "\" & $UDF_SPEAK_filename)
        InetGet( $UDF_SPEAK_baseurl, @TempDir & "\" & $UDF_SPEAK_filename, 1 )
        If @error Then
            SoundPlay("something") ;tmp replace "something" with error sound
        Else
            $UDF_SPEAK_file = @TempDir & "\" & $UDF_SPEAK_filename
            $UDF_SPEAK_sound = _SoundOpen( $UDF_SPEAK_file )
            _SoundPlay($UDF_SPEAK_sound, 1)
            _SoundClose($UDF_SPEAK_sound)
        EndIf
    EndFunc

 

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