Java InstantCode. Developing Applications using Java Speech API

JSAPI Packages

The JSAPI packages contain a number of interfaces and classes to support the speech technology. The packages used in JSAPI are:

To learn more about JSAPI, refer to the link http://java.sun.com/products/java-media/speech/reference/api/index.html.

You can download the free implementation of JSAPI from the following URL:

http://freetts. sourceforge .net/docs/index.php

To install JSAPI, extract the downloaded file, freetts-1.2beta2-bin.zip, in C drive and set the classpath of the lib directory of free implementation by executing the following command at the command prompt:

set classpath = %classpath%;c:\freetts-bin- 1_2_beta\lib\freetts.jar;c:\freetts-bin-1_2_beta\lib\cmulex.jar;c:\freetts-bin-1_2_beta\lib\ jsapi.jar;

The javax.speech Package

The javax.speech package contains classes and interfaces that define how the speech engine functions. A speech engine is a system that manages speech input and output. The javax.speech package defines the basic properties of a speech engine.

The commonly used classes of the javax.speech package are:

The commonly used interfaces of the javax.speech package are:

The AudioEvent Class

The AudioEvent class specifies the events related to audio input for the speech recognizer and audio output for speech synthesis. The AudioEvent class defines a method, paramString(), which returns a parameter string to identify the event occurred. This method is used for debugging and for maintaining event logs.

The Central Class

The Central class allows you to access all the speech input and output functions of a speech engine. This class provides methods to locate, select, and create speech engines, such as speech recognizers and speech synthesizers. A Java application can use a speech engine if the speech engine is registered with the Central class. The various methods declared in the Central class are:

The EngineModeDesc Class

The EngineModeDesc class defines the basic properties of a speech engine that determine the mode of operation, such as Spanish or English dictator. The various methods declared in the EngineModeDesc class are:

The EngineList Class

The EngineList class selects the appropriate speech engine with the help of the methods of the Central class. The EngineList class contains a set of EngineModeDesc class objects. The various methods available in the EngineList class are:

The Engine Interface

The Engine interface is the parent interface for all speech engines. The speech engines derive functions, such as allocation and deallocation of methods, access to EngineProperties and EngineModeDesc classes, and use of the pause() and resume() methods from the Engine interface. Some of the methods defined by the Engine interface are:

The AudioManager Interface

The AudioManager interface allows an application to control and monitor the audio input and output, and other audio-related events, such as start and stop audio. The methods provided by this interface are:

The VocabManager Interface

The VocabManager interface manages words that the speech engine uses. This interface provides information about difficult words to the speech engine. Some of the methods provided by this interface are:

The javax.speech.recognition Package

The javax.speech.recognition package provides classes and interfaces that support speech recognition. This package inherits the basic functioning from the javax.speech package. The speech recognizer is a type of speech engine that has the ability to recognize and convert incoming speech to text.

The commonly used classes of the javax.speech.recognition package are:

The commonly used interfaces of the javax.speech.recognition package are:

The RecognizerModeDesc Class

The RecognizerModeDesc class extends the basic functioning of the EngineModeDesc class with properties specific to a speech recognizer. Some commonly used methods of the RecognizerModeDesc class are:

The Rule Class

The Rule class defines the basic component of the RuleGrammar interface. The methods provided by this class are:

The Recognizer Interface

The Recognizer interface extends the functioning of the Engine interface of the javax.speech package. The Recognizer interface is created by using the createRecognizer() method of the Central class. Some methods defined in the Recognizer interface are:

The Result Interface

The Result interface recognizes the incoming audio that matched an active grammar object, which is an object of the Grammar class. When an incoming speech is recognized, the Result interface provides information, such as sequence of finalized and unfinalized words, matched grammar, and result state. The result state includes UNFINALIZED, ACCEPTED, and REJECTED. A new object of the Result interface is created when the recognizer identifies incoming speech that matches with active grammar. Some methods of the Result interface are:

The javax.speech.synthesis Package

The javax.speech.synthesis package provides classes and interfaces that support synthesis of speech. A speech synthesizer is a speech engine that converts text to speech. A synthesizer is created, selected, and searched through the Central class of the javax.speech package. Some commonly used classes of the javax.speech.synthesis package are:

Some commonly used interfaces of the javax.speech.synthesis package are:

The VoiceClass

The Voice class defines one output voice for the speech synthesizer. The class supports fields, such as GENDER_MALE, GENDER_FEMALE, AGE_CHILD, and AGE_TEENAGER to describe the synthesizer voice. Some methods provided by the Voice class are:

The SynthesizerModeDesc Class

The SynthesizerModeDesc class extends the functioning of the EngineModeDesc class of the javax.speech package. Apart from the engine name, locale, mode name, and running properties inherited from the EngineModeDesc class, the SynthesizerModeDesc class includes two properties, the voice to be loaded when the synthesizer is started and the list of voices provided by the synthesizer. Some methods provided by the SynthesizerModeDesc class are:

The Synthesizer Interface

The Synthesizer interface provides an extension to the Engine interface of the javax.speech package. The Synthesizer interface is created by using the createSynthesizer() method of the Central class. Some methods defined by the Synthesizer interface are:

The SynthesizerProperties Interface

The SynthesizerProperties interface provides an extension to the EngineProperties interface of the javax.speech package. This interface allows you to control the run time properties, such as voice, speech rate, pitch range, and volume. Some methods provided by the SynthesizerProperties interface are:

Категории