Reasoning Speech Generation

speech_generator.py

Overview

speech_generator.py is a text-to-speech relay: it takes plain UTF-8 sentences from the cognitive layer and republishes them on the loud-speaker channel at a steady 1 Hz. The node is intentionally agnostic about the actual TTS backend—you can plug in Festival, sound_play, a cloud API, or a proprietary amplifier as long as it subscribes to /{robot}/speaker_channel.

Interfaces (strongly-typed, stateless)

Direction

Topic

Message type

Notes

Required

/{robot}/task_speech_command

std_msgs/String

Sentences from cognition, e.g. “Table 3, your dragon roll is ready!”

Provided

/{robot}/speaker_channel

std_msgs/String

Same text, forwarded once every second

Contract

Pre-conditions

  • Upstream publishes valid UTF-8 strings.

Post-conditions

  • Latest received sentence is re-sent every second until a new one arrives.

  • If no sentence has ever been received the node publishes nothing (avoids empty utterances).

Implementation summary

  1. Subscriber callback caches incoming message → self.msg.

  2. Main loop publishes self.msg once/second if present.

  3. Holds no additional state, so the node can be hot-reloaded or replaced in unit tests without side-effects.

class reasoning_speech_generation.SpeechGenerator[source]

Bases: object

Thin, timer-driven republisher that buffers the latest sentence.

msg

Cached sentence; None until the first message arrives.

Type:

std_msgs.msg.String | None

pub_speak

Outgoing channel for TTS drivers.

Type:

rospy.Publisher

  1. Initialise ROS under {robot}_speech_gen_node.

  2. Subscribe to upstream speech commands.

  3. Advertise speaker channel.

publish_msg() None[source]

Forward cached sentence if available.