Speaker

speaker.py

Overview

speaker.py is the last-mile speech relay that takes high-level sentences from the cognitive layer and immediately forwards them to the TTS backend.

Interfaces (strongly-typed, stateless)

Direction

Topic

Semantics

Required

/{robot}/speaker_channel

High-level sentences from cognition

Provided

/{robot}/speaker_output

Identical text for TTS backends (latched)

Contract

Pre-conditions

  • Upstream publishes valid UTF-8 strings on the speaker channel.

Post-conditions

  • Each incoming message is republished exactly once on the output topic.

  • Late subscribers to the latched output still get the last sentence.

Implementation notes

  • Publisher uses latch=True and queue_size=10 to absorb bursts.

  • Callback logs every relayed sentence at INFO level.

  • No additional state is stored.

class speaker.Speaker[source]

Bases: object

Thin ROS node that immediately forwards sentences to the output topic.

  1. Read robot_number from CLI.

  2. Initialise ROS node <robot>_speaker_node.

  3. Advertise latched /speaker_output.

  4. Subscribe to /speaker_channel.

speaker_callback(msg: std_msgs.msg.String) None[source]

Forward msg to the /speaker_output topic immediately.

Parameters:

msg (std_msgs.msg.String) – High-level text from the cognitive layer.