From 66ce5fe6bd02b58932255accf779f155df17cc1e Mon Sep 17 00:00:00 2001 From: marcus-daily <111281783+marcus-daily@users.noreply.github.com> Date: Thu, 11 Sep 2025 15:20:06 +0100 Subject: [PATCH] Ruff fixes --- .../turn/smart_turn/local_smart_turn_v3.py | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) 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 169d4813d..2d3eeb102 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 @@ -18,8 +18,8 @@ from loguru import logger from pipecat.audio.turn.smart_turn.base_smart_turn import BaseSmartTurn try: - from transformers import WhisperFeatureExtractor import onnxruntime as ort + from transformers import WhisperFeatureExtractor except ModuleNotFoundError as e: logger.error(f"Exception: {e}") logger.error( @@ -28,14 +28,6 @@ except ModuleNotFoundError as e: raise Exception(f"Missing module: {e}") -def build_session(onnx_path): - so = ort.SessionOptions() - so.execution_mode = ort.ExecutionMode.ORT_SEQUENTIAL - so.inter_op_num_threads = 1 - so.graph_optimization_level = ort.GraphOptimizationLevel.ORT_ENABLE_ALL - return ort.InferenceSession(onnx_path, sess_options=so) - - class LocalSmartTurnAnalyzerV3(BaseSmartTurn): """Local turn analyzer using the smart-turn-v3 ONNX model. @@ -57,8 +49,13 @@ class LocalSmartTurnAnalyzerV3(BaseSmartTurn): logger.debug("Loading Local Smart Turn v3 model...") + so = ort.SessionOptions() + so.execution_mode = ort.ExecutionMode.ORT_SEQUENTIAL + so.inter_op_num_threads = 1 + so.graph_optimization_level = ort.GraphOptimizationLevel.ORT_ENABLE_ALL + self._feature_extractor = WhisperFeatureExtractor(chunk_length=8) - self._session = build_session(smart_turn_model_path) + self._session = ort.InferenceSession(smart_turn_model_path, sess_options=so) logger.debug("Loaded Local Smart Turn v3")