ScummVM API documentation
Common::TextToSpeechManager Class Reference

#include <text-to-speech.h>

Public Types

enum  Action {
  INTERRUPT, INTERRUPT_NO_REPEAT, QUEUE, QUEUE_NO_REPEAT,
  DROP
}
 

Public Member Functions

 TextToSpeechManager ()
 
virtual bool say (const U32String &str, Action action)
 
bool say (const String &str, Action action, CodePage charset=kUtf8)
 
bool say (const U32String &str)
 
bool say (const String &str, CodePage charset=kUtf8)
 
virtual bool stop ()
 
virtual bool pause ()
 
virtual bool resume ()
 
virtual bool isSpeaking ()
 
virtual bool isPaused ()
 
virtual bool isReady ()
 
virtual void setVoice (unsigned index)
 
TTSVoice getVoice ()
 
virtual void setRate (int rate)
 
int getRate ()
 
virtual void setPitch (int pitch)
 
int getPitch ()
 
virtual void setVolume (unsigned volume)
 
int getVolume ()
 
virtual void setLanguage (String language)
 
String getLanguage ()
 
Array< TTSVoicegetVoicesArray ()
 
Array< int > getVoiceIndicesByGender (TTSVoice::Gender gender)
 
virtual int getDefaultVoice ()
 
void pushState ()
 
bool popState ()
 
virtual void freeVoiceData (void *data)
 
void enable (bool on)
 

Protected Member Functions

void clearState ()
 
virtual void updateVoices ()
 

Protected Attributes

TTSState_ttsState
 

Detailed Description

The TextToSpeechManager allows speech synthesis.

Constructor & Destructor Documentation

◆ TextToSpeechManager()

Common::TextToSpeechManager::TextToSpeechManager ( )

The constructor sets the language to the translation manager language if USE_TRANSLATION is defined, or english when it isn't defined. It sets the rate, pitch and volume to their middle values.

Member Function Documentation

◆ say() [1/4]

virtual bool Common::TextToSpeechManager::say ( const U32String str,
Action  action 
)
inlinevirtual

Says the given string

Parameters
strThe string to say
actionWhat to do if another string is just being said. Possible actions are: INTERRUPT - interrupts the current speech INTERRUPT_NO_REPEAT - interrupts the speech (deletes the whole queue), if the str is the same as the string currently being said, it lets the current string finish. QUEUE - queues the speech QUEUE_NO_REPEAT - queues the speech only if the str is different than the last string in the queue (or the string, that is currently being said if the queue is empty) DROP - does nothing if there is anything being said at the moment

◆ say() [2/4]

bool Common::TextToSpeechManager::say ( const String str,
Action  action,
CodePage  charset = kUtf8 
)
inline

Says the given string, but strings can have a custom charset here. It will convert to UTF-32 before passing along to the intended method.

◆ say() [3/4]

bool Common::TextToSpeechManager::say ( const U32String str)
inline

Interrupts what's being said and says the given string

Parameters
strThe string to say

◆ say() [4/4]

bool Common::TextToSpeechManager::say ( const String str,
CodePage  charset = kUtf8 
)
inline

Interrupts what's being said and says the given string

Parameters
strThe string to say
charsetThe encoding of the string. It will be converted to UTF-32. It will use UTF-8 by default.

◆ stop()

virtual bool Common::TextToSpeechManager::stop ( )
inlinevirtual

Stops the speech

◆ pause()

virtual bool Common::TextToSpeechManager::pause ( )
inlinevirtual

Pauses the speech

◆ resume()

virtual bool Common::TextToSpeechManager::resume ( )
inlinevirtual

Resumes the speech

Note
On linux, the speech resumes from the beginning of the last speech being said, when pause() was called. On other platforms the speech resumes from exactly where it was paused();

◆ isSpeaking()

virtual bool Common::TextToSpeechManager::isSpeaking ( )
inlinevirtual

Returns true, if the TTS engine is speaking

◆ isPaused()

virtual bool Common::TextToSpeechManager::isPaused ( )
inlinevirtual

Returns true, if the TTS engine is paused

◆ isReady()

virtual bool Common::TextToSpeechManager::isReady ( )
inlinevirtual

Returns true, if the TTS engine is ready to speak (isn't speaking and isn't paused)

◆ setVoice()

virtual void Common::TextToSpeechManager::setVoice ( unsigned  index)
inlinevirtual

Sets a voice to be used by the TTS.

Parameters
indexThe index of the voice inside the _ttsState->_availableVoices array

◆ getVoice()

TTSVoice Common::TextToSpeechManager::getVoice ( )

Returns the voice, that is used right now

◆ setRate()

virtual void Common::TextToSpeechManager::setRate ( int  rate)
inlinevirtual

Sets the speech rate

Parameters
rateInteger between -100 (slowest) and 100 (fastest), 0 is the default

◆ getRate()

int Common::TextToSpeechManager::getRate ( )
inline

Returns the current speech rate

◆ setPitch()

virtual void Common::TextToSpeechManager::setPitch ( int  pitch)
inlinevirtual

Sets the pitch

Parameters
pitchInteger between -100 (lowest) and 100 (highest), 0 is the default

◆ getPitch()

int Common::TextToSpeechManager::getPitch ( )
inline

Returns current speech pitch

◆ setVolume()

virtual void Common::TextToSpeechManager::setVolume ( unsigned  volume)
inlinevirtual

Sets the speech volume

Parameters
volumeVolume as a percentage (0 means muted, 100 means as loud as possible)

◆ getVolume()

int Common::TextToSpeechManager::getVolume ( )
inline

Returns the current voice volume

◆ setLanguage()

virtual void Common::TextToSpeechManager::setLanguage ( String  language)
virtual

Sets the speech language

Parameters
languageThe language identifier as defined by ISO 639-1
Note
After using this method, it is probably a good idea to use setVoice, because voices are usually language specific and so it is set to some platform specific default after switching languages.

◆ getLanguage()

String Common::TextToSpeechManager::getLanguage ( )
inline

Returns the current speech language

◆ getVoicesArray()

Array<TTSVoice> Common::TextToSpeechManager::getVoicesArray ( )
inline

Returns array of available voices for the current language

◆ getVoiceIndicesByGender()

Array<int> Common::TextToSpeechManager::getVoiceIndicesByGender ( TTSVoice::Gender  gender)

Returns array of indices of voices from the _availableVoices array, which have the needed gender.

Parameters
genderGender, which indices should be returned
Returns
Array of indices into _availableVoices

◆ getDefaultVoice()

virtual int Common::TextToSpeechManager::getDefaultVoice ( )
inlinevirtual

returns the index for the default voice.

◆ pushState()

void Common::TextToSpeechManager::pushState ( )

Pushes the current state of the TTS

◆ popState()

bool Common::TextToSpeechManager::popState ( )

Pops the TTS state

◆ freeVoiceData()

virtual void Common::TextToSpeechManager::freeVoiceData ( void *  data)
inlinevirtual

Frees the _data field from TTSVoice

◆ enable()

void Common::TextToSpeechManager::enable ( bool  on)

Enables/disables the TTS


The documentation for this class was generated from the following file: