Ruby, Ruby on Rails, Artificial Intelligence and something more ...

Ver y Cocinar, descubre la cocina y disfrĂștala a simple vista

RailsConf Europe 2007 Speaker

RailsConf Europe 2007 Speaker

Spejman Thumblog!

Tuesday, 12 June 2007

Text to speech for Ruby on Rails applications

I just published the first usable festivaltts4r version, it comes with its plugin for Ruby on Rails, festivalttsOnRails. With this library and this plugin you can make talk your Ruby and your Ruby on Rails applications.

The rails plugin is so easy to use in Ubuntu linux:

  1. Install tts and mp3 generation libraries:

    sudo apt-get install festival lame

  2. Install the festivalttsOnRails plugin for Ruby on Rails:

    script/plugin install \

  3. Use text_to_flash_player(text) method in your views:

    <%= text_to_flash_player "Talk me!" %>

At the moment the plugin works with a simple english voice but can be very useful as a proof of concept. If people found it interesting it could be improved.

It works so well in Ubuntu Linux, testing in other platforms will be appreciated.

You can also use the festivaltts4r gem in order to make local voice applications with Ruby:
  1. Install tts and mp3 generation libraries:

    sudo apt-get install festival lame

  2. Install festivaltts4r gem:

    sudo gem install festivaltts4r

  3. Include required gems and call to_speech method defined into the String class by festivaltts4r:

    require "rubygems"
    require "festivaltts4r"

    "I'm talking".to_speech

This project has been developed using Festival TTS and lame libraries.

The flash mp3 player used to play the voice has been developed by dew under Creative Commons Attribution-ShareAlike License France license.

More info about festivaltts4r and festivalttsOnRails:

Tuesday, 5 June 2007

Draw with Ruby and Scribble!

Looking at the new blog of _why ( I found Scribble! that it's a Ruby version of NodeBox. Its aim is to make cool graphics using Ruby.

If you want to test it using windows, you can follow the instructions at

I wanted to test it in Linux but I didn't found related information, then I did some research on how to install it. Finally, I made it work in Ubuntu following these steps:

  1. Install cairo and gtk2 ruby libraries and get the scribble code:

    sudo apt-get install libcairo-ruby1.8 libgtk2-ruby
    svn co svn:// scribble

  2. Execute scribble:

    cd scribble

With these steps we'll execute Scribble! and we can do graphs like this:

Scribble! Screenshot

This drawing is uniq because it is randomly generated from this code:

brush.fill = rand(0.1) + 0.9, rand(0.4) + 0.6, rand(0.1) + 0.9, rand(0.1)+0.1

brush.fill = rand(0.1) + 0.9, rand(0.4) + 0.6, rand(0.1) + 0.9, rand(0.1)+0.1
brush.stroke = rand(0.4) + 0.6, 0, 1, 0.2
brush.width = 2

100.times do
circle :center => [rand(size[0]), rand(size[1])], :radius => rand(50) + 10

If you like Scribble! and make some cool graphics, share it putting its code as a comment in this post ;)

About Me

Barcelona, Barcelona, Spain