Libraries.Sound.Speech Documentation

The speech class does effectively the same thing as the say command in Quorum, except that it provides for more advanced functionality. Specifically, by using the speech class, you can change the volume, pitch, speed, and other properties of the current text-to-speech engine. You can also issue blocking calls, that prevent the program from taking other action until the speaking is complete.

Example Code

use Libraries.Sound.Speech
class Main
action Main
   //Gain access to the speech object
   Speech speech

   //Get the current volume
   number volume = speech:GetVolume()
   number speed = speech:GetSpeed()
   number pitch = speech:GetPitch()

   //issue a blocking speech call
   speech:Say("Hello, world!", true)
end
end

Inherits from: Libraries.Language.Object

Actions Documentation

CanBlock()

Determines whether or not the currently loaded text-to-speech engine can issue a speech blocking call.

Return

boolean: whether the speech engine can block.

Example

Speech speech
boolean block = speech:CanBlock()

CanPause()

Determines whether or not the currently loaded text-to-speech engine can issue a speech pause call.

Return

boolean: whether the speech engine can pause.

Example

Speech speech
boolean pause = speech:CanPause()

CanResume()

Determines whether or not the currently loaded text-to-speech engine can issue a speech resume call. This only matters if the speech engine is currently paused.

Return

boolean: whether the speech engine can resume from a pause.

Example

Speech speech
boolean resume = speech:CanResume()

CanSetSpeed()

Determines whether or not the currently loaded text-to-speech engine can have its speed changed.

Return

boolean: whether the speech engine can have a speed change.

Example

Speech speech
boolean speed = speech:CanSetSpeed()

CanSetVoice()

Determines whether or not the currently loaded text-to-speech engine can have its voice changed.

Return

boolean: whether the speech engine can have a voice change.

Example

Speech speech
boolean voice = speech:CanSetVoice()

CanSetVolume()

Determines whether or not the currently loaded text-to-speech engine can have its volume changed.

Return

boolean: whether the speech engine can have a volume change.

Example

Speech speech
boolean volume = speech:CanSetVolume()

Compare(Libraries.Language.Object object)

This action compares two object hash codes and returns an integer. The result is larger if this hash code is larger than the object passed as a parameter, smaller, or equal. In this case, -1 means smaller, 0 means equal, and 1 means larger. This action was changed in Quorum 7 to return an integer, instead of a CompareResult object, because the previous implementation was causing efficiency issues.

Parameters

Return

integer: The Compare result, Smaller, Equal, or Larger.

Example

Object o
Object t
integer result = o:Compare(t) //1 (larger), 0 (equal), or -1 (smaller)

Equals(Libraries.Language.Object object)

This action determines if two objects are equal based on their hash code values.

Parameters

Return

boolean: True if the hash codes are equal and false if they are not equal.

Example

use Libraries.Language.Object
use Libraries.Language.Types.Text
Object o
Text t
boolean result = o:Equals(t)

GetHashCode()

This action gets the hash code for an object.

Return

integer: The integer hash code of the object.

Example

Object o
integer hash = o:GetHashCode()

GetPitch()

Sets the current pitch of the text-to-speech engine. The legal values are from 0.0, lowest pitch, to 1.0 maximum pitch.

Return

number: The current pitch on the system.

Example

Speech speech
number pitch = speech:GetPitch()

GetSpeed()

Sets the current speed of the text-to-speech engine. The legal values are from 0.0, lowest speed, to 1.0 maximum speed. Each speech engine implementation calculates speed slightly different, but this speech engine should sound approximately equal across implementations.

Return

number: The current volume on the system.

Example

Speech speech
number speed = speech:GetSpeed()

GetVolume()

Sets the current volume of the text-to-speech engine. The legal values are from 0.0, no volume, to 1.0 maximum volume.

Return

number: The current volume on the system.

Example

Speech speech
number volume = speech:GetVolume()

Say(text value)

Instructs the system to speak a particular phrase through the current text-to-speech engine.

Parameters

  • text value: The text to be spoken.

Example

Speech speech
speech:Say("Hello, World!")

Say(text value, boolean block)

Instructs the system to speak a particular phrase through the current text-to-speech engine.

Parameters

  • text value: The text to be spoken.
  • boolean block: Whether or not this is a blocking call, which will cause the rest of the program to pause as it is executed.

Example

Speech speech
speech:Say("Hello, World!")

SetPitch(number value)

Sets the current pitch of the text-to-speech engine. The legal values are from 0.0, lowest pitch, to 1.0 maximum pitch.

Parameters

  • number value: The new pitch.

Example

Speech speech
speech:SetPitch(1.0)

SetSpeed(number value)

Sets the current speed of the text-to-speech engine. The legal values are from 0.0, slowest speed, to 1.0 maximum speed. Each speech engine implementation calculates speed slightly different, but this speech engine should sound approximately equal across implementations.

Parameters

  • number value: The new volume

Example

Speech speech
speech:SetSpeed(1.0)

SetVolume(number value)

Sets the current volume of the text-to-speech engine. The legal values are from 0.0, no volume, to 1.0 maximum volume.

Parameters

  • number value: The new volume

Example

Speech speech
speech:SetVolume(1.0)