Merge pull request #3480 from pipecat-ai/pk/fix-grok-realtime-smallwebrtc

Fix an issue where Grok Realtime would error out when running with Sm…
This commit is contained in:
kompfner
2026-01-16 15:46:27 -05:00
committed by GitHub
2 changed files with 9 additions and 0 deletions

1
changelog/3480.fixed.md Normal file
View File

@@ -0,0 +1 @@
- Fixed an issue where Grok Realtime would error out when running with SmallWebRTC transport.

View File

@@ -752,6 +752,14 @@ class GrokRealtimeLLMService(LLMService):
async def _send_user_audio(self, frame):
"""Send user audio to Grok."""
# Don't send audio if conversation setup is still pending, as it can
# lead to errors. For example: audio sent before conversation setup
# will be interpreted as having Grok's default sample rate (24000),
# and if that differs from the sample rate we eventually set through
# the conversation setup, Grok will error out.
if self._llm_needs_conversation_setup:
return
payload = base64.b64encode(frame.audio).decode("utf-8")
await self.send_client_event(events.InputAudioBufferAppendEvent(audio=payload))