Jun 4, 2010

Free Text-to-Speech

text to speech keyboard speech generating deviceImage via Wikipedia
text to speech keyboard

Text-to-speech is great for the lazy, visually impaired, or people with reading disabilities. I think I read much, but I also count myself to the lazy and I like it to be read to. I found how you can select any text, for example in a webpage or a PDF, and let it be spoken using free software. It is relatively easy to set this up and here I show how.


Introduction

I used to have this on my Mac, people even had this on the amiga, and I also know of some firefox add-ons that give this functionality, such as Text to Voice.

Is something like this possible for free, system-wide, on Linux or Windows? Short answer: Yes. Now I explain how with a simple trick you can hear any text that you select, in any program. I concentrate on installation on ubuntu, but similarly this should be possible on other linux distributions, on MacOS, and Windows.

There are several free software projects that produce speech synthesizers. Possibly the two best known free text-to-speech (TTS) systems are espeak and festival. Both come packaged in many linux distributions but can also be installed on other platforms, such as Mac OS or Windows.

TTS with Espeak in Ubuntu

Espeak is a speech synthesizer for English and many other languages. On ubuntu, installation could not be easier: use synaptic or type sudo apt-get install espeak.

Espeak reads text, for example, try: espeak -f sometextfile. You have options to adjust reading speed, pitch, and a choice of different voices in different languages (in ubuntu just look in /usr/share/espeak-data/voices/es-la). Try: echo "hola" | espeak -v es. You can also put these and other options directly into the files in espeak-data directory, thereby creating new voices.

Now how to read text that you select?

I found a nearly complete solution and here I am going to spell it out.

If you use Gnome as window manager, go to system->preferences->keyboard shortcuts
(if you use KDE or other managers, this should be similar), add a new shortcut.

name: read text
command: bash -c "xsel | espeak"

Then define a key combination. I defined windows button-R.

Now you can select text in any application press your keys and hear the text as it is spoken to you.

Refinement

This works already, but you can make some improvements.

I found that filtering out newline symbols was nicer to the ear, because the pauses at the end of each line make it sometimes hard to understand. The command to hear the text without newlines would then be (thanks!):

Change the command in the keyboard shortcuts to this:

bash -c "xsel | sed -e :a -e '$!N;s/\n/ /;ta' | espeak -s 180 -v en-us"

Of course you can put more elaborate filters instead of the sed command. For example you can substitute "i.e." for "this is." For theater plays you could use different voices for each characters.

I also put in some filters. For example I don't want to hear "i.e." spoken as "IdotEdot" but as "this is."

Here comes my filter file, which you can copy. I stored this file as /usr/share/espeak-data/espeak.sed

s/i\.e\./this is/g
s/e\.\g./for example/g
s/et al\./and others/g
s/\([A-Z]\)\([A-Z]\)/\1 \2/g

If you want to use these filters, your command would look like this:
command: bash -c "xsel | sed -e :a -e '$!N;s/\n/ /;ta' -f /usr/share/espeak-data/espeak.sed | espeak -s 180 -v en-us"

Finally I also defined a key combination, windows button-S to stop the reading.
name: stop text
command: pkill -9 espeak

Note that instead of espeak you can also use the festival speech synthesis system. Install typing sudo apt-get install festival. A simple test: echo hello | festival --tts. I needed to switch to ALSA output for it to work. See configuration options at the archlinux wiki.

Enjoy. Please tell me of any improvement you come up with. 

Alternative Blogging Platforms

A blogging platform is the combination of hosting service and software for the purpose of maintaining a weblog. The most common platforms are blogger.com, always hosted with google (usually with the blogspot.com domain), and the wordpress software, on paid hosting services or using the wordpress.com hosting service. Other popular services are Typepad or liveJournal. In this post I want to show an alternative that can beat these services in price, customization, and loading speed. It involves using free software (as in beer and in spirit) with the google app engine as a hosting service.


Introduction

All blogging platforms have some limitations. Blogger is free and easy to use. Its scripting language, Blogger XML, is very limited, which brings problems for extensions and search engine optimization (SEO). I have the impression that it is also a bit buggy sometimes.

Wordpress presents a more professional look than blogger. It offers to download and self-host the wordpress software (which is free software), with many possibilities for extension with plugins to help presentation and SEO.

Both blogger and wordpress.com are very fast to load from everywhere on the world, because they use a content delivery system. The same is not automatically given with self-hosted blogs, where the download speed depends on the distance of the reader to the hosting server.

Blogging Software for the Google App Engine

Now, it would be great to have a blogging platform, which is freely extensible (free and open software) like wordpress, fast to load using a content delivery system, and free of costs. There is more and more blogging software emerging that can be hosted on google app engine (GAE). This fulfills the three criteria: it is free and open software, it is fast to load (because of GAE), and it is free of costs (if you don't get millions of visitors at least).

I took a look at blogging software for GAE. Some of them are still in early stages of development, others are more mature. There are huge differences with respect to feature sets. I made a wishlist of features that I want a blogging software to have. My list is based on the post Show me your open source Django blog application.

  1. (Elegant) user interface for managing the blog.
  2. WYSIWYG post editor.
  3. Publishes (RSS and/or Atom) feeds.
  4. Allows importing and exporting of posts.
  5. Post authoring in teams.
  6. Compatibility with most browsers (Firefox, Safari, Konqueror, Internet Explorer 7 and 8).
  7. Documentation of the software.
  8. Native comment system (non-javascript, because of SEO).
  9. Support for remote publishing (for example via scribefire, windows live writer or the metaweblog api).
  10. Project actively developed.
  11. Importer from Blogger.
  12. Importer from Wordpress.

List of Blogging Software

I compiled a list of python software that runs on GAE. I found it remarkable that many of the projects are written by Chinese developers, presumingly because of access restrictions to more common blogging platforms (such as blogspot.com) from within the Chinese mainland. A very influential blog software is bloog; many projects have been based on its code. Again: the projects are in different states of maturation. Setting up a blog on GAE requires at least some knowledge of programming. I put down the list without many comments. There's no special order, although I put my personal favorites as the first.
SoftwareDemo
Tom Strummer Bloogdemo
cpediaPing Chen's blog
i-heredemo
Pyweblogdemo
appengineblogsoftwareDeveloper Advocate
vasaoveltema.jp
JoeyBdemo
Pinax Combono demo yet(?)
Project Pickydemo
Micoblogdemo
toon blog
demo
This blogging software does not run on GAE, but I still list it because it is great (free) software as you can see in the demos.



SoftwareDemo
Django Techblog"demo
byteflowdemo 1demo 2
Mighty Lemondemo
Kukkaisvoimademo
Frogdemo


Enjoy. Please leave a comment below for questions and suggestions.