Wednesday, July 22, 2009

Teach your computer how to speak!

It is good idea to teach computer to speak!. There a number of programs available for winXP paltform, but here is a unique program "espeak" for your linux. Just enter the command in terminal,

$espeak "Boss, I can speak now"

will work fine. It is useful for some scripts in linux to remind some status of computer to the user like a personal assistant. espeak is not an internal bash command and need to be installed. I simply installed in my Debian from repository.

#apt-get install espeak


The command above will work well with ubuntu systems also. If you are using any other distro, you need to download and install it manually. Click here to know more.

Here is a simple python program which uses espeak as system command. To use it you require python and espeak installed.

#! /usr/bin/python
# File: speak.py

import os
from Tkinter import *

class App:

def __init__(self, master):

frame = Frame(master)
frame.pack()
self.button = Button(frame, text="Click", command=self.activate)
self.button.pack(side=LEFT)


def activate(self):
os.system('espeak "Boss, I can speak now"')
print "Boss, I can speak now"

root = Tk()

app = App(root)

root.mainloop()

Just copy the above program into a new file named speak.py and 'cd' into the directory and enter,

python speak.py


You are free to use this program anywhere since espeak is under GPL.

1 comment:

Anonymous said...

Interesting!!