net.sf.regulus
Class RegClient

java.lang.Object
  extended bynet.sf.regulus.RegClient

public class RegClient
extends java.lang.Object

Class that interfaces to the regserver process.
The RegClient class offers basic functionality for recognition, interpretation and playback.

On object creation a new regserver instance is started, which initiates the recognition engine. After the regserver has initialized it listens for incoming requests.

The RegClient object connects to the regserver. After that recognition/playback related functions are available.

The library assumes that the 'regulus' variable is set (i.e. on the java command line -Djava=${REGULUS}). Default configuration values for the regserver process are defined in ${REGULUS}/RegulusSpeechServer/runtime/regulus.properties


Field Summary
static java.util.logging.Logger logger
           
 int PARAM_TYPE_FLOAT
           
 int PARAM_TYPE_INT
           
 int PARAM_TYPE_STRING
           
 
Constructor Summary
RegClient(int port, java.lang.String recognitionPackageAndConfigParams)
          Starts up a regulus client library along with the regserver
RegClient(int serverPort, java.lang.String regClientConfig, java.lang.String regulusServerCommand, long regulusServerTimeout)
          Deprecated. use Regclient(String) instead
RegClient(java.lang.String recognitionPackageAndConfigParams)
          Starts up a regulus client library along with the regserver
RegClient(java.lang.String serverHost, int serverPort, java.lang.String regClientConfig, java.lang.String regulusServerCommand, long regulusServerTimeout)
          Deprecated. use Regclient(String) instead
 
Method Summary
 void abortPlayback()
          Abort an ongoing playback action
 void abortRecognition()
          Abort an ongoing recognition action
 float getFloatParameter(java.lang.String paramName)
           
 int getIntParameter(java.lang.String paramName)
           
 java.lang.Object getParameter(java.lang.String paramName)
           
 java.lang.String getRegulusBaseDirectory()
           
 java.lang.String getStringParameter(java.lang.String paramName)
           
 RegResult interpret(java.lang.String grammar, java.lang.String text)
          Perform Natural Language (NL) interpretation.
 void play(java.lang.String fileOrTTS)
          Initiate a playback action.
 void playList(java.lang.String[] fileOrTTSList)
          Initiate a playback action.
 RegResult recognize(java.lang.String grammar)
          Perform a recognition action.
 RegResult recognizeFile(java.lang.String file, java.lang.String grammar)
          Perform a recognition action on a prerecorded file.
 void setEncoding(java.lang.String newEncoding)
          Sets the encoding to be used when communicating with the server.
 boolean setParameter(java.lang.String param, java.lang.String value)
          Sets a Nuance parameter.
 void shutdown()
          Exit regserver process, and release held resources.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

public static java.util.logging.Logger logger

PARAM_TYPE_INT

public int PARAM_TYPE_INT

PARAM_TYPE_FLOAT

public int PARAM_TYPE_FLOAT

PARAM_TYPE_STRING

public int PARAM_TYPE_STRING
Constructor Detail

RegClient

public RegClient(java.lang.String serverHost,
                 int serverPort,
                 java.lang.String regClientConfig,
                 java.lang.String regulusServerCommand,
                 long regulusServerTimeout)
          throws java.lang.Exception
Deprecated. use Regclient(String) instead

Parameters:
serverHost - The name (or IP address) of the host where regserver is running
serverPort - The port the regserver is waiting for connections
regClientConfig - Parameters that get passed to the regserver (Nuance recognition client parameters)
regulusServerCommand - Path to the regserver executable
regulusServerTimeout - How long to wait for regserver to start up
Throws:
java.lang.Exception - Connection to the regserver failed.

RegClient

public RegClient(int serverPort,
                 java.lang.String regClientConfig,
                 java.lang.String regulusServerCommand,
                 long regulusServerTimeout)
          throws java.lang.Exception
Deprecated. use Regclient(String) instead

Parameters:
serverPort - The name (or IP address) of the host where regserver is running
regClientConfig - Parameters that get passed to the regserver (Nuance recognition client parameters)
regulusServerCommand - Path to the regserver executable
regulusServerTimeout - How long (in msecs) to wait for regserver to start up
Throws:
java.lang.Exception - Connection to the regserver failed.

RegClient

public RegClient(int port,
                 java.lang.String recognitionPackageAndConfigParams)
          throws java.lang.Exception
Starts up a regulus client library along with the regserver

Parameters:
port - - portnumber of the regserver process.
recognitionPackageAndConfigParams - - Starts with the recognition package to load. May be followed by one or more nuance configuration parameters. May be followed by one or more nuance configuration parameters

RegClient

public RegClient(java.lang.String recognitionPackageAndConfigParams)
          throws RegClientException,
                 java.io.IOException,
                 RegClientException
Starts up a regulus client library along with the regserver

Parameters:
recognitionPackageAndConfigParams - - Starts with the recognition package to load. May be followed by one or more nuance configuration parameters. May be followed by one or more nuance configuration parameters
Method Detail

setEncoding

public void setEncoding(java.lang.String newEncoding)
Sets the encoding to be used when communicating with the server. When the object is created the encoding is set to "iso-8859-1"

Parameters:
newEncoding -

shutdown

public void shutdown()
              throws java.io.IOException
Exit regserver process, and release held resources.

Throws:
java.io.IOException

setParameter

public boolean setParameter(java.lang.String param,
                            java.lang.String value)
                     throws java.io.IOException
Sets a Nuance parameter.

Parameters:
param -
value -
Returns:
Returns true if the set parameter command was succesfull.
Throws:
java.io.IOException

play

public void play(java.lang.String fileOrTTS)
          throws java.io.IOException
Initiate a playback action. This function returns after the playback request has been submitted to the underlying platform.

Parameters:
fileOrTTS - If the parameter is a path to a file, it is played directly, otherwise if the string starts with +TTS it is submitted to a speech synthesis engine.
Throws:
java.io.IOException

playList

public void playList(java.lang.String[] fileOrTTSList)
              throws java.io.IOException
Initiate a playback action. This function returns after the playback request has been submitted to the underlying platform.

Parameters:
fileOrTTSList - If the item is a path to a file, it is played directly, otherwise if the string starts with +TTS it is submitted to a speech synthesis engine.
Throws:
java.io.IOException

getFloatParameter

public float getFloatParameter(java.lang.String paramName)
                        throws java.io.IOException,
                               RegClientException
Throws:
java.io.IOException
RegClientException

getIntParameter

public int getIntParameter(java.lang.String paramName)
                    throws java.io.IOException,
                           RegClientException
Throws:
java.io.IOException
RegClientException

getStringParameter

public java.lang.String getStringParameter(java.lang.String paramName)
                                    throws java.io.IOException,
                                           RegClientException
Throws:
java.io.IOException
RegClientException

getParameter

public java.lang.Object getParameter(java.lang.String paramName)
                              throws java.io.IOException,
                                     RegClientException
Throws:
java.io.IOException
RegClientException

recognize

public RegResult recognize(java.lang.String grammar)
                    throws java.io.IOException
Perform a recognition action. This function blocks untill recognition returns. It does however not mean that the value returned will contain a valid recognition result. The result might for example contain an error indication or a timeout.

Parameters:
grammar - Recognition grammar used.
Returns:
Recognition result
Throws:
java.io.IOException

interpret

public RegResult interpret(java.lang.String grammar,
                           java.lang.String text)
                    throws java.io.IOException
Perform Natural Language (NL) interpretation. This function blocks untill interpretation returns.

Parameters:
grammar - The grammar context the input text will be parsed with
text - Input text we want to get interpreted
Returns:
The RegResult object returned will contain a valid interpretation if no error was encountered. Check the result's status before using this object.
Throws:
java.io.IOException

recognizeFile

public RegResult recognizeFile(java.lang.String file,
                               java.lang.String grammar)
                        throws java.io.IOException
Perform a recognition action on a prerecorded file. This function blocks untill recognition returns.

Parameters:
file - Prerecorded file
grammar -
Returns:
The RegResult object returned will contain a valid interpretation if no error was encountered. Check the result's status before using this object.
Throws:
java.io.IOException
See Also:
recognize(String)

abortRecognition

public void abortRecognition()
                      throws java.io.IOException
Abort an ongoing recognition action

Throws:
java.io.IOException

abortPlayback

public void abortPlayback()
                   throws java.io.IOException
Abort an ongoing playback action

Throws:
java.io.IOException

getRegulusBaseDirectory

public java.lang.String getRegulusBaseDirectory()
Returns:
Returns the regulusBaseDirectory.