Skip to content

Commit 08003f6

Browse files
committed
Publish user SST text
1 parent 4089270 commit 08003f6

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

coffee_ws/src/coffee_voice_agent/coffee_voice_agent/voice_agent_bridge.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,13 @@ def __init__(self):
7070
callback_group=self.callback_group
7171
)
7272

73+
self.user_speech_pub = self.create_publisher(
74+
String,
75+
'voice_agent/user_speech',
76+
10,
77+
callback_group=self.callback_group
78+
)
79+
7380
self.connected_pub = self.create_publisher(
7481
Bool,
7582
'voice_agent/connected',
@@ -216,6 +223,18 @@ async def _handle_websocket_message(self, message: str):
216223

217224
self.tool_event_pub.publish(tool_msg)
218225

226+
elif message_type == 'USER_SPEECH':
227+
# Handle user speech transcription events
228+
speech_data = data.get('data', {})
229+
user_text = speech_data.get('text', '')
230+
231+
self.get_logger().info(f"User Speech: '{user_text[:50]}{'...' if len(user_text) > 50 else ''}'")
232+
233+
# Publish user speech to ROS2 topic
234+
speech_msg = String()
235+
speech_msg.data = user_text
236+
self.user_speech_pub.publish(speech_msg)
237+
219238
elif message_type == 'ACKNOWLEDGMENT':
220239
# Handle acknowledgment messages from voice agent
221240
status = data.get('status', 'unknown')

coffee_ws/src/coffee_voice_agent/scripts/state/state_manager.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,9 @@ async def handle_conversation_item():
228228
text_lower = user_text.lower()
229229
logger.info(f"🔍 DEBUG: User said: '{user_text}'")
230230

231+
# Send user speech event
232+
await self._send_user_speech_event(user_text)
233+
231234
goodbye_words = ['goodbye', 'thanks', 'that\'s all', 'see you', 'bye']
232235

233236
if any(word in text_lower for word in goodbye_words):
@@ -622,4 +625,15 @@ async def _send_tool_event(self, tool_name: str, status: str, parameters: list =
622625
}
623626
await self.agent._send_websocket_event("TOOL_EVENT", tool_data)
624627
else:
625-
logger.debug(f"Cannot send tool event - no agent WebSocket connection")
628+
logger.debug(f"Cannot send tool event - no agent WebSocket connection")
629+
630+
async def _send_user_speech_event(self, text: str):
631+
"""Send user speech event through agent's WebSocket connection"""
632+
if self.agent and hasattr(self.agent, '_send_websocket_event'):
633+
speech_data = {
634+
"text": text,
635+
"timestamp": datetime.now().isoformat()
636+
}
637+
await self.agent._send_websocket_event("USER_SPEECH", speech_data)
638+
else:
639+
logger.debug(f"Cannot send user speech event - no agent WebSocket connection")

0 commit comments

Comments
 (0)