djfountain
Posts: 3
Joined: Sun Mar 17, 2013 7:00 pm

Text to speech script (Unlimited length, google)

Sun Mar 17, 2013 7:24 pm

Hey everyone.
I found a couple of helpful scripts for text to speech.
My favourite was via google... they process it on their servers, and send you the mp3.
However, the length is limited to 100 characters.

I created this shell script to take a string of any length, divide it up per word, make strings of less than 100 characters, then play them all automatically.

Hopefully someone finds this useful
(requires program mpg123... feel free to replace this line in the script with something else that takes a URL input)

I put the script on my site, so I can edit it all in one place,
Get is here:
http://danfountain.com/2013/03/raspberr ... to-speech/

Usage:
save as a shell script, eg: Speech.sh
set permissions:

Code: Select all

sudo chmod -x Speech.sh
pass any text like this:

Code: Select all

./Speech.sh What is this great task for which I, Deep Thought, the second greatest computer in the Universe of Time and Space have been called into existence?
(Speech marks "" are optional, but can help if it gets confused with strange punctuation.)


Let me know if you do anything nice with it.
Enjoy,
Dan

RonHackett
Posts: 1
Joined: Sun May 05, 2013 5:02 pm

Re: Text to speech script (Unlimited length, google)

Sun May 05, 2013 5:08 pm

Hi Dan,

Thanks for the great script - the google voice is really great!

I've been trying to searching to find a way to access the script from a python program, but no luck.
Do you have any suggestions as to how that might be done?

djfountain
Posts: 3
Joined: Sun Mar 17, 2013 7:00 pm

Re: Text to speech script (Unlimited length, google)

Mon May 06, 2013 11:30 am

Thanks for the reply - glad its being put to good use.

Sorry, I dont know much about python.
It cant be too tricky - its just a normal shell script
google it?

forenbenutzer
Posts: 148
Joined: Thu Aug 02, 2012 7:08 pm

Re: Text to speech script (Unlimited length, google)

Fri Jun 07, 2013 1:45 pm

I already did something similar which does not require working internet/google.

(German) http://edv-huber.com/index.php/probleml ... -isdnmodem

It uses txt2pho, mbrola and sox. I am not sure if it's available in the raspberry's repositories, but it should be able to be compiled from source.

This is how it works:

1. conversion of text string to a phoneme intermediary format with txt2pho
2. conversion of intermediary format to wav file with mbrola
3. conversion of wav to something else with sox (for example ulaw to play in a voip answering application)

I think that festival is a better solution for cases where english TTS is needed.
Pitendo - Case And Emulator Project - http://edv-huber.com/index.php/problemloesungen/12-pitendo

redanb
Posts: 12
Joined: Mon Jan 04, 2016 11:42 am

Re: Text to speech script (Unlimited length, google)

Mon Jan 04, 2016 3:05 pm

Can someone post the script by dan fountain.The link: http://danfountain.com/2013/03/raspberr ... to-speech/ is not accessible now. I have been trying a lot to make google text to speech work but geting errors like 503 .I am using file speech.sh:

Code: Select all

#!/bin/bash
say() { local IFS=+;/usr/bin/mplayer -ao alsa -really-quiet -noconsolecontrols "http://translate.google.com/translate_tts?tl=en&q=$*"; }
say $*
and when i execute it: ./speech.sh Look Dave, I can see you're really upset about this.
i get this :
pi@raspberrypi ~ $ ./speech.sh Look Dave, I can see you're really upset about this.
>
no output or sound just an arrow in next line.I am using raspberry pi through ssh.Please help me out.

User avatar
DougieLawson
Posts: 38883
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Text to speech script (Unlimited length, google)

Mon Jan 04, 2016 3:10 pm

You've got a lone apostrophe in there.
Look Dave, I can see you're really upset about this.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

redanb
Posts: 12
Joined: Mon Jan 04, 2016 11:42 am

Re: Text to speech script (Unlimited length, google)

Mon Jan 04, 2016 4:39 pm

Now , it is showing no error but still no sound through earphones and it simply moves for the next command showing no message or error

User avatar
DougieLawson
Posts: 38883
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Text to speech script (Unlimited length, google)

Mon Jan 04, 2016 4:47 pm

Have you configured the system for analog audio?
sudo amixer cset numid=3 1

And have you set the volume above zero?
sudo alsamixer
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

redanb
Posts: 12
Joined: Mon Jan 04, 2016 11:42 am

Re: Text to speech script (Unlimited length, google)

Mon Jan 04, 2016 6:48 pm

Yes, I set the audio to analog for headphone audio jack but dont know about the volume. I will try to increase the value and post results in 12 hours.But dont you think if it executed properly,it should be displaying some messages like decoding of mp3 /finished status,etc.
Thanks a lot for your help sir.

User avatar
DougieLawson
Posts: 38883
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Text to speech script (Unlimited length, google)

Mon Jan 04, 2016 7:33 pm

You've told it to not announce anything with the -really-quiet parm.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

User avatar
scruss
Posts: 3155
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON
Contact: Website

Re: Text to speech script (Unlimited length, google)

Mon Jan 04, 2016 7:37 pm

Wayback machine copy of the script: Raspberry Pi – Text to Speech | Dan Fountain

I'm not sure if Google Speech still works the same way, as any script that I try gives me 503 errors.

If you need TTS, flite or festival run well on a Raspberry Pi. If you want to be really nerdy and get your Stephen Hawking voice on, you could attach an Emic 2. This is a DECTalk module running from a couple of small chips. I've just got one (for $US 59; real 1980s serial DECTalk units go for several thousand, alas) and may play with it on a Raspberry Pi.
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.
Pronouns: he/him

User avatar
DougieLawson
Posts: 38883
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Text to speech script (Unlimited length, google)

Mon Jan 04, 2016 8:12 pm

That http://translate.google.com/translate_tts URL is now blocked. Try it from a browser and it gives you a CAPTCHA to confirm you're human (I failed that test).
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

redanb
Posts: 12
Joined: Mon Jan 04, 2016 11:42 am

Re: Text to speech script (Unlimited length, google)

Tue Jan 05, 2016 3:37 am

Yup i deleted really quite parameter and output is:

Code: Select all

pi@raspberrypi ~ $ ./speech.sh hello everyone good morning
MPlayer svn r34540 (Raspbian), built with gcc-4.6 (C) 2000-2012 MPlayer Team

Playing http://translate.google.com/translate_tts?tl=en&q=hello+everyone+good+morning.
Resolving translate.google.com for AF_INET...
Connecting to server translate.google.com[173.194.36.67]: 80...
Resolving ipv4.google.com for AF_INET...
Connecting to server ipv4.google.com[173.194.36.70]: 80...

Server returned 503: Service Unavailable
STREAM_ASF, URL: http://translate.google.com/translate_tts?tl=en&q=hello+everyone+good+morning
Resolving translate.google.com for AF_INET...
Connecting to server translate.google.com[173.194.36.67]: 80...

Server returned 302:Found
Failed to parse header.
Failed, exiting.
Resolving translate.google.com for AF_INET...
Connecting to server translate.google.com[173.194.36.67]: 80...
Resolving ipv4.google.com for AF_INET...
Connecting to server ipv4.google.com[173.194.36.70]: 80...

Server returned 503: Service Unavailable
No stream found to handle url http://translate.google.com/translate_tts?tl=en&q=hello+everyone+good+morning


Exiting... (End of file)
I think they have taken measures to block such kind of activity.If anything further is possible to make it work,please guide me.I tried festival but the sound felt a little robotic,I want a soothing voice. I will aslo try pico tts.
Thanks again.

User avatar
scruss
Posts: 3155
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON
Contact: Website

Re: Text to speech script (Unlimited length, google)

Thu Jan 07, 2016 1:14 am

redanb wrote:I tried festival but the sound felt a little robotic
Festival has lots of different voices, so you might find one you like.
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.
Pronouns: he/him

hippy
Posts: 7459
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Text to speech script (Unlimited length, google)

Thu Jan 07, 2016 3:56 pm

redanb wrote:I think they have taken measures to block such kind of activity.If anything further is possible to make it work,please guide me.
https://gist.github.com/ncpierson/eeea9956cb2bc3b290e5

Haven't tested that, don't know if it does work or have any idea how long it will work for before Google put a block on that. I expect they will if it becomes over used.

User avatar
scruss
Posts: 3155
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON
Contact: Website

Re: Text to speech script (Unlimited length, google)

Sun Jan 10, 2016 6:05 pm

There's also Voice RSS, which has a free API for up to 350 requests a day.
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.
Pronouns: he/him

User avatar
DougieLawson
Posts: 38883
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Text to speech script (Unlimited length, google)

Sun Jan 10, 2016 6:29 pm

scruss wrote:There's also Voice RSS, which has a free API for up to 350 requests a day.
At 350 requests per 24 hours then in a week you've got 2450 requests. So if you use your 350/day to convert 350 single words to 350 wav files then in a week you've got the first stage of a usable dictionary, in a month you've got over 10,000 words encoded to 10000 wav files. All for free and all within their rules for API calls. It'll cost you some 1s & 0s on a SDCard or hard drive somewhere.

I've not looked at how they might stop you feeding it a dictionary and cheating that way.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

hippy
Posts: 7459
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Text to speech script (Unlimited length, google)

Sun Jan 10, 2016 7:40 pm

DougieLawson wrote:
scruss wrote:There's also Voice RSS, which has a free API for up to 350 requests a day.
At 350 requests per 24 hours then in a week you've got 2450 requests. So if you use your 350/day to convert 350 single words to 350 wav files then in a week you've got the first stage of a usable dictionary, in a month you've got over 10,000 words encoded to 10000 wav files. All for free and all within their rules for API calls. It'll cost you some 1s & 0s on a SDCard or hard drive somewhere.

I've not looked at how they might stop you feeding it a dictionary and cheating that way.
The English and American dictionaries I have acquired over the years each have about 50,000 words in them but a usable set for a specific application will often be a lot smaller. Synthesising 50,000 words at 350 a day would take about 5 months done individually but it should be possible to send sentences and then automatically split the WAV file.

Not sure it would be morally right or even legal. I would imagine that if they saw it happening they would be inclined to add lower limits and/or take steps so only registered users could usefully use the service.

It would be nice if someone could make a comprehensive set of WAV files of words for free and unrestricted use but I would prefer those who have developed the technology doing that rather than others just using their technology. Of course per-word synthesis still only gets you so far.

The actual service delivered quite good speech when I tried it out, was very easy to access via Python, and presumably in any other language which can download an octet stream from a web server URL.

User avatar
DougieLawson
Posts: 38883
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Text to speech script (Unlimited length, google)

Sun Jan 10, 2016 9:09 pm

hippy wrote: The English and American dictionaries I have acquired over the years each have about 50,000 words in them but a usable set for a specific application will often be a lot smaller. Synthesising 50,000 words at 350 a day would take about 5 months done individually but it should be possible to send sentences and then automatically split the WAV file.
If you use the full 50,000 words you should be an "Octochamp" on Countdown with the appropriate pieces of Nick Hewer's "Kryptonite" trophies tucked away on your mantelshelf. Most folks don't use anywhere near the whole collection of words in their dictionary. I know I don't because I keep learning things from Susie Dent's "Origins of Words" segment on Countdown.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

hippy
Posts: 7459
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Text to speech script (Unlimited length, google)

Sun Jan 10, 2016 9:59 pm

It appears I'm pretty average on vocabulary, just shy of 30,000 according to a 'fun for a Sunday' random web site test. I would have thought lower ... http://testyourvocab.com

Minimal foreign language skills as well but I can remember one word of Esperanto; mano = hand :P

User avatar
DougieLawson
Posts: 38883
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Text to speech script (Unlimited length, google)

Sun Jan 10, 2016 10:32 pm

It had some extraordinary words, but gave me a score of 32,700.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

User avatar
scruss
Posts: 3155
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON
Contact: Website

Re: Text to speech script (Unlimited length, google)

Mon Jan 11, 2016 3:01 am

DougieLawson wrote:
scruss wrote:There's also Voice RSS, which has a free API for up to 350 requests a day.
At 350 requests per 24 hours then in a week you've got 2450 requests. So if you use your 350/day to convert 350 single words to 350 wav files then in a week you've got the first stage of a usable dictionary
It's only as good as the pronouncing dictionary it's based on. Some of those are quite short. Some of them have restrictions (like the computer-usable version of the Oxford Advanced Learning Dictionary; generate words from that, and you've made a derived work copyright OUP). How would you mark/store heteronyms, words that are spelled the same, but pronounced differently? For example, lead can be a verb, a synonym for "to guide", and is pronounced /liːd/; or it can be a noun, a metal, pronounced /lɛd/.

I suspect a Festival installation, with a good voice installed and a large dictionary, would be smaller and quicker than trying to bend the licence of VoiceRSS.

You could probably use Wiktionary as a source, too.

That vocab test was fun. Wonder what my old colleagues at Collins Dictionaries (now scattered to the winds of Oxford, Chambers, Larousse, and all) would make of it?

cheers,
Stewart
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.
Pronouns: he/him

redanb
Posts: 12
Joined: Mon Jan 04, 2016 11:42 am

Re: Text to speech script (Unlimited length, google)

Wed Jan 13, 2016 10:06 am

scruss wrote:
There's also Voice RSS, which has a free API for up to 350 requests a day.
I tried voicerss but i think the voice was fair but not good , i tried 3-4 weeks ago. I will try again.

I am also trying to run marytts . I am following below links:
https://github.com/marytts/marytts/wiki ... stallation
https://github.com/marytts/marytts-installer
https://github.com/marytts/marytts/wiki/MaryInterface

When i try to run marytts as http server ,using sudo -u mary /local/mary/marytts/target/marytts-5.1-beta2/bin/marytts-server.sh,
the service starts but i am not able to figure out how to convert text to speech or use it.

when i use curl :

Code: Select all

curl http://localhost:59125/process?INPUT_TYPE=TEXT&AUDIO=WAVE_FILE&OUTPUT_TYPE=AUDIO&LOCALE=DE&INPUT_TEXT=%22Hallo%20Josef!%22 | aplay
Error is :curl (7) couldn't connect to host
aplay: playback:2483: read error

User avatar
scruss
Posts: 3155
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON
Contact: Website

Re: Text to speech script (Unlimited length, google)

Thu Jan 14, 2016 1:58 pm

redanb wrote: I tried voicerss but i think the voice was fair but not good
I think you might have to pay for a commercial TTS, then. They have some very nice voices. You pay for them because it's a huge amount of work to develop a new voice. Most of the free ones are academic test-beds for various vocal modelling techniques, so the voices they come with have limitations. Cepstral has Callie for Raspberry Pi (demonstration). I think it's $30. There are some older threads on running it: Cepstral (or Alternative)?

There are also some alternatives (oldish) for running free TTS here: RPi Text to Speech
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.
Pronouns: he/him

redanb
Posts: 12
Joined: Mon Jan 04, 2016 11:42 am

Re: Text to speech script (Unlimited length, google)

Fri Jan 15, 2016 10:12 am

I checked the cepstral website and found that some voices are available for download for linux/windows etc. for personal use .Is it possible to make them work on pi by changing the pi os to ubuntu mate or snappy ubuntu core or some other os?
May be i can buy voices later but its difficult now.
Thanks for the help.

Return to “Graphics, sound and multimedia”