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 |
|
|
Sentences from cognition, e.g. “Table 3, your dragon roll is ready!” |
Provided |
|
|
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
Subscriber callback caches incoming message →
self.msg
.Main loop publishes
self.msg
once/second if present.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
Initialise ROS under
{robot}_speech_gen_node
.Subscribe to upstream speech commands.
Advertise speaker channel.