Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Google Text to Speech TTS


  • Please log in to reply
22 replies to this topic
evandevon
  • Members
  • 88 posts
  • Last active: Oct 15 2014 01:03 PM
  • Joined: 22 Apr 2008
Hi AHKers
Here's something I found today which does great text2speech

<!-- m -->http://translate.goo..._t ... lo world<!-- m -->

It returns you an mp3 with the text transformed into a clear, friendly voice. just change around the last bit to be whatever text you need spoken.

evs
Inventing problems that need solutions...

Open Communicator
MouseTrainer

nimda
  • Members
  • 4368 posts
  • Last active: Aug 09 2015 02:36 AM
  • Joined: 26 Dec 2010
I tink this belongs in the general section - I can't help you with this since there is no problem.

I think the "post helpful tips and tricks" is about common problems, as with the stickys.

TLM
  • Administrators
  • 3864 posts
  • Last active:
  • Joined: 21 Aug 2006
OMG thanks for that.. I was using a 3rd party driver to snag the audio from the site before.
Used it here ( at the start ) ;)
How is that linked to the main translate page?? I dont see save as mp3 anywhere..

Much appreciated!

BTW this would make a very cool AHK project!

Posted Image

don't duplicate, iterate!


aaronbewza
  • Members
  • 466 posts
  • Last active: Feb 05 2013 08:40 AM
  • Joined: 20 Feb 2011
I've integrated your idea into something... I think it would count as help for evandevon's potential problem... how to incorporate said speech function?
This is part of my "Aaron's Super Google Search" script.

First you use FileCreateDir to make a folder in %temp% like:
FileCreateDir, %temp%\foldername ; makes folder in temp folder
Then make an input box:
Gui, Add, Edit,  (size etc...) vInput ; makes search edit box
Then assign it to a control. In my case it's a button:
ButtonSpeech:
Gui, Submit, NoHide ; sends input to variable
FileDelete, %temp%\foldername\*.mp3 ; gets rid of existing speech files
UrlDownloadToFile, http://translate.google.com/translate_tts?tl=en&q=%Input%`., %temp%\foldername\%Input%.mp3
Soundplay, %temp%\foldername\%Input%.mp3, Wait ; plays the downloaded speech file and waits for it to finish
FileDelete, %temp%\foldername\*.mp3 ; deletes sound file and is ready for new one
GoTo Next

It works very nicely in my "Aaron's Super Google Search" :)

flak
  • Members
  • 283 posts
  • Last active: Jan 01 2012 06:20 PM
  • Joined: 02 Oct 2009
Posted Image
Doesn't work for me.

aaronbewza
  • Members
  • 466 posts
  • Last active: Feb 05 2013 08:40 AM
  • Joined: 20 Feb 2011
I don't see HTTP:\\ in front of that address you're showing... try that?
It works for me, I've already built it into a script

shajul
  • Members
  • 571 posts
  • Last active: Aug 01 2015 03:45 PM
  • Joined: 15 Sep 2006

Doesn't work for me.


Strangely, this does not seem to work in Chrome. Works with IE and firefox.
If i've seen further it is by standing on the shoulders of giants

my site | ~shajul | WYSIWYG BBCode Editor

aaronbewza
  • Members
  • 466 posts
  • Last active: Feb 05 2013 08:40 AM
  • Joined: 20 Feb 2011
EDIT: Chrome users MUST type "HTTP://" (without quotes) into the address bar manually, unless you launch the URL from a script.

...and you need to fill in the speech end of the URL with "%20" (without the quotes) in place of spaces, or it can return an error.

TLM
  • Administrators
  • 3864 posts
  • Last active:
  • Joined: 21 Aug 2006
bump

Posted Image

don't duplicate, iterate!


johfor77
  • Members
  • 39 posts
  • Last active: Jan 13 2015 02:04 PM
  • Joined: 18 Mar 2011
I took aaronbewza's example and came up with this.
since I want to save the files and to chose the language I added one droplist.

mabye useful to some.

FileCreateDir, c:\GoogleSpeech ; makes folder in temp folder
Gui, Add, DropDownList, vLang, sv|en
Gui, Add, Edit,  (size etc...) vInput ; makes search edit box
gui, add, button, ,Speech
gui, show
ButtonSpeech:
Gui, Submit, NoHide ; sends input to variable
FileDelete, c:\GoogleSpeech\%Input%.mp3 ; gets rid of existing speech file
UrlDownloadToFile, http://translate.google.com/translate_tts?tl=%Lang%&q=%Input%`., c:\GoogleSpeech\%Input%.mp3
Soundplay, c:\GoogleSpeech\%Input%.mp3, Wait ; plays the downloaded speech file and waits for it to finish
return


aaronbewza
  • Members
  • 466 posts
  • Last active: Feb 05 2013 08:40 AM
  • Joined: 20 Feb 2011
cool stuff! :)
I added IfInString/StringReplace for spaces and question marks so errors are minimized (and a couple more language selections), default choice is first entry:
FileCreateDir, c:\GoogleSpeech ; makes folder in temp folder
Gui, Add, DropDownList, vLang Choose1, sv|en|fr|es|de|fi|el|ja|pl|ru|uk
Gui, Add, Edit,  (size etc...) vInput ; makes search edit box
gui, add, button, Default ,Speech ; ENTER presses this button
gui, show
ButtonSpeech:
Gui, Submit, NoHide ; sends input to variable
 IfInString, Input, %A_Space% ; Looks for spaces in Input variable
  StringReplace, Input, Input, %A_Space%, `%20, All ; Replaces spaces with "%20" (html) to minimize errors from Google Translate
 IfInString, Input, `? ; Looks for question marks in Input variable
  StringReplace, Input, Input, `?, `&`#63, All ; Replaces question marks with "?" (html)
FileDelete, c:\GoogleSpeech\%Input%.mp3 ; gets rid of existing speech file
UrlDownloadToFile, http://translate.google.com/translate_tts?tl=%Lang%&q=%Input%`., c:\GoogleSpeech\%Input%.mp3
Soundplay, c:\GoogleSpeech\%Input%.mp3, Wait ; plays the downloaded speech file and waits for it to finish
return
GuiClose:
ExitApp


johfor77
  • Members
  • 39 posts
  • Last active: Jan 13 2015 02:04 PM
  • Joined: 18 Mar 2011
nice, Minor change since I like to have the Mp3 name without %20 thing.

FileCreateDir, c:\GoogleSpeech ; makes folder in temp folder
Gui, Add, DropDownList, vLang Choose1, en|sv|fr|es
Gui, Add, Edit,  (size etc...) vInput ; makes search edit box
gui, add, button, Default ,Speech ; ENTER presses this button
gui, show
ButtonSpeech:
Gui, Submit, NoHide ; sends input to variable
IfInString, Input, %A_Space% ; Looks for spaces in Input variable
StringReplace, Output, Input, %A_Space%, `%20, All ; Replaces spaces with "%20" to minimize errors from Google Translate
FileDelete, c:\GoogleSpeech\%Input%.mp3 ; gets rid of existing speech file
UrlDownloadToFile, http://translate.google.com/translate_tts?tl=%Lang%&q=%Output%`., c:\GoogleSpeech\%Input%.mp3
Soundplay, c:\GoogleSpeech\%Input%.mp3, Wait ; plays the downloaded speech file and waits for it to finish
return
GuiClose:
ExitApp

Edit: Geting some strange result when using swedish "åäö", I will look in to that later.

aaronbewza
  • Members
  • 466 posts
  • Last active: Feb 05 2013 08:40 AM
  • Joined: 20 Feb 2011
for å it is

`&`#229;
(escape the first two characters)

Check this out:

<!-- m -->http://www.ascii.cl/htmlcodes.htm<!-- m --> <-- EDIT: WRONG ONES!

The page has HTML code for every character you are looking for, and considering your Input goes into a URL http address line, it would probably be a good idea to substitute the proper HTML code for all special characters.
Someone might want to find or build a "Character to HTML Converter" script?

I made a mistake on the HTML for the Question Mark... it should be
`&`#63;
not
`&`#63

sorry about that! (remember to escape the weird characters if need be)

EDIT: after much experimentation, these codes simply do not work. :(

sumon
  • Moderators
  • 1317 posts
  • Last active: Dec 05 2016 10:14 PM
  • Joined: 18 May 2010

for å it is

`&`#229;
(escape the first two characters)

Check this out:

http://www.ascii.cl/htmlcodes.htm

The page has HTML code for every character you are looking for, and considering your Input goes into a URL http address line, it would probably be a good idea to substitute the proper HTML code for all special characters.
Someone might want to find or build a "Character to HTML Converter" script?

I made a mistake on the HTML for the Question Mark... it should be
`&`#63;
not
`&`#63

sorry about that! (remember to escape the weird characters if need be)


Yeah I've also been looking for something like that :(

aaronbewza
  • Members
  • 466 posts
  • Last active: Feb 05 2013 08:40 AM
  • Joined: 20 Feb 2011
I think a subroutine on this script could do the HTML conversion on characters from different languages?
I'm going to start one.

EDIT: it looks like the HTML codes I mentioned do not actually work :(

Below in the code box is the actual table of codes to use in URL addresses (without percent signs) :
ASCII Character 	URL-encoding
space 	%20
! 	%21
" 	%22
# 	%23
$ 	%24
& 	%26
' 	%27
( 	%28
) 	%29
* 	%2A
+ 	%2B
, 	%2C
- 	%2D
. 	%2E
/ 	%2F
0 	%30
1 	%31
2 	%32
3 	%33
4 	%34
5 	%35
6 	%36
7 	%37
8 	%38
9 	%39
: 	%3A
; 	%3B
< 	%3C
= 	%3D
> 	%3E
? 	%3F
@ 	%40
A 	%41
B 	%42
C 	%43
D 	%44
E 	%45
F 	%46
G 	%47
H 	%48
I 	%49
J 	%4A
K 	%4B
L 	%4C
M 	%4D
N 	%4E
O 	%4F
P 	%50
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