Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Download MP3 from Google Translate text to speech

Tags:

I found this code from the Internet and it uses the Google translate's text to speech capability using URL. here is the code:

http://translate.google.com/translate_tts?tl=en&q="hello world" 

I know how to call this in my vb.net but I don't know how to save the MP3 file from Google Translate. i used the system.speech in vb.net to have this capability but I specifically need to get the speech from google translate. so, does anyone know how to save the sound file from Google Translate using that URL? Thanks.

like image 492
user1169690 Avatar asked Feb 06 '12 17:02

user1169690


People also ask

Is there a way to translate an audio recording?

VEED's powerful audio translator can automatically detect any language in your audio files (mp3, wav, m4a, etc.) and transcribe it to text in a single click! Simply upload your file, head to 'Subtitles' and transcribe your audio into text in no time. Feel free to edit and reword the transcription when it's ready.


2 Answers

EDIT 2015-12-26

As of 2015-12-21 this code no longer works following further changes to the Google TTS API. As indicated by @ncpierson a new additional parameter tk is required, and I am having a hard time working out how to calculate it in a shell script. I will revise this answer with a new edit as/when I can.

I'm not sure about Windows, but in Linux this is very easy from the command line. I use a command line script to download English audio of text strings:

#!/bin/bash # write an English text string as an audio file using Google Translate # usage: en2audio.sh <text> wget -q -U Mozilla -O "$*.mp3" "http://translate.google.com/translate_tts?ie=UTF-8&client=t&tl=en&q=$*" 

I do the same thing with Chinese (the script is a bit simpler because there are no spaces to parse between words):

#!/bin/bash # write a Chinese text string as an audio file using Google Translate # usage: zh2audio.sh <text> wget -q -U Mozilla -O $1.mp3 "http://translate.google.com/translate_tts?ie=UTF-8&client=t&tl=zh&q=$1" 

Most Linux distros include wget as standard, but it can easily be downloaded (see, e.g, this link).

(Thanks to @ncpierson for client=t parameter).

like image 98
Bobble Avatar answered Sep 18 '22 16:09

Bobble


The script that the google translate page ran, when I used your example, produced a file called "translate_tts" with no file extension.

One easy way to use this file is to tell your browser, e.g. Mozilla [under the "TOOLS"/ "OPTIONS"/APPLICATIONS], to save audio files - in this case I believe it is an MP3, even though there is no extension. In any case, select the option under "ACTION" next to audio/wave or audio/Mpg to "SAVE FILE".

When the browser loads your URL, it downloads the file called "translate_tts", no matter what the data is. So, in your case I would change the file name to "Hello-World.mp3". That way you now have the file on your hard drive, containing the audio you want, which can be played by any audio player, preferably VLC media player since it will play almost any format.

Of course if you want a different audio , e.g. "Goodbye-World", you just change your URL to

http://translate.google.com/translate_tts?tl=en&q="Goodbye-World"

and repeat the above steps to save the file as "Goodbye-World.mp3".

like image 24
JCCbama Avatar answered Sep 16 '22 16:09

JCCbama