From 70033ae00ba18a05909650fd3b3cd769a47d5fe6 Mon Sep 17 00:00:00 2001 From: Mark Backman Date: Wed, 23 Apr 2025 17:17:46 -0400 Subject: [PATCH] fix: SmartTurnMetricsData was reporting 0 for inference and processing time --- CHANGELOG.md | 7 +++++++ src/pipecat/audio/turn/smart_turn/base_smart_turn.py | 9 +++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a8fee8db6..bbea043a5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,13 @@ All notable changes to **Pipecat** will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [Unreleased] + +### Fixed + +- Fixed an issue where the `SmartTurnMetricsData` was reporting 0ms for + inference and processing time when using the `FalSmartTurnAnalyzer`. + ## [0.0.65] - 2025-04-23 "Sant Jordi's release" https://en.wikipedia.org/wiki/Saint_George%27s_Day_in_Catalonia diff --git a/src/pipecat/audio/turn/smart_turn/base_smart_turn.py b/src/pipecat/audio/turn/smart_turn/base_smart_turn.py index a45ac87e6..e7f30246a 100644 --- a/src/pipecat/audio/turn/smart_turn/base_smart_turn.py +++ b/src/pipecat/audio/turn/smart_turn/base_smart_turn.py @@ -149,13 +149,18 @@ class BaseSmartTurn(BaseTurnAnalyzer): # Calculate processing time e2e_processing_time_ms = (end_time - start_time) * 1000 + # Extract metrics from the nested structure + metrics = result.get("metrics", {}) + inference_time = metrics.get("inference_time", 0) + total_time = metrics.get("total_time", 0) + # Prepare the result data result_data = SmartTurnMetricsData( processor="BaseSmartTurn", is_complete=result["prediction"] == 1, probability=result["probability"], - inference_time_ms=result.get("inference_time", 0) * 1000, - server_total_time_ms=result.get("total_time", 0) * 1000, + inference_time_ms=inference_time * 1000, + server_total_time_ms=total_time * 1000, e2e_processing_time_ms=e2e_processing_time_ms, )