Chapter 3: Creating a Voice Synthesizer Application


 Download CD Content

The Java Speech API provides the javax.speech package that contains various classes and interfaces, such as the Central, EngineList and EngineModeDesc classes and the Engine interface. The Central class helps you locate, select, and create speech recognizers and speech synthesizers. The EngineList class helps you select speech engines and contains a set of EngineModeDesc class objects. The EngineModeDesc class provides information about the speech engine, such as locale and mode of operation of the speech engine.

This chapter describes how to develop the Voice Synthesizer application that converts text to speech by using the javax.speech and javax.speech.synthesis packages. In this application, end users can select the required voice for speech conversion.

Architecture of the Voice Synthesizer Application

The Voice Synthesizer application provides an interface that allows end users to create a text file or open an existing file in the text area provided by the interface. This application retrieves and lists all the voices that an end user s computer supports. This application converts the text specified in the text area to speech by using the voice selected by the end user .

The Voice Synthesizer application uses the following files:

  • TextPad.java: Creates the user interface for the Voice Synthesizer application. This file also sets the voice of the synthesizer to read out the written text.

  • SelectVoice.java: Helps an end user to select the voice that the synthesizer uses to read out the text.

  • SpeakText.java: Converts text to speech by using the voice selected by an end user.

Figure 3-1 shows the architecture of the Voice Synthesizer application:

click to expand: this figure shows the files that the voice synthesizer application uses and the sequence in which the application uses them.
Figure 3-1: Architecture of the Voice Synthesizer Application

The TextPad.java file creates the user interface of the Voice Synthesizer application that contains the File and Voice menus . The File menu allows end users to create a file to write the required text or to open an existing file.

If an end user selects the Voice-> Select Voice option in the user interface, the TextPad.java file calls the SelectVoice.java file. The SelectVoice.java file retrieves all the voices that the end user s computer supports and allows the end user to select the voice in which the synthesizer reads out the text. The interface of the SelectVoice.java file provides two radio buttons , Voice 1 and Voice 2, for selecting a voice.

After selecting a voice, the end user selects the Speak button and the TextPad.java file calls the SpeakText.java file. The SpeakText.java file converts the text to speech in the voice selected by the end user.




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