org.rococoa.contrib.appkit
Class NSSpeechSynthesizer

java.lang.Object
  extended by org.rococoa.cocoa.foundation.NSObject
      extended by org.rococoa.contrib.appkit.NSSpeechSynthesizer
All Implemented Interfaces:
ObjCObject

public abstract class NSSpeechSynthesizer
extends NSObject

Provides access to Cocoa NSSpeechSynthesizer. Methods have been wrapped to take and return natural Java types. Convenience methods and wrapper classes have been implemented for property and NSDictionary based datastructures.


Nested Class Summary
static class NSSpeechSynthesizer._Class
          Represents the Objective C class of the speech synthesizer
static class NSSpeechSynthesizer.NSSpeechBoundary
          Describes boundaries between speech units
static class NSSpeechSynthesizer.NSSpeechCommand
          Desribes how to set the delimiters used to embed commands in text to be spoken
static class NSSpeechSynthesizer.NSSpeechError
          Describes an error that occurred
static class NSSpeechSynthesizer.NSSpeechMode
          Describes the modes a synthesizer can operate in.
static class NSSpeechSynthesizer.NSSpeechPhonemeInfo
          Describes information about phonemes the synthesizer uses
static class NSSpeechSynthesizer.NSSpeechStatus
          Describes the current status of the synthesizer
static interface NSSpeechSynthesizer.NSSpeechSynthesizerDelegate
          Interface to be implemented by Java objects that want to be informed about events reported to the speech syntheszier's delegate
static class NSSpeechSynthesizer.NSSpeechSynthesizerInfo
          Describes identifying information about the synthesizer
static class NSSpeechSynthesizer.SpeechProperty
          Defines the properties associated with a speech synthesizer.
 
Nested classes/interfaces inherited from class org.rococoa.cocoa.foundation.NSObject
NSObject._class_
 
Field Summary
static NSSpeechSynthesizer._Class CLASS
          Represents the Objective C class for NSSpeechSynthesizer
 
Constructor Summary
NSSpeechSynthesizer()
           
 
Method Summary
 void addSpeechDictionary(NSSpeechDictionary dictionary)
          Add a speech dictionary to those in use with this synthesizer
static List<NSVoice> availableVoices()
          Get a list of all available voices
abstract  void continueSpeaking()
          Resume speaking if output was paused
static String createSyncPoint(int marker)
          Create a sync point that can be embeded in speech, to trigger a synchronization callback.
static NSVoice defaultVoice()
          Determine the default voice for this computer, set in system preferences
 NSSpeechSynthesizer.NSSpeechMode getCharacterMode()
          Get the current character mode, whether the synthesizer is currently speaking strings normally or speaking each character literally.
 NSSpeechSynthesizer.NSSpeechSynthesizerDelegate getDelegate()
          Get the current delegate
 NSSpeechSynthesizer.NSSpeechError getError()
          Get the latest error that occurred in the synthesizer
 NSSpeechSynthesizer.NSSpeechMode getInputMode()
          Get the current input mode, whether the synthesizer is currently expecting regular text input or raw phonemes.
 NSSpeechSynthesizer.NSSpeechMode getNumberMode()
          Get the current number mode, whether the synthesizer is currently speaking numbers normally or speaking each digit literally.
 List<NSSpeechSynthesizer.NSSpeechPhonemeInfo> getPhonemeInfo()
          Get a list of phonemes the synthesizer uses
 float getPitchBase()
          Get the baseline pitch for the synthesizer
 float getPitchMod()
          Get the pitch modulation for the synthesizer
 NSObject getProperty(NSSpeechSynthesizer.SpeechProperty property)
          Get the value of a synthesizer property.
 int getRecentSync()
          Get the most recent sync point encountered when speaking
 NSSpeechSynthesizer.NSSpeechStatus getStatus()
          Get the status of the synthesizer
 NSSpeechSynthesizer.NSSpeechSynthesizerInfo getSynthesizerInfo()
          Get identifying information about this synthesizer
 NSVoice getVoice()
          Get the current voice in use
 String getVoiceIdentifier()
          Get the identifier of the current voice
 float getVolume()
          Get the current volume
static boolean isAnyApplicationSpeaking()
          Determine whether any application is currently generating speech through the default output channel at present.
abstract  boolean isSpeaking()
          Determine whether the current application is speaking using the default output channel
 String opcodeToPhoneme(short opcode)
          Convert a phoneme opcode to human readable form
abstract  void pauseSpeakingAtBoundary(NSSpeechSynthesizer.NSSpeechBoundary boundary)
          Pause speech at the indicated boundary
abstract  String phonemesFromText(String text)
          Convert text to phonemes.
abstract  float rate()
          Get the current rate of speech
 void reset()
          Reset the synthesizer to the default settings
 void setCharacterMode(NSSpeechSynthesizer.NSSpeechMode mode)
          Set the current character mode, whether the synthesizer is currently speaking strings normally or speaking each character literally.
 void setCommandDelimiter(NSSpeechSynthesizer.NSSpeechCommand delimiters)
          Set the command delimiter to use
 void setDelegate(NSSpeechSynthesizer.NSSpeechSynthesizerDelegate delegate)
          Set the delegate that will receive events when speech is generated.
 void setInputMode(NSSpeechSynthesizer.NSSpeechMode mode)
          Set the current input mode, whether the synthesizer is currently expecting regular text input or raw phonemes.
 void setNumberMode(NSSpeechSynthesizer.NSSpeechMode mode)
          Set the current number mode, whether the synthesizer is currently speaking numbers normally or speaking each digit literally.
 void setOutputToFileURL(URI uri)
          Set the synthesizer to send output to a file instead of the default output channel
 void setPitchBase(float baselinePitch)
          Set the baseline pitch for the synthesizer
 void setPitchMod(float modulation)
          Set the pitch modulation for the synthesizer
 void setProperty(NSSpeechSynthesizer.SpeechProperty property, NSObject value)
          Set the value of a synthesizer property.
abstract  void setRate(float rate)
          Set the current rate of speech
abstract  void setUsesFeedbackWindow(boolean useFeedbackWindow)
          Set whether the feedback window should be used
 boolean setVoice(NSVoice voice)
          Set the voice to use
abstract  boolean setVoice(String voiceIdentifier)
          Set the voice to use, should be called when the synthesizer is not currently speaking
abstract  void setVolume(float volume)
          Set the volume
abstract  boolean startSpeakingString(String text)
          Start speaking the given string through the default system speech channel
 boolean startSpeakingStringToURL(String text, URI uri)
          Speak the given string to a file
abstract  void stopSpeaking()
          Stop this synthesizer from speaking
abstract  void stopSpeakingAtBoundary(NSSpeechSynthesizer.NSSpeechBoundary boundary)
          Stop this synthesizer from speaking when it reaches the indicated place.
static NSSpeechSynthesizer synthesizerWithVoice(NSVoice voice)
          Construct a new synthesizer that speaks with a specified voice.
static NSSpeechSynthesizer synthesizerWithVoiceIdentifier(String voiceIdentifer)
          Construct a new synthesizer that speaks with a specified voice.
abstract  boolean usesFeedbackWindow()
          Get whether the feedback window is enabled
 
Methods inherited from class org.rococoa.cocoa.foundation.NSObject
description, isKindOfClass, isKindOfClass, release, retain, retainCount
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.rococoa.ObjCObject
id
 

Field Detail

CLASS

public static final NSSpeechSynthesizer._Class CLASS
Represents the Objective C class for NSSpeechSynthesizer

Constructor Detail

NSSpeechSynthesizer

public NSSpeechSynthesizer()
Method Detail

synthesizerWithVoiceIdentifier

public static NSSpeechSynthesizer synthesizerWithVoiceIdentifier(String voiceIdentifer)
                                                          throws IllegalArgumentException
Construct a new synthesizer that speaks with a specified voice.

Parameters:
voiceIdentifer - the identifier of the voice to use
Returns:
the newly created synthesizer
Throws:
IllegalArgumentException - if the identifier is invalid or the voice indicated is not installed

synthesizerWithVoice

public static NSSpeechSynthesizer synthesizerWithVoice(NSVoice voice)
Construct a new synthesizer that speaks with a specified voice.

Parameters:
voice - the voice to use, or null to use the defalt voice
Returns:
the newly created synthesizer
Throws:
IllegalArgumentException - if the voice is invalid or not installed

defaultVoice

public static NSVoice defaultVoice()
Determine the default voice for this computer, set in system preferences

Returns:
the system default voice

availableVoices

public static List<NSVoice> availableVoices()
Get a list of all available voices

Returns:
a list of available voices

isAnyApplicationSpeaking

public static boolean isAnyApplicationSpeaking()
Determine whether any application is currently generating speech through the default output channel at present.

Returns:
true if the default speech output channel is in use

setDelegate

public void setDelegate(NSSpeechSynthesizer.NSSpeechSynthesizerDelegate delegate)
Set the delegate that will receive events when speech is generated.

Parameters:
delegate - the delegate to set, replacing any existing one

getDelegate

public NSSpeechSynthesizer.NSSpeechSynthesizerDelegate getDelegate()
Get the current delegate

Returns:
the delegate

opcodeToPhoneme

public String opcodeToPhoneme(short opcode)
Convert a phoneme opcode to human readable form

Parameters:
opcode - the phoneme code to convert
Returns:
the corresponding readable string

createSyncPoint

public static String createSyncPoint(int marker)
Create a sync point that can be embeded in speech, to trigger a synchronization callback.

Parameters:
marker - the marker number for the sync point
Returns:
a sync point marker that can be embeded in a string to be spoken

getProperty

public NSObject getProperty(NSSpeechSynthesizer.SpeechProperty property)
                     throws IllegalArgumentException
Get the value of a synthesizer property.

Parameters:
property - the property whose value should be retrieved
Returns:
the value asociated with the property
Throws:
IllegalArgumentException - if an error occurs while reading the property

setProperty

public void setProperty(NSSpeechSynthesizer.SpeechProperty property,
                        NSObject value)
                 throws IllegalArgumentException
Set the value of a synthesizer property.

Parameters:
property - the property whose value will be set
value - the value to set
Throws:
IllegalArgumentException - if an error occurs while setting the property

addSpeechDictionary

public void addSpeechDictionary(NSSpeechDictionary dictionary)
Add a speech dictionary to those in use with this synthesizer

Parameters:
dictionary - the dictionary to add

getStatus

public NSSpeechSynthesizer.NSSpeechStatus getStatus()
Get the status of the synthesizer

Returns:
the current status of the synthesizer

getError

public NSSpeechSynthesizer.NSSpeechError getError()
Get the latest error that occurred in the synthesizer

Returns:
the latest error to occur

getInputMode

public NSSpeechSynthesizer.NSSpeechMode getInputMode()
Get the current input mode, whether the synthesizer is currently expecting regular text input or raw phonemes.

Returns:
either NSSpeechMode.Text or NSSpeechMode.Phoneme depending on the current mode

setInputMode

public void setInputMode(NSSpeechSynthesizer.NSSpeechMode mode)
Set the current input mode, whether the synthesizer is currently expecting regular text input or raw phonemes.

Parameters:
mode - either NSSpeechMode.Text or NSSpeechMode.Phoneme depending on the desired mode

getCharacterMode

public NSSpeechSynthesizer.NSSpeechMode getCharacterMode()
Get the current character mode, whether the synthesizer is currently speaking strings normally or speaking each character literally.

Returns:
either NSSpeechMode.Normal or NSSpeechMode.Literal depending on the current mode

setCharacterMode

public void setCharacterMode(NSSpeechSynthesizer.NSSpeechMode mode)
Set the current character mode, whether the synthesizer is currently speaking strings normally or speaking each character literally.

Parameters:
mode - either NSSpeechMode.Normal or NSSpeechMode.Literal depending on the desired mode

getNumberMode

public NSSpeechSynthesizer.NSSpeechMode getNumberMode()
Get the current number mode, whether the synthesizer is currently speaking numbers normally or speaking each digit literally.

Returns:
either NSSpeechMode.Normal or NSSpeechMode.Literal depending on the current mode

setNumberMode

public void setNumberMode(NSSpeechSynthesizer.NSSpeechMode mode)
Set the current number mode, whether the synthesizer is currently speaking numbers normally or speaking each digit literally.

Parameters:
mode - either NSSpeechMode.Normal or NSSpeechMode.Literal depending on the desired mode

getSynthesizerInfo

public NSSpeechSynthesizer.NSSpeechSynthesizerInfo getSynthesizerInfo()
Get identifying information about this synthesizer

Returns:
information that identifies this synthesizer

getPitchBase

public float getPitchBase()
Get the baseline pitch for the synthesizer

Returns:
the baseline pitch

setPitchBase

public void setPitchBase(float baselinePitch)
Set the baseline pitch for the synthesizer

Parameters:
baselinePitch - the baseline pitch to use

getPitchMod

public float getPitchMod()
Get the pitch modulation for the synthesizer

Returns:
the pitch modulation

setPitchMod

public void setPitchMod(float modulation)
Set the pitch modulation for the synthesizer

Parameters:
modulation - the pitch modulation to use

getPhonemeInfo

public List<NSSpeechSynthesizer.NSSpeechPhonemeInfo> getPhonemeInfo()
Get a list of phonemes the synthesizer uses

Returns:
information about the phonemes the synthesizer uses

getRecentSync

public int getRecentSync()
Get the most recent sync point encountered when speaking

Returns:
the identifying number of the most recent sync point

setVoice

public boolean setVoice(NSVoice voice)
Set the voice to use

Parameters:
voice - the new voice to use
Returns:
true if the voice change was successful

getVoice

public NSVoice getVoice()
Get the current voice in use

Returns:
the voice in use

setCommandDelimiter

public void setCommandDelimiter(NSSpeechSynthesizer.NSSpeechCommand delimiters)
Set the command delimiter to use

Parameters:
delimiters - the delimiters to use when embedding commands in speech

reset

public void reset()
Reset the synthesizer to the default settings


setOutputToFileURL

public void setOutputToFileURL(URI uri)
Set the synthesizer to send output to a file instead of the default output channel

Parameters:
uri - a file URI to send output to, pass null to switch back to the computer speakers

startSpeakingStringToURL

public boolean startSpeakingStringToURL(String text,
                                        URI uri)
Speak the given string to a file

Parameters:
text - the text to speak
uri - a file URI indicating where to send output to
Returns:
true if the synthesis began successfully

continueSpeaking

public abstract void continueSpeaking()
Resume speaking if output was paused


isSpeaking

public abstract boolean isSpeaking()
Determine whether the current application is speaking using the default output channel

Returns:
true if the current application is speaking

pauseSpeakingAtBoundary

public abstract void pauseSpeakingAtBoundary(NSSpeechSynthesizer.NSSpeechBoundary boundary)
Pause speech at the indicated boundary

Parameters:
boundary - the place to stop speech

phonemesFromText

public abstract String phonemesFromText(String text)
Convert text to phonemes.

Parameters:
text - the text to convert
Returns:
the corresponding phonemes

rate

public abstract float rate()
Get the current rate of speech

Returns:
the current rate of speech

setRate

public abstract void setRate(float rate)
Set the current rate of speech

Parameters:
rate - the rate to use

setUsesFeedbackWindow

public abstract void setUsesFeedbackWindow(boolean useFeedbackWindow)
Set whether the feedback window should be used

Parameters:
useFeedbackWindow - pass true to enable the feedback window

setVoice

public abstract boolean setVoice(String voiceIdentifier)
Set the voice to use, should be called when the synthesizer is not currently speaking

Parameters:
voiceIdentifier - the identifier of the voice to use
Returns:
true if the voice change was successful

setVolume

public abstract void setVolume(float volume)
Set the volume

Parameters:
volume - the volume to use

startSpeakingString

public abstract boolean startSpeakingString(String text)
Start speaking the given string through the default system speech channel

Parameters:
text - the text to speak
Returns:
true if synthesis starts successfully

stopSpeaking

public abstract void stopSpeaking()
Stop this synthesizer from speaking


stopSpeakingAtBoundary

public abstract void stopSpeakingAtBoundary(NSSpeechSynthesizer.NSSpeechBoundary boundary)
Stop this synthesizer from speaking when it reaches the indicated place.

Parameters:
boundary - the place to stop speaking

usesFeedbackWindow

public abstract boolean usesFeedbackWindow()
Get whether the feedback window is enabled

Returns:
true if the feedback window is enabled

getVoiceIdentifier

public String getVoiceIdentifier()
Get the identifier of the current voice

Returns:
the identifier of the current voice

getVolume

public float getVolume()
Get the current volume

Returns:
the current volume


Copyright © 2012. All Rights Reserved.