Chapter 5: Creating a Counting Application


 Download CD Content

The Java API provides the javax.speech and javax.speech.synthesis packages to develop an application to count the number of vowels , consonants, words, and sentences in the text provided by an end user . This helps in calculating the word count of a document.

This chapter describes how to develop a Counting application, which provides a user interface containing four buttons to count the number of vowels, consonants, words, and sentences in the specified text. This application converts the count values to speech in the voice selected by an end user.

Architecture of the Counting Application

The Counting application uses the following files:

  • SpeechCounting.java: Allows an end user to specify the text in the text area provided by the interface. This file also counts the number of vowels, consonants, words, and sentences in the specified text.

  • SpeakCounting.java: Converts the count values to speech.

  • SelectVoiceType.java: Allows an end user to select the voice in which the application converts the count values to speech.

Figure 5-1 shows the architecture of the Counting application:

click to expand: this figure shows the files that the counting application uses and the sequence in which the application uses them.
Figure 5-1: Architecture of the Counting Application

The SpeechCounting.java file creates the user interface of the Counting application that contains the File menu and four buttons: Vowel, Consonant, Word, and Sentence .

The File menu allows end users to open an existing file in the text area provided by the interface. An end user can select File->Select Voice to select the required voice. The application uses the selected voice to read out the count values of vowels, consonants, words, and sentences.

The SpeechCounting.java file calls the SelectVoiceType.java file, which provides an interface that contains two radio buttons, Voice 1 and Voice 2, for selecting a voice.

The SpeechCounting.java file calls the SpeakCounting.java file to convert the count values of vowels, consonants, words, and sentences to speech.




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