Archive for the ‘hacking’ Category

using text to speech in firefox

Monday, December 26th, 2005

There are so many nice articles written in web everyday. And after delicious, digg, reddit etc are there, these articles are becoming reachable also. But i dont have time to read all of them. How nice it would be if someone will read them for me while in am working on something else. Here is a simple solution.

Software Requirements -
* festival (text to speech software)
* mbrola (speech synthesizers)

Steps -

1) Install festival
- festival comes by default with my distribution fc4.

2) Test festival
- echo “hello world” | festival –tts
or festival –tts filename.txt

this is a basic setup with which will work. You can save the webpage and then run festival on it.

3) Improve voice quality with mbrola ( follow the instructions at this link )
- Get the binary of your architecture from mbroal download page. i386 people get mbr01h.zip. move the binary of your architecture available in mbr301h.zip to any $PATH directory and rename it to just mbrola. ex : mv mbrola-linux-i386 /usr/local/bin/mbrola
- Get the festival voice wrapper from here and extract it to festival voices directory (aka $FVD) (/usr/share/festival/voices for me)
– move us1_mbrola available in the tar to $FVD/english
– get us1 voice from mbrola voices page. extract the mbrola voice (eg us1) to $FVD/english/us1_mbrola/
— to add more voices just copy festvox to another directory (say us2_mbrola), and do the necessary changes to file names and data. replace every us1 with us2 (for us2 voice). and then copy the new voice like before(us1 case).

run festival as in step 2 and you will be able to listen to any text in a real like voice.

But its not very convenient to everytime save text and then run festival. so a firefox extension will do this job for us. coz i am not a firefox extension hacker i have worked around the problem to solve it for me.. if anyone knows how to save the selected test into a file and then run a system program using a firefox extension then please let me know. or those who are looking around to develop something cool, can write such an extension for firefox.

4) my hack to this problem - i mapped a mouse gesture to a javascript (provided by Optimoz Mouse Gesture extension) that posts the selected test to a cgi file sitting on localhost. this cgi file run festival tts on the text and i am able to listen to selected text with a simple mouse gesture. the javascript follows -

Q=”;
x=parent.content.document;
y=window;
if(x.getSelection){
Q=x.getSelection();
}else if(y.getSelection){
Q=y.getSelection();
}
var r = new XMLHttpRequest();
r.open(”GET”, “http://localhost/~user/cgi-bin/tts.cgi?data=”+escape(Q) );
r.send( null );

write a simple cgi files which just does `echo $_GET[’data’] | festival –tts`

5) festival also provides text2wave which allows you to convert text to wave file and you can enqueue the audio file into your playlist.

* window managers like KDE/Gnome etc provides this facility. so if you use a complex window manager, try to explore this facility in it before going through the above procedure.

long time no links -
* The C++ Source. As Simple As Possible?
* How to Interview a Programmer
* You have the right to blog silent!
* 2006 Will Be Delayed By A Second
* Switched On: The Year of the Switch
* Three Reasons Why You Should be an Entrepreneur
* timbl’s blog
* Software Predicts Movie Success
* Agatra / Forget your passwords

rss feeds @ blogroll

Wednesday, October 12th, 2005

blogroll upgraded to v1.4, and it now provides rss feeds for blog entries.

the link for IIIT:blogroll rss feeds is …/blogroll?rss. number of items in the feed can be contorlled with show=[integer], which is set to 6 by default. eg ?rss&show=3 will generate a feed of (10 oops!) 3 entries. **

** if you are checking for feeds frequently keep this number low, and otherwise high. ideally(heuriscically) : hourly(or less) check = 2 , daily check = 5, weekly check = 20. and if it confuse you, just forget about it.

code will me made available for download in a few days.

blogroll v1.0

Wednesday, September 28th, 2005

blogroll is a web based system for gathering feeds from various sites to a single page. an example of blogroll is IIIT::blogroll, which is being used for gathering feeds from blogs of IIIT students.

blogroll v1.0 can be downloaded from here

blogroll is powered by php and magpie.

happy blogging winking

Update 1 (Jan 05, 2006):
rss feed was buggy. Thanks to V Manoj Kumar aka Majjj for pointing that out and fixing it up.
now firefox is able to display it in live bookmarks, the reason why Majjj wanted it to work.
also suggested me to add “–Author” info in feed title. i think it will make life easier.

videoIO : Wrapper for ffmpeg libavcodec

Saturday, September 24th, 2005

This is a wrapper for ffmpeg libraries (libavcodec, libavformat) and provides an easy to use API for reading/writing videofiles. videoIO is object oriented interface to libavcodec and thus provides the simplest way to encode and decode videos.

In short, using videoIO looks like -

#include “videoIO.h”…videoIn v;v.open( char_arr_filename );…v.seek( some_int_position_optional );…do{	char_arr_buf = v.getFrame();	display_the_frame_on_screen( char_arr_buf ); 	// or just do v.saveFrame(”test.pgm”);}while( v.next() );…v.close();…

and program for reading from a video and writing to another video looks like -

#include “videoIO.h”…videoIn vi;videoOut vo;vi.open( “input.avi” );vo.setSize( vi.width(), vi.height() );vo.open( “output.avi” );

do{	vo.addFrame( vi.getFrame );}while( vi.next() );

vi.close();vo.close();…

download the API and example codes from here.

This wrapper includes modification of code provided by Martin Bohme : here and here and code from example programs available in ffmpeg tarball.

Note : The provided wrapper is written for ffmpeg version 0.4.9-pre1, and might not work for any other version. Also this api is still in beta version.. it lack lots of features and you will probably find lots of bugs. If you make any improvements to it, pls let me know. i will be happy to release them with next version.

TODO :
* implement an easy to use Time-Management API with videoIO for seeking by time, forward, rewind, etc operations.
* audio support

ChangeLog :

Nov 08, 2005 : version 0.2b	Can Write/Encode videosSep 24, 2005 : version 0.1b	Can Read/Decode videos