Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Code Snippets / [DBP] - Text to Speech Function Using Google Translate

Author
Message
Emir Starshyne
9
Years of Service
User Offline
Joined: 4th Oct 2014
Location: Brazil
Posted: 4th Oct 2014 16:52
This function I made from a snippet from another user who made a chatbot that could speak its messages using Google Translator.
What I did was only getting the TTS part and turn it into a function ready to be used in any program as you wish.
No credits for me, if you want to credit someone credit the guy who made the original, whose name I don't know (the snippet is somewhere at this forums).


do
input string$
tts(string$)
loop


function tts(string$)
translateurl$="http://translate.google.com/translate_tts?ie=utf-8&tl=en&q=" + string$


filenumber$="tts.mp3"
if file exist(filenumber$) then delete file filenumber$

load dll "urlmon",1
a=CALL DLL(1,"URLDownloadToFileA",0,translateurl$,filenumber$,0,0)

delete dll 1

if file exist("tts.mp3")=1
LOAD music "tts.mp3",1

play music 1

While music playing(1)=1
endwhile

delete music 1
endif
endfunction

<b><i>The mind is the compiler of dreams.</i></b>

Login to post a reply

Server time is: 2024-04-23 09:18:56
Your offset time is: 2024-04-23 09:18:56