removed old metrics

This commit is contained in:
Sam Sykes
2026-01-26 23:11:25 +00:00
parent fc1444c9d6
commit 3a71865cf4

View File

@@ -598,9 +598,6 @@ class SpeechmaticsSTTService(STTService):
if segments: if segments:
await self._send_frames(segments) await self._send_frames(segments)
# Update metrics
await self._emit_metrics(message.get("metadata", {}).get("processing_time", 0.0))
async def _handle_segment(self, message: dict[str, Any]) -> None: async def _handle_segment(self, message: dict[str, Any]) -> None:
"""Handle AddSegment events. """Handle AddSegment events.
@@ -738,23 +735,33 @@ class SpeechmaticsSTTService(STTService):
# If final, then re-parse into TranscriptionFrame # If final, then re-parse into TranscriptionFrame
if finalized: if finalized:
frames += [ # Do any segments have `is_eou` set to True?
TranscriptionFrame( if (
**attr_from_segment(segment), finalized=segment.get("is_eou", False) any(segment.get("is_eou", False) for segment in segments)
) and self._finalize_requested
for segment in segments ):
] self.confirm_finalize()
# Add the finalized frames
frames += [TranscriptionFrame(**attr_from_segment(segment)) for segment in segments]
# Handle the text (for metrics reporting)
finalized_text = "|".join([s["text"] for s in segments]) finalized_text = "|".join([s["text"] for s in segments])
await self._handle_transcription( await self._handle_transcription(
finalized_text, is_final=True, language=segments[0]["language"] finalized_text, is_final=True, language=segments[0]["language"]
) )
# Log the frames
logger.debug(f"{self} finalized transcript: {[f.text for f in frames]}") logger.debug(f"{self} finalized transcript: {[f.text for f in frames]}")
# Return as interim results (unformatted) # Return as interim results (unformatted)
else: else:
# Add the interim frames
frames += [ frames += [
InterimTranscriptionFrame(**attr_from_segment(segment)) for segment in segments InterimTranscriptionFrame(**attr_from_segment(segment)) for segment in segments
] ]
# Log the frames
logger.debug(f"{self} interim transcript: {[f.text for f in frames]}") logger.debug(f"{self} interim transcript: {[f.text for f in frames]}")
# Send the frames # Send the frames
@@ -811,28 +818,6 @@ class SpeechmaticsSTTService(STTService):
yield ErrorFrame(f"Speechmatics error: {e}") yield ErrorFrame(f"Speechmatics error: {e}")
await self._disconnect() await self._disconnect()
async def _emit_metrics(self, processing_time: float) -> None:
"""Create TTFB metrics.
The TTFB is the seconds between the person speaking and the STT
engine emitting the first partial. This is only calculated at the
start of an utterance.
"""
# Skip if metrics not available
if not self._metrics or processing_time == 0.0:
return
# Calculate time as time.time() - ttfb (which is seconds)
start_time = time.time() - processing_time
# Update internal metrics
self._metrics._start_ttfb_time = start_time
self._metrics._start_processing_time = start_time
# Stop TTFB metrics
await self.stop_ttfb_metrics()
await self.stop_processing_metrics()
# ============================================================================ # ============================================================================
# HELPERS # HELPERS
# ============================================================================ # ============================================================================