Speaker
robot.speaker controls the robot's overall hardware volume — separate from any individual media lane's volume (see Audio). These examples assume you already have a connected robot — see Connection if you haven't set one up yet.
Setup
mkdir ~/example
cd ~/example
python -m venv .venv
# or: uv venv .venv
source .venv/bin/activate
pip install luxai-robot
# or: uv pip install luxai-robot
Connect
from luxai.robot.core import Robot
robot = Robot.connect_zmq(robot_id="QTRD000123")
print(f"connected to {robot.robot_id} ({robot.robot_type})")
See Connection for MQTT, WebRTC, and other connection options.
Get and set volume
# Read the current master volume level
vol = robot.speaker.get_volume()
Logger.info(f"Current speaker volume: {vol:.2f}")
# Set the master volume to 80%
robot.speaker.set_volume(0.8)
vol = robot.speaker.get_volume()
Logger.info(f"Volume after set: {vol:.2f}")
# Reduce to 70%
robot.speaker.set_volume(0.7)
Volume isn't perfectly linear
Because of how QTRP's internal audio system handles volume, the perceived loudness doesn't scale evenly with the value you set — for example, going from 0.5 to 0.7 may sound only slightly louder, while going from 0.8 to 0.9 can be a much bigger jump. Worth keeping in mind when picking a default volume or building a volume slider.
Mute and unmute
import time
robot.speaker.mute()
Logger.info("Speaker muted. Waiting 2 seconds...")
time.sleep(2)
robot.speaker.unmute()
Logger.info("Speaker unmuted.")
Next steps
Continue with the Audio tutorial, or see the full robot.speaker namespace in the Python API Reference.