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
Summary
Actions Summary Table
Actions | Description |
---|---|
CanBlock() | Determines whether or not the currently loaded text-to-speech engine can issue a speech blocking call. |
CanPause() | Determines whether or not the currently loaded text-to-speech engine can issue a speech pause call. |
CanResume() | Determines whether or not the currently loaded text-to-speech engine can issue a speech resume call. |
CanSetSpeed() | Determines whether or not the currently loaded text-to-speech engine can have its speed changed. |
CanSetVoice() | Determines whether or not the currently loaded text-to-speech engine can have its voice changed. |
CanSetVolume() | Determines whether or not the currently loaded text-to-speech engine can have its volume changed. |
Compare(Libraries.Language.Object object) | This action compares two object hash codes and returns an integer. |
Equals(Libraries.Language.Object object) | This action determines if two objects are equal based on their hash code values. |
GetHashCode() | This action gets the hash code for an object. |
GetPitch() | Sets the current pitch of the text-to-speech engine. |
GetSpeed() | Sets the current speed of the text-to-speech engine. |
GetVolume() | Sets the current volume of the text-to-speech engine. |
Say(text value) | Instructs the system to speak a particular phrase through the current text-to-speech engine. |
Say(text value, boolean block) | Instructs the system to speak a particular phrase through the current text-to-speech engine. |
SetPitch(number value) | Sets the current pitch of the text-to-speech engine. |
SetSpeed(number value) | Sets the current speed of the text-to-speech engine. |
SetVolume(number value) | Sets the current volume of the text-to-speech engine. |
Actions Documentation
CanBlock()
Determines whether or not the currently loaded text-to-speech engine can issue a speech blocking call.
Example Code
Speech speech
boolean block = speech:CanBlock()
Return
boolean: whether the speech engine can block.
CanPause()
Determines whether or not the currently loaded text-to-speech engine can issue a speech pause call.
Example Code
Speech speech
boolean pause = speech:CanPause()
Return
boolean: whether the speech engine can pause.
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.
Example Code
Speech speech
boolean resume = speech:CanResume()
Return
boolean: whether the speech engine can resume from a pause.
CanSetSpeed()
Determines whether or not the currently loaded text-to-speech engine can have its speed changed.
Example Code
Speech speech
boolean speed = speech:CanSetSpeed()
Return
boolean: whether the speech engine can have a speed change.
CanSetVoice()
Determines whether or not the currently loaded text-to-speech engine can have its voice changed.
Example Code
Speech speech
boolean voice = speech:CanSetVoice()
Return
boolean: whether the speech engine can have a voice change.
CanSetVolume()
Determines whether or not the currently loaded text-to-speech engine can have its volume changed.
Example Code
Speech speech
boolean volume = speech:CanSetVolume()
Return
boolean: whether the speech engine can have a volume change.
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.
Example Code
Object o
Object t
integer result = o:Compare(t) //1 (larger), 0 (equal), or -1 (smaller)
Parameters
- Libraries.Language.Object: The object to compare to.
Return
integer: The Compare result, Smaller, Equal, or Larger.
Equals(Libraries.Language.Object object)
This action determines if two objects are equal based on their hash code values.
Example Code
use Libraries.Language.Object
use Libraries.Language.Types.Text
Object o
Text t
boolean result = o:Equals(t)
Parameters
- Libraries.Language.Object: The to be compared.
Return
boolean: True if the hash codes are equal and false if they are not equal.
GetHashCode()
This action gets the hash code for an object.
Example Code
Object o
integer hash = o:GetHashCode()
Return
integer: The integer hash code of the object.
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.
Example Code
Speech speech
number pitch = speech:GetPitch()
Return
number: The current pitch on the system.
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.
Example Code
Speech speech
number speed = speech:GetSpeed()
Return
number: The current volume on the system.
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.
Example Code
Speech speech
number volume = speech:GetVolume()
Return
number: The current volume on the system.
Say(text value)
Instructs the system to speak a particular phrase through the current text-to-speech engine.
Example Code
Speech speech
speech:Say("Hello, World!")
Parameters
- text value: The text to be spoken.
Say(text value, boolean block)
Instructs the system to speak a particular phrase through the current text-to-speech engine.
Example Code
Speech speech
speech:Say("Hello, World!")
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.
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.
Example Code
Speech speech
speech:SetPitch(1.0)
Parameters
- number value: The new pitch.
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.
Example Code
Speech speech
speech:SetSpeed(1.0)
Parameters
- number value: The new volume
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.
Example Code
Speech speech
speech:SetVolume(1.0)
Parameters
- number value: The new volume