Skip to content

Commit d267d64

Browse files
committed
only calculate metrics if there are listeners
1 parent 3630bfe commit d267d64

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

sdk/voice/speechmatics/voice/_client.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -949,8 +949,10 @@ async def _add_speech_fragments(self, message: dict[str, Any], is_final: bool =
949949
}
950950
self._logger.debug(json.dumps(debug_payload))
951951

952-
# Update TTFB
953-
if not is_final:
952+
# Update TTFB (only if there are listeners)
953+
if not is_final and (
954+
self.listeners(AgentServerMessageType.TTFB_METRICS) or self.listeners(AgentServerMessageType.METRICS)
955+
):
954956
self._calculate_ttfb(end_time=payload_end_time)
955957

956958
# Fragments available

0 commit comments

Comments
 (0)