Newsletter sign-up
View all newsletters

Sign up for our technology specific newsletters.

Enterprise Java
Email Address:

Talking Java!

Add speech capability to your Java 1.3 applications and applets

  • Digg
  • Reddit
  • SlashDot
  • Stumble
  • del.icio.us
  • Technorati
  • dzone
Why would you want to make your applications talk? For a start, it's fun, and suitable for fun applications like games. And there's a more serious accessibility side. I'm thinking here not just of those naturally disadvantaged when using a visual interface, but also those situations where it's impossible -- or even illegal -- to take your eyes off what you're doing.

Recently I've been working with some technologies to take HTML and XML information from the Web [see "Access the World's Biggest Database with Web DataBase Connectivity" (JavaWorld, March 2001)]. It occurred to me that I could plug that work and this idea together to build a talking Web browser. Such a browser would prove useful for listening to snippets of information from your favorite sites -- news headlines, for example -- just like listening to the radio while out walking your dog or driving to work. Of course, with current technology you'd have to carry around your laptop computer with your mobile phone attached, but that impractical scenario could well change in the near future with the arrival of Java-enabled smart phones like the Nokia 9210 (9290 in the US).

Perhaps more useful in the short term would be an email reader, also possible thanks to the JavaMail API. This application would check your inbox periodically, and your attention would be attracted by a voice from nowhere proclaiming "You have new mail, would you like me to read it to you?" In a similar vein, consider a talking reminder -- connected with your diary application -- that shouts out "Don't forget your meeting with the boss in 10 minutes!"

Assuming you're sold on those ideas, or have some good ideas of your own, we'll move on. I'll start by showing how to put my supplied zip file to work so you can get up-and-running straightaway and skip the implementation details if you think that's too much hard work.

Test drive the speech engine

To use the speech engine, you'll need to include the jw-0817-javatalk.zip file in your CLASSPATH and run the com.lotontech.speech.Talker class from the command line or from within a Java program.

To run it from the command line, type:

java com.lotontech.speech.Talker "h|e|l|oo"


To run it from a Java program, simply include two lines of code:

com.lotontech.speech.Talker talker=new com.lotontech.speech.Talker();
talker.sayPhoneWord("h|e|l|oo");


At this point you probably wonder about the format of the "h|e|l|oo" string you supply on the command line or provide to the sayPhoneWord(...) method. Let me explain.

The speech engine works by concatenating short sound samples that represent the smallest units of human -- in this case English -- speech. Those sound samples, called allophones, are labeled with a one-, two-, or three-letter identifier. Some identifiers are obvious and some not so obvious, as you can see from the phonetic representation of the word "hello."

  • h -- sounds as you would expect
  • e -- sounds as you would expect
  • l -- sounds as you would expect, but notice that I've reduced a double "l" to a single one
  • oo -- is the sound for "hello," not for "bot," and not for "too"


Here is a list of the available allophones:

  • Digg
  • Reddit
  • SlashDot
  • Stumble
  • del.icio.us
  • Technorati
  • dzone
Comments (1)
Login
Forgot your account info?

GoodBy Anonymous on June 3, 2009, 4:21 amVery good job

Reply | Read entire comment

View all comments

Add comment
Anonymous comments subject to approval. Register here for member benefits.
Have a JavaWorld account? Log in here. Register now for a free account.
Resources
  • "Add MP3 capabilities to Java Sound with SPI," Dan Becker (JavaWorld, November 2000)
    http://www.javaworld.com/jw-11-2000/jw-1103-mp3.html
  • Sign up for the JavaWorld This Week free weekly email newsletter to learn what's new at JavaWorld: http://www.idg.net/jw-subscribe
  • You'll find a wealth of IT-related articles from our sister publications at IDG.net