The speech component is the Computronics text-to-speech interface. It lets a device speak generated audio through the local audio system instead of manually programming tones.
This component is intended for spoken notifications, accessibility helpers, dialog systems, and voice status readouts.
- Repository:
computronics - Component name:
speech - Typical host: robots or other devices equipped with the Computronics speech upgrade
local component = require("component")
local speech = component.speech
if not speech then
error("speech component not installed")
endYou can also access a specific device with component.proxy(address).
- Syntax:
speech.say(text) - Returns:
- Success:
true - Failure:
false, reason
- Success:
- Purpose: Starts speaking the supplied text.
Parameters:
text:string: text to convert into spoken audio.
Behavior:
- The device can only process one phrase at a time.
- If speech is already in progress, the call returns
false, "already processing". - The text length must not exceed
300characters by default. - If no text-to-speech backend is available, the call returns
false, "text-to-speech system not available".
Common failure results:
false, "already processing"false, "text too long"false, "text-to-speech system not available"
Example:
local ok, reason = speech.say("Reactor temperature is stable.")
if not ok then
io.stderr:write("Speech failed: " .. tostring(reason) .. "\n")
end- Syntax:
speech.stop() - Returns:
- Success:
true - Failure:
false, reason
- Success:
- Purpose: Stops the phrase that is currently being spoken.
If the device is idle, it returns false, "not talking".
Example:
local ok, reason = speech.stop()
if not ok and reason ~= "not talking" then
io.stderr:write("Stop failed: " .. tostring(reason) .. "\n")
end- Syntax:
speech.isProcessing() - Returns:
boolean - Purpose: Returns whether the device is currently speaking or still processing speech data.
Example:
while speech.isProcessing() do
os.sleep(0.1)
end- Syntax:
speech.setVolume(volume) - Returns: nothing
- Purpose: Sets the playback volume of the speech box.
Parameters:
volume:number: desired volume. Values lower than0are clamped to0, and values higher than1are clamped to1.
Example:
speech.setVolume(0.8)- The component depends on the installed text-to-speech backend. If that backend is unavailable,
saycannot start. - This interface outputs generated speech audio, not raw phoneme control.
componentsound