Chapter 2: Creating a Speech-Enabled Calendar Application


 Download CD Content

The Java API provides the javax.speech and javax.speech.synthesis packages that contain classes, such as SynthesizerModeDesc, SynthesizerProperties, and Voice and interfaces, such as Synthesizer, which help convert text to speech. To convert text to speech, the javax.speech.synthesis package allows you to retrieve and list all the system voices installed on a computer. The javax.speech package provides a class called central, which helps you to locate, select, and create speech recognizers and speech synthesizers.

This chapter describes how to develop a speech-enabled calendar application, which reads out the date, day, and time specified by an end user by using the javax.speech and javax.speech.synthesis packages. To specify the date, the end user selects the required date format. The application also checks the validity of the date specified. If the date is invalid, the application reads out an error message.

Architecture of the Speech-Enabled Calendar Application

The Speech-Enabled Calendar application uses the following files:

  • SelectFormat.java: Allows an end user to choose a date format from the various formats provided by the interface.

  • SpeakText.java: Converts to speech the date, day, and time values that the end user specifies.

  • SpeechCalendar.java: Allows the end user to retrieve current system date, day, and time from the computer.

Figure 2-1 shows the architecture of the Speech-Enabled Calendar application:

click to expand: this figure shows the files that the speech-enabled calendar application uses and the sequence in which the application uses them.
Figure 2-1: Architecture of the Speech-Enabled Calendar Application

The SpeechCalendar.java file allows an end user to retrieve the current date, day, and time from the computer and validates the date entered by the end user. This file also sets the date in the format specified by the end user. If the end user selects the Date option, the application provides an interface with two radio buttons , Current Date and Enter Date. The Current Date option retrieves the current date from the computer and displays it. The Enter Date option prompts the end user to specify a date and checks whether or not the date is in a valid format.

If an end user clicks the Select Date Format button, the SpeechCalendar.java file calls the SelectFormat.java file, which provides the end user with various date formats. An end user can select the required date format. If the end user clicks the Speak button, the SpeechCalendar.java file calls the SpeakText.java file, which retrieves and lists all the types of voices supported by the end user s computer. When an end user selects a voice, the specified date, day, or time is spoken out in that voice.




Java InstantCode. Developing Applications using Java Speech API
Java InstantCode. Developing Applications using Java Speech API
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 46

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net