From a14d00b8069205a1f761a6109e49aeceabf9e47f Mon Sep 17 00:00:00 2001 From: Marcus <111281783+marcus-daily@users.noreply.github.com> Date: Thu, 6 Nov 2025 19:42:05 +0000 Subject: [PATCH] Improved LocalSmartTurnAnalyzerV3 performance on systems with a low CPU count (#2982) --- CHANGELOG.md | 3 +++ src/pipecat/audio/turn/smart_turn/local_smart_turn_v3.py | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 649424eec..f0b16df29 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -64,6 +64,9 @@ reason")`. - Added support for passing in an `LLMSwicher` to `MCPClient.register_tools()` (as well as the new `MCPClient.register_tools_schema()`). +- Added `cpu_count` parameter to `LocalSmartTurnAnalyzerV3`. This is set to `1` + by default for more predictable performance on low-CPU systems. + ### Changed - `STTMuteFilter` no longer sends `STTMuteFrame` to the STT service. The filter diff --git a/src/pipecat/audio/turn/smart_turn/local_smart_turn_v3.py b/src/pipecat/audio/turn/smart_turn/local_smart_turn_v3.py index ec60c293a..08b9f3cd1 100644 --- a/src/pipecat/audio/turn/smart_turn/local_smart_turn_v3.py +++ b/src/pipecat/audio/turn/smart_turn/local_smart_turn_v3.py @@ -35,12 +35,15 @@ class LocalSmartTurnAnalyzerV3(BaseSmartTurn): enabling offline operation without network dependencies. """ - def __init__(self, *, smart_turn_model_path: Optional[str] = None, **kwargs): + def __init__( + self, *, smart_turn_model_path: Optional[str] = None, cpu_count: int = 1, **kwargs + ): """Initialize the local ONNX smart-turn-v3 analyzer. Args: smart_turn_model_path: Path to the ONNX model file. If this is not set, the bundled smart-turn-v3.0 model will be used. + cpu_count: The number of CPUs to use for inference. Defaults to 1. **kwargs: Additional arguments passed to BaseSmartTurn. """ super().__init__(**kwargs) @@ -70,6 +73,7 @@ class LocalSmartTurnAnalyzerV3(BaseSmartTurn): so = ort.SessionOptions() so.execution_mode = ort.ExecutionMode.ORT_SEQUENTIAL so.inter_op_num_threads = 1 + so.intra_op_num_threads = cpu_count so.graph_optimization_level = ort.GraphOptimizationLevel.ORT_ENABLE_ALL self._feature_extractor = WhisperFeatureExtractor(chunk_length=8)