SimpleSpeak text-to-speech - new filter

SimpleSpeak text-to-speech - new filter

by Nick Freear -
Number of replies: 36

I've been developing a new filter to add speech synthesis to Moodle, particularly for scenarios like an alphabet quiz for children.

Syntax

  1. Simple: [Speak] Hello world [/Speak]
  2. Quiz:
    [Speak]
    ;; Just a comment.
    letter = A
    sound  = ah
    image  = "ht++tp://upload.wikimedia.org/wikipedia/commons/thumb/f/fb/Red_Delicious.jpg/240px-Red_Delicious.jpg"
    alt    = "A red delicious apple, on WikiMedia Commons"
    word   = apple
    phrase = Which of the words below start with the letter [em]a[/em]?
    [/Speak]

Feedback welcome! Thanks,

Nick

Average of ratings: -
In reply to Nick Freear

Re: SimpleSpeak text-to-speech - new filter

by Frankie Kam -
Picture of Plugin developers

Hi Nick

Thank you for an GREAT filter. WIth TTS technology getting better each year, your filter has opened up endless potential in teaching and learning English on Moodle!

I ALSO like your [speak][/speak] syntax where you have abstracted the coding for the non-programmer.

I immediately downloaded you zip file and with further reading of your README file, I spent the next 20 minutes poking around the sites TTS of espeak, google translate and festival for Linux.

Now if I could only get a free TTS service installed on my Centos VPS and link the API or whatever to my to-installed-in-the-future TTS service as in:

$CFG->simplespeak_service_url =
'http://example.org/cgi-bin/espeak/getsound.pl?lang=!LANG&text=!TEXT';

that would be FANTASTIC.

At the moment all I have is this link to install a TTS service named festival (Linux system). This is the link I am using (even as I type) to install festival on my Centos VPS system:
http://www.xenocafe.com/tutorials/php/festival_text_to_speech/index.php

.....downloading lotsa stuff.....I'll let you know how it goes. mixed

Frankie Kam
Melaka, Malaysia

In reply to Frankie Kam

Re: SimpleSpeak text-to-speech - new filter

by Frankie Kam -
Picture of Plugin developers

My going down a 1.5 hour RABBIT HOLE

Ever the eager-beaver, I immediately downloaded your zip file and with further reading of your README file, I spent the next 20 minutes poking around the sites TTS of espeak, google translate and festival for Linux.

Now if I could only get a free TTS service installed on my Centos VPS and link the API or whatever to my to-installed-in-the-future TTS service as in:

$CFG->simplespeak_service_url =
'http://example.org/cgi-bin/espeak/getsound.pl?lang=!LANG&text=!TEXT';

that would be FANTASTIC.

At the moment all I have is this link to install a TTS service named festival (Linux system). This is the link I am using (even as I type) to install festival on my Centos VPS system:
http://www.xenocafe.com/tutorials/php/festival_text_to_speech/index.php

.....downloading lotsa stuff.....I'll let you know how it goes. mixed

(20 minutes later)

OKAYY! I managed to install Festival on my Centos. AND with this command I am able to create a WAV file on my server:

At the Linux command promt, I used this command to create the WAV file:
echo "It's such a beautiful day!" |  text2wave -scale 50 -o beautiful_day.wave

which I can download and play from this link (it works, give it a try!):

Quite a robotic bloke isn't he?

This link below shows me how to install BETTER voices compared to the festival's "default robotic voice":-
http://info.solomonson.com/content/linux-text-speech

Another interesting link: http://www.ghacks.net/2010/10/09/linux-text-to-speech-with-festival/

So in conclusion,
1. I got festival's TTS robotic voice installed on my Centos server;
2. I can get festival to create a WAV file (I bet I can find out how to use LAME to convert WAV to MP3 - resulting in 10x smaller sound MP3 files)
3. How to link festival to your SimpleSpeak TTS filter, I simply do NOT KNOW.
4. I am STUCK. Need a Linux/Centos/pHP  guru to sort this one out.
5. DEAD-END.

I'm gonna have to leave this on the to-do-list. Till next time, bye!
Frankie Kam
Melaka, Malaysia

Average of ratings: Useful (1)
In reply to Frankie Kam

Re: SimpleSpeak text-to-speech - new filter

by Nick Freear -

Hi Frankie,

Thanks for downloading and having a go. And apologies for the gaps in documentation. I hope you'll find some answers here.

Below I've started documenting how I got this working with eSpeak and LAME on my Mac for the DIY'ers.

3rd party services

There are a number of TTS services emerging on the Web. These can get you started quickly. I've been wary of saying too much, because in many cases I'm unclear on their terms of use. Please check with the service before proceeding. (And I accept no responsibility for your use of the services.)

Note, SimpleSpeak caches the audio from the TTS service, but please respect any usage limits.

DIY - eSpeak

Here are some steps to install and configure eSpeak and LAME:

  1. Install eSpeak, for example, Mac installer, from Curtin University of Tech.
  2. Install LAME, eg.
      $ sudo port install lame
  3. Download a CGI bridging script, eg. my Gist, based on WebAnywhere, or from the WebAnywhere project on Google Code (includes Festival script) - Perl, hmm!
  4. Make CGI script executable, eg.
      cgi-bin/espeak$ chmod +x getsound.pl
  5. Configure binary, log and cache paths in the CGI script.
  6. Test! For example,
      http://example.org/cgi-bin/espeak/getsound.pl?lang=en|f1&text=Hello+world 
    ('f1' is a eSpeak female speaker.)
  7. Consider setting up an alias in Apache, eg.
      ScriptAlias /espeak_tts /var/www/cgi-bin/espeak/getsound.pl
  8. Consider installing alternative voices, eg. mbrola (242 MB!)
  9. In Moodle, go to Site Administration | Plugins | Filters | SimpleSpeak. Enter the URL in the settings form, using the placeholders !TEXT and optionally !LANG, eg.
      http://example.org/espeak_tts?lang=!LANG%2Bf1&text=!TEXT 
  10. Experiment!

I hope this helps, and you can adapt to Festival. Please let us know how you get on. Best wishes,

Nick

In reply to Nick Freear

Re: SimpleSpeak text-to-speech - new filter

by Frankie Kam -
Picture of Plugin developers

Hi Nick

Thanks for the quick reply. And thanks for the extra information.

Well, as a former C, C++, Java programmer, I'm still boggled by the amount of subproblems to I'll have to experiment-try-fail-experiment-again in order to get the TTS working.

I'm sure to take up the challenge once I SUBMIT MY DISSERTATION ON MONDAY. Heh, I took a slight diversion this morning to attempt installing festival because I SO WANTED TO USE your filter. Anyway, they say "good things come to those who wait". So, I'll bide my time and when I've rechared, I'll charge right back in and try out your steps.

From the look of things (I'm new to this Linuxy stuff), it's more like "Who DARES WINS" when it comes to server side programming, coding and script stuff.

But I'm sure I can do it. I know because I managed to install Munin Graphs, eAccelerator and mod_deflate on my Apache, Centos setup. I took me days, no - weeks, and hours of pecking away at the keyboard one step at a time. Hours it took me to read all those Googled how to sites and blogs. Also managed to get Ghostscript installed on my Centos.

And to think that 6 months ago I had never ever run a script in a Linux command prompt. Anyway I still backup my system before doing anything I consider as "high risk" to my beloved VPS.

So anyway, keep up the good work on the filter, maybe one day you can write a PHP & Linux for Dummies book for the rest of us.

Thanks for reading my ramblings. After my Masters is done, I intend to take up Php and MySQL seriously (reading books first). So that I can one day write Moodle mods and code and be a developer rather than just a power user.

Frankie Kam

In reply to Nick Freear

Re: SimpleSpeak text-to-speech - new filter

by Frankie Kam -
Picture of Plugin developers

Hi Nick. I've got Festival 1.9.5 installed on my site. You can test it out it out here: http://scm.moodleace.com/tts.php

Now, if I could
(a) connect SimpleSpeak plugin to Festival
AND
(b) change the Festival voice to a better sounding voice
THEN I would have had it made.

Problem is (a). Any pointers?

I've attached the tts.php file for your reference.

Frankie
P.S., I had a look at eSpeak's installation instructions at the eSpeak website and then beat a hasty retreat when I couldn't find anything on the Web that could help me install eSpeak on CentOS. Maybe later.

In reply to Nick Freear

Re: SimpleSpeak text-to-speech - new filter

by Nicholas Walker -

Hello Nick,

I love the filter and have successfully installed it with Festival (with help--and Frankie's posts were very helpful). It works, but not as well as I would like it to work in the context of a Glossary with pictures. It seems to filter the first entry with a picture on the page, but entries lower on the list are less reliably filtered. That being said, when I display a random glossary entry on a course page the filter works every time.

Entries in the glossary without pictures (using either the "image =" method or the image insertion button on the HTML editor) seem to work as long as they are shown ahead of a picture. Below, it is not so reliable. I am using Moodle 1.9.12+. The server is pretty powerful: CORE2 Duo E7500 2.93GHz, 2GB RAM with CentOS.

I should note that I prefer to use [speak] phrase = yacht [/speak] rather than [speak] word = yacht [/speak] for simplicity sake. I doubt this is the issue. Also, I get the same result with IE, Firefox and Chrome.

Has anyone else had this problem? Is there a way to improve the reliability of the filter with a server tweak?

Nick Walker

Screen shot of TTS filter in IE

In reply to Nicholas Walker

Re: SimpleSpeak text-to-speech - new filter

by Nicholas Walker -

P.S. I have found a workaround for summer courses. Since my post above, I have switched the glossary from "simple, dictionary style" to "entry list". Now, each entry gets its own pop-up window.

Average of ratings: Useful (1)
In reply to Nicholas Walker

Re: SimpleSpeak text-to-speech - new filter

by Frankie Kam -
Picture of Plugin developers

Hi Nicholas.

How did you manage to link Festival to SimpleSpeak?

In reply to Frankie Kam

Re: SimpleSpeak text-to-speech - new filter

by Nicholas Walker -

Hi Frankie,

I asked my provider to install the speech server using the link you provided: http://www.xenocafe.com/tutorials/php/festival_text_to_speech/index.php The rest is a mystery. He reports that he was able to get this link working: "http://www.example.com/cgi-bin/espeak/getsound.pl?lang=en&text=Hello+world"

Perhaps you can help me with a question I have. Do you know how to change the voice? The default has an English accent. It must be the Festival standard voice. I teach English in Montreal and would prefer a Standard American accent.

Nick

In reply to Nicholas Walker

Re: SimpleSpeak text-to-speech - new filter

by Frankie Kam -
Picture of Plugin developers

Dear Nicholas

I'm not sure what OS you're using (Linux I presume). On my CentOS system, there is a file named siteinit.scm that is located in the /usr/share/festival folder in my server. Your server's festival folder may differ from mine.

Anyway, inside that siteinit.scm file is an interesting code that looks like this:

;; If you want a voice different from the system installed default
;; uncomment the following line and change the name to the voice you
;; want

;(set! voice_default 'voice_ked_diphone)

Remove that read semicolon at the front of the line, and replace the pink voice name with the voice name of your choice. Hope this is clear enough for you and your provider, and hope you can get that Standard American accent working! tongueout

P.S., it took me roughly 4 hours(!) of solidly tackling this festival/tts/espeak/SimpleSpeak feature to find this out. So hope it helps you.

In reply to Nick Freear

Re: SimpleSpeak text-to-speech - new filter

by Andy Petroski -

Has anyone got this working with one of the free TTS services?  Do you only need the API URL or is there something else that's needed?

I've entered "https://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q=!TEXT&langpair=%7Ces" in the Text to Speech service URL, but it's not working.  There is no "speech" when I click the button that's created by <speak>Apple</speak>

In reply to Andy Petroski

Re: SimpleSpeak text-to-speech - new filter

by Nicholas Walker -

Hello Andy,

I have been using Festival installed on my own dedicated server, but your post prompted me to try the Google TTS. I was able to get it to work using the following URL:

http://translate.google.com/translate_tts?tl=en&q=!TEXT

I noticed that you reported using these < > rather than these [  ] to enclose your speak tags. Please, try the sqaure brackets and the URL above, and let us know if you get SimpleSpeak to work for you.

Best wishes,

Nick

Average of ratings: Useful (1)
In reply to Nicholas Walker

Re: SimpleSpeak text-to-speech - new filter

by Andy Petroski -

That URL didn't work either.  And, I mistyped my original entry.  I was using the brackets [ ]. 

Is there something else that needs to be installed or another setting that needs turned "on?"

The TTS button renders.  When I click the button the browser processes "something."  I see the progress bar at the bottom of the browser activated and completed.

My audio is not muted.  I'm useing IE 8.

Thanks for any additional help.

In reply to Nick Freear

回复: SimpleSpeak text-to-speech - new filter

by yun gao -

really appreciate your work! but i wonder how to deploy  this filter on windows IIS, I tried but faild,would you pls to give me some advice?

In reply to yun gao

Re: 回复: SimpleSpeak text-to-speech - new filter

by Frankie Kam -
Picture of Plugin developers

Hi Yun Gao.

Actually I've just discovered how simple it is to run SimpleSpeakon your Moodle 1.9.x site by using Google's Text-To-Speech service!

1. Download the filter from http://moodle.org/plugins/pluginversion.php?id=118&action=download

2. Ftp the simplespeak folder to your Moodle site's filters folder

3. On your Moodle site, run Notification to install the Filter

4. At the settings page, you can use:
      http://translate.google.com/translate_tts?tl=en&q=!TEXT
   as the Text to speech service URL. See image below:

 

5. Activate the SimpleSpeak filter by clicking on the filter's eye icon

6. Test the filter to see if it is working by creating a label or a webpage with the text: [speak]Welcome to Moodle![/speak]

7. Save the resource 

8. You should be able to see the SimpleSpeak object.
 

9. Click the SimpleSpeak object and enjoy the text to speech audio! 

Hope this helps!

Frankie Kam

Average of ratings: Useful (1)
In reply to Frankie Kam

Re: 回复: SimpleSpeak text-to-speech - new filter

by Doug Moody -

Frankie (or anybody)

You said you installed it on 1.9. Has anyone tried this on a 2.x Moodle? Is there any reason it would NOT work on a 2.x install?

In reply to Doug Moody

Re: SimpleSpeak text-to-speech - new filter

by Stuart Mealor -

Yes, we've got it running on Moodle 2.1.3+

You can see it here on our public development server (you can use Guest access)

http://dev.moodlebites.com (Course is called SimpleSpeak Filter)

We have noticed a strange behaviour in that the filter will work (once) and then seems to not work again?

Average of ratings: Useful (2)
In reply to Stuart Mealor

Re: SimpleSpeak text-to-speech - new filter

by peter winter -

I have got the filter to work on both 1.9 and 2.0 using Google translate. It is a little temperamental and definitely works better with very short text.  The sites I run are all for my primary school and the SimpleSpeak filter has the most enormous potential for this age range. As a sidepoint if you set up a glossary and autolink the entries all the text to speech entries break-any ideas!

Average of ratings: Useful (1)
In reply to peter winter

Re: SimpleSpeak text-to-speech - new filter

by Stuart Mealor -

"if you set up a glossary and autolink the entries all the text to speech entries break"

Hmmm, well in this case you are filtering the text twice - once for the SimpleSpeak, and once for the Glossary auto-linking.  So I'm wondering if the order that you have the Filters in will make a difference?

Although Teachers can enable/disable Filters at a Course level in Moodle 2.x, the order has to be altered at a site level, by Admin.  I'm not sure this will resolve this problem for you, but it might be a factor?

Stu

Average of ratings: Useful (1)
In reply to Frankie Kam

Re: 回复: SimpleSpeak text-to-speech - new filter

by Giedrius G. -

Hello,

now I managed to make it show the button, but when i click it nothing happens. The file is generated in the server. Also below the inserted link the player is shown like black rectangle, maybe this is the problem? Any ideas how to solve it are welcome.

Thanks.

Giedrius

In reply to Frankie Kam

Re: 回复: SimpleSpeak text-to-speech - new filter

by Dorota B -

I have the filter on Moodle 1.9 using Google translate. The problem is that once it works in browsers and another time it doesn't and all I can see is text in brackets "Speak". 

What can be the reason?

Any ideas? Thanks

 

In reply to Nick Freear

Re: SimpleSpeak text-to-speech - new filter

by peter winter -

Have  the SimpleSpeak filter working in 1.9 and 2.1. Upgraded to 2.2 and it does not work using the http://translate.google.com/translate_tts?q=!TEXT. Has anyone got any suggestions or do I have to wait for the 2.2 version.

In reply to peter winter

Re: SimpleSpeak text-to-speech - new filter

by Albert Chan -

Hi Peter, I am using v2.2.4, I have same problem, do you have any solution yet? 

Will Nick (the author) make any update in near future?

In reply to Albert Chan

Re: SimpleSpeak text-to-speech - new filter

by peter winter -

Hi Albert

As far as I know there is no update yet. As a solution to not having the Simple Speak working I have used the new Nanogong applet for quick audio instructions. Another solution is to use Vozme a free TTS where you can copy your text, create a mp3 of it and then upload it. Fun but even longer process use VOKI.

Hope this is of some help!

Vozme

Voki

nanogong

In reply to peter winter

Re: SimpleSpeak text-to-speech - new filter

by Albert Chan -

Hi Peter, thanks for your useful tips. I am using a workaround. I make a link to google tts and ask student to click it

Click and Listen -> Apple

 Of course you can replace the "Apple" text with image <img></img>

P.S. There should be a popup window to play "Apple" . Seems removed javascript code when I save it.

In reply to peter winter

Re: SimpleSpeak text-to-speech - new filter

by Thomas Bachert -

Please provide an update to this plugin.  We host over 30 schools at my job and they are greatly anticipating the use of SimpleSpeak.  We are currently using Moodle 2.2.3

Thank you for your time and cannot wait to install this plugin - Tom

In reply to Nick Freear

Re: SimpleSpeak text-to-speech - new filter

by Frankie Kam -
Picture of Plugin developers

I get an echo when I click on a SimpleSpeak link - if I use Google Chrome. When I use Mozilla Firefox, there is no echo! Anyone experienced this phenomena?

In reply to Frankie Kam

Re: SimpleSpeak text-to-speech - new filter

by Doug I -

I can confirm this.

Firefox - Perfect;
Chrome - The file seems to play twice, so often appears to have an echo, but occasionally also plays them consecutively instead. I notice the code generates two iframes - could this be the cause?
Internet Explorer - Works as expected, however with an added 2-3sec delay.

In reply to Nick Freear

Re: SimpleSpeak text-to-speech - new filter

by Giedrius G. -

Hello,

I'm quite new to Moodle, I have tried to install Bitnami with Moodle version 2.2.2. Is it possible to use SimpleSpeak TTS with this kind of installation? Because i can see the filter enabled, but when try to post something I can see it like this: [Speak] Hello world [/Speak]. It doesn't seem to work. Any suggestions are really appreciated. Thanks.

Best regards,

Giedrius

In reply to Giedrius G.

Re: SimpleSpeak text-to-speech - new filter

by Frankie Kam -
Picture of Plugin developers

SimpleSpeak limitations

The following tag pair and sentence results in "backslash" being voiced three times and "single quote" voiced once. Quite irritating.

[speak]It's great to be back isn't it?[/speak]

How do I solve this? 

In addition, he below sentence doesn't work. Perhaps it's too long?

[speak]If quitters never win, and winners never quit, then who is the fool who said, quit while you're ahead?[/speak]

Frankie Kam

In reply to Frankie Kam

Re: SimpleSpeak text-to-speech - new filter

by Philip Hayes -

I got this to work on moodle 2.2.x by changing line 169 of filter.php to:

 var SIMPLESPEAK_URL="{$CFG->wwwroot}/filter/simplespeak/proxy_tts/?q=";

I also found the editing jquery.speak.js line 25 and changing it to:

$(".tts").append('<iframe style="display:none" id="tts-frame" title="Player" src="" width="2" height="2"></iframe>');

Adding in the "display:none" to the iframe stopped the page from jumping up to the first iframe when there where multiple instances of speech on the page.

Hopefully it will work for you guys too.

 

In reply to Philip Hayes

Re: SimpleSpeak text-to-speech - new filter

by Frankie Kam -
Picture of Plugin developers

Hi Philip! 

Thanks for sharing this. I've used your clever hack and it seems to work. No repetitious overlapping audio this time. Brilliant! 

Frankie Kam

In reply to Nick Freear

what about other languages

by Yasser Goda -

can this filter be used with other languages , if possiple can we use more than one languaes in moodle at the same time , and ho to choose which language to use in each place in the lesson.

by the way , I'm using google service.

many thanks for your concern

In reply to Nick Freear

Re: SimpleSpeak text-to-speech - new filter

by Suresh Dhanakotti -

Hi Nick,

Thanks for the wonderful plugin. It's very useful.

I installed the plugin in Moodle 1.9.8, it's working fine but I give more than 100 chars inside <speak> tag it's not working. Can you please tell me how to make it work for more than 100chars?