Merge pull request #3689 from pipecat-ai/aleix/default-smart-turn-stop-strategy

Use TurnAnalyzerUserTurnStopStrategy as default stop strategy
This commit is contained in:
Aleix Conchillo Flaqué
2026-02-09 12:07:16 -08:00
committed by GitHub
6 changed files with 20 additions and 8 deletions

View File

@@ -39,6 +39,7 @@ jobs:
--extra google \ --extra google \
--extra langchain \ --extra langchain \
--extra livekit \ --extra livekit \
--extra local-smart-turn-v3 \
--extra piper \ --extra piper \
--extra websocket --extra websocket

View File

@@ -43,6 +43,7 @@ jobs:
--extra google \ --extra google \
--extra langchain \ --extra langchain \
--extra livekit \ --extra livekit \
--extra local-smart-turn-v3 \
--extra piper \ --extra piper \
--extra websocket --extra websocket

View File

@@ -0,0 +1 @@
- Changed default user turn stop strategy from `TranscriptionUserTurnStopStrategy` to `TurnAnalyzerUserTurnStopStrategy` with `LocalSmartTurnAnalyzerV3`.

View File

@@ -48,7 +48,7 @@ from pipecat.metrics.metrics import MetricsData
from pipecat.processors.frame_processor import FrameDirection, FrameProcessor from pipecat.processors.frame_processor import FrameDirection, FrameProcessor
from pipecat.transports.base_transport import TransportParams from pipecat.transports.base_transport import TransportParams
AUDIO_INPUT_TIMEOUT_SECS = 1.0 AUDIO_INPUT_TIMEOUT_SECS = 0.5
class BaseInputTransport(FrameProcessor): class BaseInputTransport(FrameProcessor):
@@ -449,8 +449,6 @@ class BaseInputTransport(FrameProcessor):
if not audio_received: if not audio_received:
continue continue
logger.debug(f"{self}: audio not received for more than {AUDIO_INPUT_TIMEOUT_SECS}")
################################################################### ###################################################################
# DEPRECATED. # DEPRECATED.
if self._user_speaking: if self._user_speaking:

View File

@@ -9,6 +9,7 @@
from dataclasses import dataclass from dataclasses import dataclass
from typing import List, Optional from typing import List, Optional
from pipecat.audio.turn.smart_turn.local_smart_turn_v3 import LocalSmartTurnAnalyzerV3
from pipecat.turns.user_start import ( from pipecat.turns.user_start import (
BaseUserTurnStartStrategy, BaseUserTurnStartStrategy,
ExternalUserTurnStartStrategy, ExternalUserTurnStartStrategy,
@@ -18,7 +19,7 @@ from pipecat.turns.user_start import (
from pipecat.turns.user_stop import ( from pipecat.turns.user_stop import (
BaseUserTurnStopStrategy, BaseUserTurnStopStrategy,
ExternalUserTurnStopStrategy, ExternalUserTurnStopStrategy,
SpeechTimeoutUserTurnStopStrategy, TurnAnalyzerUserTurnStopStrategy,
) )
@@ -29,7 +30,7 @@ class UserTurnStrategies:
If no strategies are specified, the following defaults are used: If no strategies are specified, the following defaults are used:
start: [VADUserTurnStartStrategy, TranscriptionUserTurnStartStrategy] start: [VADUserTurnStartStrategy, TranscriptionUserTurnStartStrategy]
stop: [SpeechTimeoutUserTurnStopStrategy] stop: [TurnAnalyzerUserTurnStopStrategy(LocalSmartTurnAnalyzerV3)]
Attributes: Attributes:
start: A list of user turn start strategies used to detect when start: A list of user turn start strategies used to detect when
@@ -46,7 +47,7 @@ class UserTurnStrategies:
if not self.start: if not self.start:
self.start = [VADUserTurnStartStrategy(), TranscriptionUserTurnStartStrategy()] self.start = [VADUserTurnStartStrategy(), TranscriptionUserTurnStartStrategy()]
if not self.stop: if not self.stop:
self.stop = [SpeechTimeoutUserTurnStopStrategy()] self.stop = [TurnAnalyzerUserTurnStopStrategy(turn_analyzer=LocalSmartTurnAnalyzerV3())]
@dataclass @dataclass

View File

@@ -24,10 +24,15 @@ from pipecat.frames.frames import (
) )
from pipecat.pipeline.pipeline import Pipeline from pipecat.pipeline.pipeline import Pipeline
from pipecat.processors.aggregators.llm_context import LLMContext from pipecat.processors.aggregators.llm_context import LLMContext
from pipecat.processors.aggregators.llm_response_universal import LLMContextAggregatorPair from pipecat.processors.aggregators.llm_response_universal import (
LLMContextAggregatorPair,
LLMUserAggregatorParams,
)
from pipecat.processors.frame_processor import FrameProcessor from pipecat.processors.frame_processor import FrameProcessor
from pipecat.processors.frameworks.langchain import LangchainProcessor from pipecat.processors.frameworks.langchain import LangchainProcessor
from pipecat.tests.utils import SleepFrame, run_test from pipecat.tests.utils import SleepFrame, run_test
from pipecat.turns.user_stop import SpeechTimeoutUserTurnStopStrategy
from pipecat.turns.user_turn_strategies import UserTurnStrategies
class TestLangchain(unittest.IsolatedAsyncioTestCase): class TestLangchain(unittest.IsolatedAsyncioTestCase):
@@ -65,7 +70,12 @@ class TestLangchain(unittest.IsolatedAsyncioTestCase):
self.mock_proc = self.MockProcessor("token_collector") self.mock_proc = self.MockProcessor("token_collector")
context = LLMContext() context = LLMContext()
context_aggregator = LLMContextAggregatorPair(context) context_aggregator = LLMContextAggregatorPair(
context,
user_params=LLMUserAggregatorParams(
user_turn_strategies=UserTurnStrategies(stop=[SpeechTimeoutUserTurnStopStrategy()])
),
)
pipeline = Pipeline( pipeline = Pipeline(
[context_aggregator.user(), proc, self.mock_proc, context_aggregator.assistant()] [context_aggregator.user(), proc, self.mock_proc, context_aggregator.assistant()]