-
Notifications
You must be signed in to change notification settings - Fork 3.7k
(stt): reset the retry budget on any event, not only on a final transcript #7207
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -538,8 +538,15 @@ async def _metrics_monitor_task(self, event_aiter: AsyncIterable[SpeechEvent]) - | |
| ) | ||
|
|
||
| self._stt.emit("metrics_collected", stt_metrics) | ||
| elif ev.type == SpeechEventType.FINAL_TRANSCRIPT: | ||
| # reset the retry count after a successful recognition | ||
|
|
||
| if ev.type in ( | ||
| SpeechEventType.INTERIM_TRANSCRIPT, | ||
| SpeechEventType.PREFLIGHT_TRANSCRIPT, | ||
| SpeechEventType.FINAL_TRANSCRIPT, | ||
| SpeechEventType.RECOGNITION_USAGE, | ||
| ): | ||
|
Comment on lines
+542
to
+547
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔴 Local usage defeats retry limits Locally generated Learn more
Example: Deepgram establishes a WebSocket, receives no message, and the socket closes. Its cleanup reports the short socket lifetime as usage. Each failed attempt resets Recommended fix: Reset from an explicit successful-connection or provider-message signal. Do not treat Was this helpful? React with 👍 or 👎 to provide feedback. |
||
| # START/END_OF_SPEECH can be synthesized by adapters, so only provider | ||
| # responses prove the underlying recognition connection has recovered. | ||
| self._num_retries = 0 | ||
|
Comment on lines
+542
to
550
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 Immediate responses miss retry reset If Learn moreThe event producer and metrics monitor are separate tasks. Example: With Recommended fix: Make response observation synchronous with retry accounting rather than mutating Was this helpful? React with 👍 or 👎 to provide feedback. |
||
|
|
||
| def push_frame(self, frame: rtc.AudioFrame) -> None: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to put the reset back in
_metrics_monitor_taskand widen it fromFINAL_TRANSCRIPTto other events that verify the connection is health , instead of overridingsend_nowaitin_HealthySignallingChan.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also need to add that for
MultiSpeakerAdapteragents/livekit-agents/livekit/agents/stt/multi_speaker_adapter.py
Lines 143 to 145 in 4de6232
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Devin raised two valid edge cases: usage events can be generated locally, and the monitor can run too late. Would you be comfortable with a small per-attempt recovery marker, set only after a real provider response and checked by the retry logic? That avoids both endless retries and missed recoveries.