Tuesday, October 05, 2004

Adding sound to a boring build

Well, the builds that I do at my day job take a couple of minutes and I hate wating for build to complete. So i decided to add a simple voice notification mechanism at the end of the build so that I can go back to poor dos prompt.

I was left with three options:

1. Using optional ant task Sound.
Using sound task is little boring since you need the audio files for what your build process want to say to you. Also this requires modifying the original build which could be annoying for other team members who don't prefer the sound notification.

2. Writing a custom ant task using FreeTTS.
Writing a custom ant task would help me relearn how to write custom ant task as it has been 2 years since i wrote a custom ant task. But the problem is this also requires modifying the original build which could be annoying for other team members who don't prefer the sound notification.

3. Writing a custom logger.
Well this option probably is simplest and doesn't require any change to regular build file. So this works great for me.


Its really amazing how simeple this task is using FreeTTS and Ant. Write a simple logger extending DefaultLogger. Extending DefaultLogger helps because you only need to listen to events that you want to add sound to. Here is my code for providing sound to build complete event:


package org.js.build;

import org.apache.tools.ant.BuildEvent;
import org.apache.tools.ant.DefaultLogger;

import com.sun.speech.freetts.Voice;
import com.sun.speech.freetts.VoiceManager;


public class FreeTTSLogger extends DefaultLogger {

    public void buildFinished(BuildEvent e)
    {
      //Let default logger do what ever it doing.
        super.buildFinished(e);

        String voiceName = "kevin16";
        //create voice 
        Voice buildVoice = VoiceManager.getInstance().getVoice(voiceName);

        if (buildVoice == null) {
            System.err.println("Cannot load a voice named " + voiceName + ".");
            return;
        }
        //Allocate the resources for the voice.
        buildVoice.allocate();

        /* Synthesize speech based on whether or not build is successful
         */
        if(e.getException() == null)
          buildVoice.speak("Build completed Mr. Kumar.");
        else
          buildVoice.speak("Build failed.");

        //cleanup. Be a good citizen.
        buildVoice.deallocate();

    }

}


For using the logger copile this code into a jar file of its own. You can download my jar file. copy this jar file into lib directory of your ANT_HOME. Now you need to copy FreeTTS libraries (all jars under freetts\lib directory) to ANT_HOME\lib directory. But ant 1.6 and FreeTTS 1.2Beta2, this throws a unexpected Exception:

java.lang.ArrayStoreException
at java.lang.System.arraycopy(Native Method)
at java.util.Vector.toArray(Vector.java:688)
at com.sun.speech.freetts.UniqueVector.toArray(VoiceManager.java:840)
at com.sun.speech.freetts.VoiceManager.getVoiceDirectories(VoiceManager.java:203)
at com.sun.speech.freetts.VoiceManager.getVoices(VoiceManager.java:109)
at com.sun.speech.freetts.VoiceManager.getVoice(VoiceManager.java:519)
at org.js.build.FreeTTSLogger.buildFinished(FreeTTSLogger.java:55)
at org.apache.tools.ant.Project.fireBuildFinished(Project.java:1796)
at org.apache.tools.ant.Main.runBuild(Main.java:693)
at org.apache.tools.ant.Main.startAnt(Main.java:188)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:196)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:55)

A simple way to get around this is by copying FreeTTS libraries to JRE\lib\ext directory. Now to use this new logger, just use the command:

ant -logger org.js.build.FreeTTSLogger

27 comments:

Anonymous said...

Awesome. I am going to add the same to my build process.

/Chris

Anonymous said...

The Usual Suspects, right?

Mats

tweedledeetweedledum said...

This blog is awesome! If you get a chance you may want to visit this mp3 download site, it's pretty awesome too!

Anonymous said...

I came across you blog and thought you may find this site usefull. It has gas saving tips and where to find cheap gas. washington state travel

:)

foundation grants said...

Do you know or have you ever heard of Gotting Money from foundation grants ..If you are interested in finding out how to get more info on foundation grants visit us at http://grantsnloans4u.com... There are so many things you can get grants for.. Homes, school, work, business, college..ect.. Find out how everybody is getting money from foundation grants today... Quit living in poverty educate yourself and improve your life..

miami roofers said...

Wow... Find me a miami roofers Today.. If you are having problems with your roof. Look no more.. Visit us at http://roofer4u.com and get the information aboutmiami roofers.. If you cant find what you need go to http;/contractorr.com ..

daytona roofers said...

Raining its Pouring... Find me a daytona roofers Today.. If you are having problems with your roof. Look no more.. Visit us at http://rooferr.com and get the information aboutdaytona roofers.. If you cant find what you need go to http;/contractorr.com ..

how to build a house said...

Projects..Projects..Projects.. If you are like me it seems like there is never enough time in the day.. You get home late and leave early.. then the weekends thats another story by itself. My wife has found it easier to hire somebody if you we need help with how to build a house. She fond a great site for how to build a house at http://build444.com and wanted to share it with you.. Im glad to find help when I need it..

Anonymous said...

WOW WHATS NEXT>>>Live Your Life With A Little Daily Motivation.. Do we seek empowerment Daily,weekly or yearly. I have been interested in working and empowerment for years now. I am driven to success by the master teachers from the past. I really enjoy people like Wayne Dyer, Greg Vanden Berge and Tony Robbins. Im writing to this blog for selfish reasons, I want to see everyone live the life of their dreams. I am Living my life to the fullest and it is due to a book writen by Greg Vanden Berge . Master Goal Achiever and Author of Start Living Your Dreams Today.. A Great Book from the masters.. I hope you enjoy the book as much as I did..

Anonymous said...

Visit Our Web Site at http://buildhomes4u.com If You are Looking forr advice on how to build your own house

Solutions said...

Well such an interesting and informative site.

If you require some custom home building info come visit mine at http://www.customsuperhome.biz/SuperiorHomes/Custom_Build_Homes.html

Palace said...

Some thought provoking and interesting comments I would say.

Anyways, if you like I have an interesting site to visit at http://www.customsuperhome.biz/SuperiorHomes/Custom_Build_Homes.html. All about supercustomhomes

Anonymous said...

Building Self-Esteem and Happiness in your life..How do I create a life of abundance forever..Visit and learn..Any questions..http://possibility123.com/build-self-esteem.html. How do I find the love of my life. What do you want from other people.

private label rights said...

I don't know if you've noticed, but the competition amongst resell rights providers has become dog eat dog.

It's a huge market, but you end up competing against the big dogs every time.

The solution, in my opinion, is in private label and source code rights.

Simply put, these are the groundwork for creating your own products and services which you are then the sole owner of.

With private labels you get to brand your own identity and all the sudden you are no longer competing with hundreds or even thousands of people to sell the same old products.

If you want to learn more about how to put yourself ahead of the pack with ease then check out this great provider...

private label rights

Scott Arthur Edwards said...

Check this out for FREE...

This opportunity says:

"Your Ad" Will Be Instantly Displayed on Thousands of Websites and Read By Over 10 Million People Per Week For FREE, and It Only Takes 60 Seconds To Get Started!

To find out more visit: proven system site. It successfully exposes FREE information covering Traffic and proven system related stuff.

Anonymous said...

Dear Blogers

Great fallbrook contractors advice can be founf at http://fallbrookremodeling.com/sitemap_1.html . We are starting a home improvement site for home remodeling experts and home owners.

Scott A. Edwards said...

Check this out for FREE...

This opportunity says:

"Your Ad" Will Be Instantly Displayed on Thousands of Websites and Read By Over 10 Million People Per Week For FREE, and It Only Takes 60 Seconds To Get Started!

To find out more visit: money making idea online site. It successfully exposes FREE information covering Traffic and money making idea online related stuff.

Anonymous said...

Hello General Contractors

One of the most popular home improvements where home improvement contractors come in handy are the re styling of your home. If you really wish to give your home a total professional new style then there are lots of interior designers out there who are very willing to help you re furnish and style you house to get the look that you are looking for. However, the problem is that they tend to be quite expensive even though they are really only consultants. As with any other home improvement project, you're the one that will have to pay for all materials and the hours that the contractors spend telling you how to choose fabrics and so on.

No matter what type of home improvement project you plan on doing - a large or small job, the home improvement contractors you choose will have a great impact on the results you get for your home improvements. Always make sure that you see their certificates and the materials that they use. Do this both before the job is started and while the project is in progress as well. If you don't like something they are doing you have the decision to stop their work.

http://fallbrook.rgcont.com/

Anonymous said...

Home improvement is a great financial investment, either in the money you put into it or the money you hope to get out of it. All 40,000 of our building, remodeling, Temecula Contractors renovation and construction contractors in all fifty states and Canada are checked for state licensing and insurance requirements at the time of their enrollment. Whether you are a contractor or homeowner, ServiceMagic has the answer . Home remodel contractors or Building new construction ServiceMagic has the answer to all of your home improvement needs and questions. Again Thank you for Visiting fallbrook remodeling,,

Anonymous said...

Here it is... FREE advertising, FREE download. No cost to you! Get your FREE download NOW! Make money and get FREE advertising! This is a great program for you to take advantage of... Check this out now for FREE!

To find out more visit: make a living online site. It successfully exposes FREE information covering traffic and make a living online related stuff. Don't forget, FREE, FREE, FREE!!!

Anonymous said...

Hi
Take a look adipex | didrex | meridia | adipex | phentermine | phentermine
phentermine | ativan | valium | xanax | sex for adult
G'night

Anonymous said...

Hello
WATCH THESE GIRLS WORK IT WITH THEIR STRAP-ONS


Show Models by Ethnicity:

G'night

Anonymous said...

Hi all!
Join for free. Most of 2 millions members.List of most popular hot girls in your area. Find today sex partner here from list of most hot girls in your area. Adult only.
hotgirls xanax sex sexcam phentermine xanax phentermine sex hotbabe sexforadult sex sexygirlsfree sexygirls sexfree adult hotgirlsonline freeadult sexvideo
viagra valium meridia ativan xanax drugs valium tramadol viagra drug store free hosting viagra levitra cialis
Have fun

Anonymous said...

Hello .List of most popular hot girls in your area. Adult only.
hotgirls cialis xanax sex sexcam phentermine xanax phentermine sex hotbabe sexforadult sex sexygirlsfree sexygirls sexfree adult hotgirlsonline freeadult
/sexvideo--.blogspot.com>sexvideo

valium meridia ativan xanax drugs valium tramadol viagra drug store viagra levitra cialis
Check prices of these useful pills:
tramadol pharmacy search cialis soma ambien meridia ultram tramadol carisoprodol viagra
Have fun

Anonymous said...

Hi
xanax phentermine xanax xanax phentermine phentermine phentermine tramadol tramadol tramadol levaquin levaquin levaquin norvasc sex babe casino casino
lroulette blackjack lpoker phentermine
G'night

Anonymous said...

-Why would not Marianne come?
hydrocodone vicodin

Anonymous said...

Hello

http://nextel-ringtones.da.cx

See you