# Text to speech?

**URL:** <https://www.ruby-forum.com/t/text-to-speech/97371>\
**Category:** Ruby\
**Created:** [July 6, 2006, 5:46pm UTC](https://www.ruby-forum.com/t/text-to-speech/97371 "2006-07-06T17:46:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![arun](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ee7513/32.png) [@arun](https://www.ruby-forum.com/u/arun)\
**Post date:** [July 6, 2006, 5:46pm UTC](https://www.ruby-forum.com/t/text-to-speech/97371/1 "2006-07-06T17:46:55Z")

</div>

Hi, I’m new to Ruby and to Linux, but not to programming. I teach blind  
people how to program in New Delhi, and it saddens me that they all use  
MS Windows. I teach them Visual Basic version 6, which is far more  
accessible to the blind than later versions, but that is another story.

Anyway, in looking for a programming environment well suited to Linux,  
I examined Ruby, and loved it. Now, of course, for a blind person,  
audio is as important as the screen is for the sighted, and even to do  
your first “Hello World” program, you need text to speech to be  
working.

I’m running Ubunty Breezy, and have Gnopernicus installed, but in the  
terminal window, it only reads out part of what is needed: program  
output is ignored. I’m therefore wondering how I might access text to  
speech in Ruby, preferably in a manner that works independent of what  
kind of Linux is installed. I was unable to get Emacspeak to say  
anything, and did not have much joy trying to get it to compile and  
debug Ruby code.

Ideas or thoughts related to any of the above would be highly  
appreciated.

Arun

---

<div class="post-metadata">

**Author:** ![arun](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ee7513/32.png) [@arun](https://www.ruby-forum.com/u/arun)\
**Post date:** [July 6, 2006, 7:22pm UTC](https://www.ruby-forum.com/t/text-to-speech/97371/2 "2006-07-06T19:22:47Z")

</div>

Arun wrote:

> Hi, I’m new to Ruby and to Linux, but not to programming. I teach blind  
> people how to program in New Delhi, and it saddens me that they all use  
> MS Windows. I teach them Visual Basic version 6, which is far more  
> accessible to the blind than later versions, but that is another story.
> 
> Anyway, in looking for a programming environment well suited to Linux,  
> I examined Ruby, and loved it. Now, of course, for a blind person,  
> audio is as important as the screen is for the sighted, and even to do  
> your first “Hello World” program, you need text to speech to be  
> working.
> 
> I’m running Ubunty Breezy, and have Gnopernicus installed, but in the  
> terminal window, it only reads out part of what is needed: program  
> output is ignored. I’m therefore wondering how I might access text to  
> speech in Ruby, preferably in a manner that works independent of what  
> kind of Linux is installed. I was unable to get Emacspeak to say  
> anything, and did not have much joy trying to get it to compile and  
> debug Ruby code.
> 
> Ideas or thoughts related to any of the above would be highly  
> appreciated.
> 
> Arun

Sorry I am not familar with Text-to-Speech on Linux. On Windows, you can  
use Daniel B.'s Win32 Util library for Ruby (see  
[http://rubyforge.org/projects/win32utils/](http://rubyforge.org/projects/win32utils/)). It has support for win-sapi.

Example:

require “win32/sapi5”  
include Win32

t = [  
“Fourscore and seven years ago,”,  
“our fathers brought forth, upon this continent,”,  
“a new nation,”,  
“conceived in liberty and dedicated to the proposition”,  
“that all men are created equal.”,  
“Now we are engaged in a great civil war, testing whether that nation,”,  
“or any nation so conceived and so dedicated,”,  
“can long endure.”,  
“We are met on a great battlefield of that war.”,  
“We have come to dedicate a portion of it,”,  
“as a final resting place for those who died here,”,  
“that the nation might live.”,  
“This we may, in all propriety do.”,  
“But in a larger sense,”,  
“we cannot dedicate,”,  
“we cannot consecrate,”,  
“we cannot hallow, this ground.”,  
“The brave men, living and dead, who struggled here,”,  
“have hallowed it, far above our poor power to add or detract.”,  
“The world will little note,”,  
“nor long remember what we say here;”,  
“while it can never forget what they did here.”,  
“It is rather for us the living,”,  
“we here be dedicated to the great task remaining before us–”,  
“that from these honored dead we take increased devotion”,  
“to that cause for which they here gave the last full measure of  
devotion–”,  
“that we here highly resolve that these dead shall not have died in  
vain,”,  
“that this nation shall have a new birth of freedom,”,  
“and that government of the people, by the people, for the people shall  
not perish from the earth.”  
]

v = SpVoice.new

srand Time.now.to\_i

t.each do |s|  
v.Speak( s )  
sleep 0.5  
end

---

<div class="post-metadata">

**Author:** ![arun](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ee7513/32.png) [@arun](https://www.ruby-forum.com/u/arun)\
**Post date:** [July 6, 2006, 7:46pm UTC](https://www.ruby-forum.com/t/text-to-speech/97371/3 "2006-07-06T19:46:35Z")

</div>

Arun,

Recently there was an announcement here about Ruby-GNOME:  
[http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/199856](http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/199856)  
and it looks like it supports Gnome’s accessibility interface:  
[http://developer.gnome.org/projects/gap/](http://developer.gnome.org/projects/gap/)

Might be of interest. Not sure. There’s a few links on that GAP page  
(under “Audio”) mentioning Gnopernicus (the links point to mp3’s).

TPFJ [1]

—John

[1]: “Top-Posting For Jamal” 😉
