Friday, March 26, 2010

TTS (Text-to-Speech) Using Linux

Okey... TTS or Text to Speech is the system converts normal language text into speech. Speech synthesis is the artificial production of human speech. A computer system used for this purpose is called a speech synthesizer, and can be implemented in software or hardware

This Schema of TTS generally :

File:Festival TTS Telugu.jpg
for more information about TTS u can go to http://en.wikipedia.org/wiki/Speech_synthesis
Now at least we know how text can be converted to voice.

Let's Rock n Roll On LINUX
actually, you can use any LINUX Distro and I Use CENTOS 5.2 to implement TTS
here we go...
if you have install linux on your PC, you can go now to try TTS but if you have not install yet. i will wait you :P hehehe......
Okey....Now We install dependencies of TTS using gnome-terminal or shell (run as root)


1. yum install festival (for REDHAT-Based) / apt-get install festival (for Debian-Based)
festival is the speech synthesizer that developed by The University of Edinburgh


2. yum install text2wave (for REDHAT-Based) / apt-get install text2wave (for Debian-Based)
taxe2wave is text to wav converter based-on festival voice

3. Install lame :
- wget http://nchc.dl.sourceforge.net/project/lame/lame/3.98.4/lame-3.98.4.tar.gz
- tar xvfz lame-3.98.4.tar.gz
- cd lame-3.98.4
- ./configure --prefix=/usr
- make
- make install
lame is wav to mp3 converter :D
4. Install PHP and Web Server (Optional: Just if you want to make a TTS Web-Based)
- yum install php5 httpd (for REDHAT-Based) / apt-get install php5 httpd (for Debian-Based)
PHP and Web Server for create web-based TTS



Now test festival running or not

$ echo hello world festival --tts (you will hear "Hello World")

$ nano myspeech.txt (write everything you wanna say)

$ festival --tts myspeech.txt (you will hear everything you wanna say)



Test text2wav

$text2wave myspeech.txt -o myspeech.wav (Now you will get wav file from text2wave )



Test lame

$lame myspeech.wav myspeech.mp3 (and you get mp3 file from lame you can play using totem in linux)



Okey....actually it's over if we just talking how can we convert text to audio file but if we want to try explore.

I will give u a simple source code for PHP front-end below


< html >
< body >
< form method="POST" >
< textarea name="text" cols="70" > < /textarea > < br / >
< input type="submit" >
< /form >
< ?php
error_reporting ( E_ALL );
ini_set ( 'display_errors', True );
if ( isset ( $_REQUEST['text'] ) ) {

//Directory OF WAV FILE
$wavfile = "wav/".time().".wav";

//Directory Of WWW file default is /var/www
$wwwDir = '/var/www/voice/';
2
//Directory of mp3 file
$mp3file = "mp3/".time().".wav";

// convert text 2 wav
exec ( 'echo "'. escapeshellarg ( utf8_decode ( $_REQUEST['text'] ) ) . '" | text2wave -o ' . $wwwDir . $wavfile );

// convert wav to mp3
exec ( "lame '".$wavfile."' '".$mp3file."'" );
? >
< p > The File is < a href="
< ?php
echo $speechfile;
? > " > Here< a > < /p >
< ?php
}
? >
< /body >
< /html >

Oke See ya..... I hope can help you





Monday, February 1, 2010

Build your own SMS gateway with Ubuntu Linux and Gammu

Some time ago I went down the path of building a simple sms gateway. At the time I wrote a basic blog entry but received numerous requests for a more detailed "how-to"... so here it is.

I based my solution around a basic linux (Ubuntu) server - the machine itself is nothing fancy but is more than capable of handling the sort of load it's getting. The device being used to send/receive SMS messages is an "old" Nokia mobile phone that I have since retired from use as a handset.


The specs of all components I used are listed below - all up you should be able to purchase these items for less than $50 (or you may have the majority of them lying around).

Computer: IBM GL300 - Celeron 366, 128Mb RAM, 30Gb HDD
Phone: Nokia 7200
Cable: Nokia "Type CA-42" (this will vary depending on your phone, basically it's a usb to phone cable)
Software: Ubuntu Server (I used the "edgy" release) and Gammu (the part that does all the work)

Optional: USB Phone charger - this makes things easier than having to find somewhere to plug in another power adapter and is also much more energy efficient :)


Please note: I am assuming some basic linux familiarity with this tutorial - if nothing else the ability to use a command-line editor such as vim to edit text files is required. I have tried to keep all the language simplified to make this tutorial suitable for people of all skill levels.
Step 1 - INSTALL UBUNTU

The first step is to install ubuntu (server) on you machine. You can install the desktop (client) release if you prefer - although if you're doing so I woul recommend a higher-spec machine. As I am using this machine strictly as a server (all access will be done remotely once the initial install is complete) I had no need for a GUI or additional applications.

Run through the setup and answer all the questions - they should all be fairly straight-forward, and if you get stuck the defaults are usually what are worth using.

The only point to ensure you do is select that you want to run it as a LAMP (Linux, Apache, MySQL, PHP) server.
Step 2 - Remote Access

Once the install is complete and the server rebooted, I like to install ssh so that I can complete the process from the comfort of my study (rather than coping with the noise from a rack full of machines). This is done with the following command:

sudo apt-get install ssh

Once this is done you can complete the process remotely using an ssh client (in my case PuTTY) - of course you can always sit with your server and do it all locally - whatever you prefer.
Step 3 - Update and Upgrade/Patch the server

I like to get things up to date and patch them before going any further (much like I would do with any other Operating System). Before running an update (to find out what is available) and an upgrade (to implement the upgrades) using apt-get, the /etc/apt/sources.list file needs to be modified to ensure that all universe and backport repositries are made available (this will make sense when you see the file).

Once you have made the changes to /etc/apt/sources.list, use the following commands to update and upgrade your server:

sudo apt-get update
sudo apt-get upgrade

Step 4 - Install Gammu

Installing gammu is surprisingly easy (once again thanks to the wonders of apt-get), just use the following command:

sudo apt-get install gammu

Hard wasn't it? ;)

OK now it's time to plug your phone in and see if we can get things talking. With the phone connected, type the following command:

lsusb

you should now see your phone listed as a device - for example:

Bus 001 Device 002: ID 0421:0802 Nokia Mobile Phones

if not - make sure your cables and power are all good and try again.

The gammu installation comes with some example configuration files which are worth using as a starting point - if nothing else they help you to understand how gammu can be configured so that you can tailor a solution for your needs. These are located in /usr/share/doc/gammu/examples (in gZip archives).

Copy the gammurc file to /etc/gammurc :

sudo cp /usr/share/doc/gammu/examples/config/gammurc /etc/gammurc

Now edit /etc/gammurc to specify your port and connection type (this will vary based upon where/how you have things plugged in and what sort of cable/interface your phone is using). The settings for mine are:

port = /dev/ttyACM0
connection = dku5

Save this config and from the shell type:

gammu --identify

you should now be presented with some information regaqrding your phone such as:

Manufacturer : Nokia
Model : 7200 (RH-23)
Firmware : 3.110 T (18-03-04)
Hardware : 0903
IMEI : 353363000813894
Original IMEI : 353363/00/081389/4
Manufactured : 04/2004
Product code : 0514143
UEM : 16

If this is the case then you have got gammu up and running and can send yourself a test message with the following command:

echo "boo" | gammu --sendsms TEXT [recipient mobile number]

That's it for the basic creation of your own private SMS gateway - I'll post a followup article which details how to integrate gammu with MySQL and also discuss creating a PHP front-end for it (these are the reasons the LAMP components were installed).A challenge plays!.