Class TrcEmic2TextToSpeech

java.lang.Object
trclib.archive.TrcEmic2TextToSpeech

public abstract class TrcEmic2TextToSpeech extends Object
This class implements a platform independent Emic2 text to speech device that is connected to a Serial Port. This class should be extended by a platform dependent Emic2 device class that provides the asynchronous access to the serial port the device is connected to.
  • Field Details

    • MIN_VOLUME

      public static final int MIN_VOLUME
      See Also:
    • MAX_VOLUME

      public static final int MAX_VOLUME
      See Also:
    • tracer

      private final TrcDbgTrace tracer
    • instanceName

      private final String instanceName
    • configMsg

      private volatile String configMsg
    • versionMsg

      private volatile String versionMsg
    • helpMsg

      private volatile String helpMsg
  • Constructor Details

    • TrcEmic2TextToSpeech

      public TrcEmic2TextToSpeech(String instanceName)
      Constructor: Create an instance of the object.
      Parameters:
      instanceName - specifies the instance name.
  • Method Details

    • asyncReadString

      public abstract void asyncReadString(TrcEmic2TextToSpeech.RequestId requestId)
      This method issues an asynchronous read of a text string from the device.
      Parameters:
      requestId - specifies the ID to identify the request. Can be null if none was provided.
    • asyncWriteString

      public abstract void asyncWriteString(String text, boolean preemptive)
      This method writes the string to the device asynchronously.
      Parameters:
      text - specifies the text string to be written to the device.
      preemptive - specifies true for immediate write without queuing, false otherwise.
    • toString

      public String toString()
      This method returns the instance name.
      Overrides:
      toString in class Object
      Returns:
      instance name.
    • start

      public void start()
      This method is called to start the device in which it would send a read request for the prompt string.
    • speak

      public void speak(String msg)
      This method speaks the specified message.
      Parameters:
      msg - specifies the message to be spoken.
    • playDemoMessage

      public void playDemoMessage(TrcEmic2TextToSpeech.DemoMsg msg)
      This method plays the specified demo message.
      Parameters:
      msg - specifies the demo message.
    • stopPlayback

      public void stopPlayback()
      This method aborts the spoken sentence in progress.
    • togglePlayback

      public void togglePlayback()
      This method is called to pause/resume the spoken sentence in progress.
    • selectVoice

      public void selectVoice(TrcEmic2TextToSpeech.Voice voice)
      This method selects the spoken voice.
      Parameters:
      voice - specifies the voice to be used.
    • setVolume

      public void setVolume(int vol)
      This method sets the speaking volume. Valid value is between -48 to 18.
      Parameters:
      vol - specifies the speaking volume.
    • setVolume

      public void setVolume(double vol)
      This method sets the speaking volume. Valid value is between 0 and 1.0. 0 for mute and 1.0 for full volume.
      Parameters:
      vol - specifies the speaking volume.
    • setSpeakingRate

      public void setSpeakingRate(int rate)
      This method sets the speaking rate in words per minute.
      Parameters:
      rate - specifies the speaking rate.
    • setLanguage

      public void setLanguage(TrcEmic2TextToSpeech.Language lang)
      This method sets the spoken language.
      Parameters:
      lang - specifies the spoken language.
    • selectParser

      public void selectParser(TrcEmic2TextToSpeech.Parser parser)
      This method selects the parser that parses the sentence.
      Parameters:
      parser - specifies the parser to use.
    • revertDefaultConfig

      public void revertDefaultConfig()
      This method sets the text-to-speech back to default configuration.
    • getCurrentConfig

      public String getCurrentConfig(boolean wait)
      This method returns the current text-to-speech configuration.
      Parameters:
      wait - specifies true for synchronous access.
      Returns:
      current configuration string if wait is true, null otherwise.
    • getVersion

      public String getVersion(boolean wait)
      This method returns the firmware version.
      Parameters:
      wait - specifies true for synchronous access.
      Returns:
      firmware version string if wait is true, null otherwise.
    • getHelpMessage

      public String getHelpMessage(boolean wait)
      This method returns the help message.
      Parameters:
      wait - specifies true for synchronous access.
      Returns:
      help message string if wait is true, null otherwise.
    • notify

      protected void notify(Object context)
      This method is called when the read request is completed.
      Parameters:
      context - specifies the read request.