Aria: ArSpeechSynth Class Reference

- Main Page
- Classes
- Files
- Related Pages

- Alphabetical List
- Class List
- Class Hierarchy
- Class Members

# ArSpeechSynth Class Reference

`#include <ArSpeech.h>`

List of all members.

## Detailed Description

Abstract interface to speech synthesis.

This class defines the abstract interface for speech synthesizers used with Aria. Implementations are provided in the separate ArSpeechSynth_Cepstral and ArSpeechSynth_Festival libraries. This class provides a common-denominator interface. Implementations (especially ArCepstral) may support more features, or behave differently; refer to their documentation for more information.

This class registers one parameter with the global ArConfig object in the "Speech Synthesis" section: The parameter is named "voice" and sets the voice used for speech synthesis, if multiple voices is supported and the new voice can be loaded.

## Public Member Functions
virtual void | addToConfig (ArConfig *config)
| ArSpeechSynth ()
virtual int | getAudioSampleRate ()=0
virtual const char * | getCurrentVoiceName ()=0
ArRetFunctorC< bool, ArSpeechSynth > * | getInitCallback ()
ArFunctorC< ArSpeechSynth > * | getInterruptCallback ()
ArRetFunctor2C< bool, ArSpeechSynth, const char *, const char * > * | getSpeakCallback (void)
virtual std::list< std::string > | getVoiceNames ()=0
virtual bool | init ()
virtual void | interrupt ()=0
virtual void | lock ()
void | setAudioCallback (ArRetFunctor2< bool, ArTypes::Byte2 *, int > *cb)
virtual void | setAudioSampleRate (int rate)=0
virtual bool | setVoice (const char *name)=0
virtual bool | speak (const char *str, const char *voiceParams=NULL)
virtual bool | speak (const char *str, const char *voiceParams, ArRetFunctor2< bool, ArTypes::Byte2 *, int > *audioOutputCB, unsigned short sampleRate=0)=0
virtual bool | speakf (const char *fmt,...)=0
virtual void | unlock ()
## Protected Attributes
ArRetFunctor2< bool, ArTypes::Byte2 *, int > * | myAudioPlaybackCB
| If set, send audio to this callback instead of playing it directly.
ArRetFunctorC< bool, ArSpeechSynth > | myInitCB
ArFunctorC< ArSpeechSynth > | myInterruptCB
ArRetFunctor2C< bool, ArSpeechSynth, const char *, const char * > | mySpeakCB

## Constructor & Destructor Documentation

ArSpeechSynth::ArSpeechSynth | ( |  | ) |

Don't forget to call this from derived classes.

## Member Function Documentation

virtual void ArSpeechSynth::addToConfig | ( | ArConfig * | config | ) | `[virtual]`

Use the given ArConfig object to read parameters such as voice, speaking rate, volume.

virtual const char* ArSpeechSynth::getCurrentVoiceName | ( |  | ) | `[pure virtual]`

Get name of current voice, if set with setVoice (else returns NULL)

ArRetFunctorC<bool, ArSpeechSynth>* ArSpeechSynth::getInitCallback | ( |  | ) |

Returns:
  a functor for init() to use with ArSoundsQueue

ArFunctorC<ArSpeechSynth>* ArSpeechSynth::getInterruptCallback | ( |  | ) |

Returns:
  a functor for interrupt()

ArRetFunctor2C<bool, ArSpeechSynth, const char*, const char*>* ArSpeechSynth::getSpeakCallback | ( | void |  | ) |

Returns:
  a functor for speak() to use with ArSoundsQueue

virtual std::list<std::string> ArSpeechSynth::getVoiceNames | ( |  | ) | `[pure virtual]`

Return a list of available voice names, if possible.

virtual bool ArSpeechSynth::init | ( |  | ) | `[virtual]`

Perform synthesizer initialization, if necessary. You must call this method.

(Subclass implementations should call this method *after* initializing their speech engine.)

virtual void ArSpeechSynth::interrupt | ( |  | ) | `[pure virtual]`

If any speech is currently ongoing, interrupt it.

virtual void ArSpeechSynth::lock | ( | void |  | ) | `[inline, virtual]`

Lock, if neccesary

void ArSpeechSynth::setAudioCallback | ( | ArRetFunctor2< bool, ArTypes::Byte2 *, int > * | cb | ) |

Instead of playing synthesized audio using the synthesizer's internal audio playback, call the given callback when a chunk of audio has been synthesized. Audio is passed to the callback in the first parameter as signed 16-bit samples (PCM16). The sample rate is 16kHz but may be changed with setAudioSampleRate(). The second parameter is the number of samples. The return value from the callback is ignored.

virtual void ArSpeechSynth::setAudioSampleRate | ( | int | rate | ) | `[pure virtual]`

Change audio sample rate (Hz). Normal rate is 16000 Hz. Suggested values are 8000, 16000, or 44400

virtual bool ArSpeechSynth::setVoice | ( | const char * | name | ) | `[pure virtual]`

Set the current voice by name. Replaces fully any previous required voice criteria.

See also:
  getVoiceNames

virtual bool ArSpeechSynth::speak | ( | const char * | str,
|  | const char * | voiceParams = `NULL` |
| ) |  |  | `[virtual]`

Speaks the given text.

Parameters:

  | str | The text to speak.
  | voiceParams | Voice selection criteria expression (implementation-specific)

virtual bool ArSpeechSynth::speak | ( | const char * | str,
|  | const char * | voiceParams,
|  | ArRetFunctor2< bool, ArTypes::Byte2 *, int > * | audioOutputCB,
|  | unsigned short | sampleRate = `0` |
| ) |  |  | `[pure virtual]`

Speaks the given text.

Parameters:

  | str | The text to speak.
  | voiceParams | Voice selection criteria expression (implementation-specific)
  | audioOutputCB | If not NULL, send synthesized audio data to this callback (may be called several times). Otherwise, play using default AudioCallback, or directly out the speakers
  | sampleRate | if given, temporarily use this sample rate for this speech, then restore. If 0, use current sample rate.

virtual bool ArSpeechSynth::speakf | ( | const char * | fmt,
|  |  | ... |
| ) |  |  | `[pure virtual]`

Speaks the given string, using current voice and output settings, taking varargs and a format string (like printf)

virtual void ArSpeechSynth::unlock | ( | void |  | ) | `[inline, virtual]`

Unlock, if neccesary

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

- ArSpeech.h