or run

tessl search
Log in

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/pipecat-ai@0.0.x

docs

audio

dtmf.mdfilters-mixers.mdturn-detection.mdvad.md
core-concepts.mdindex.mdpipeline.mdrunner.mdtransports.mdturns.md
tile.json

tessl/pypi-pipecat-ai

tessl install tessl/pypi-pipecat-ai@0.0.0

An open source framework for building real-time voice and multimodal conversational AI agents with support for speech-to-text, text-to-speech, LLMs, and multiple transport protocols

turn-detection.mddocs/audio/

Turn Detection

Turn detection analyzes conversations to determine when it's appropriate for the bot to speak. It goes beyond simple VAD by considering semantic and contextual cues for natural turn-taking.

Turn Analyzers

BaseTurnAnalyzer

{ .api }
from pipecat.audio.turn.base_turn_analyzer import BaseTurnAnalyzer, BaseTurnParams

class BaseTurnAnalyzer:
    """Base class for turn detection analyzers.

    Analyzes audio and context to determine turn-taking opportunities.

    Methods:
        analyze(audio, context): Analyze for turn opportunity
        reset(): Reset analyzer state

    Example:
        turn_analyzer = SomeTurnAnalyzer()
        should_speak = await turn_analyzer.analyze(audio, context)
    """

    def __init__(self, params: BaseTurnParams):
        """Initialize turn analyzer.

        Args:
            params: Turn detection parameters
        """
        pass

    async def analyze(self, audio: bytes, context: Optional[Dict] = None) -> bool:
        """Analyze for turn opportunity.

        Args:
            audio: Audio bytes
            context: Optional context (transcription, etc.)

        Returns:
            True if bot should take turn
        """
        pass

    def reset(self):
        """Reset analyzer state."""
        pass

Smart Turn Detection

LocalSmartTurnAnalyzer

{ .api }
from pipecat.audio.turn.smart_turn import LocalSmartTurnAnalyzer

class LocalSmartTurnAnalyzer(BaseTurnAnalyzer):
    """Local ML-based turn detection.

    Uses machine learning model to detect turn-taking opportunities
    based on audio and semantic features.

    Example:
        turn_analyzer = LocalSmartTurnAnalyzer()

        transport = DailyTransport(
            params=DailyParams(
                turn_analyzer=turn_analyzer
            )
        )
    """

    def __init__(self):
        pass

LocalSmartTurnV2Analyzer

{ .api }
from pipecat.audio.turn.smart_turn import LocalSmartTurnV2Analyzer

class LocalSmartTurnV2Analyzer(BaseTurnAnalyzer):
    """Smart Turn V2 model.

    Improved turn detection model with better accuracy.

    Example:
        turn_analyzer = LocalSmartTurnV2Analyzer()
    """

    def __init__(self):
        pass

LocalSmartTurnV3Analyzer

{ .api }
from pipecat.audio.turn.smart_turn import LocalSmartTurnV3Analyzer

class LocalSmartTurnV3Analyzer(BaseTurnAnalyzer):
    """Smart Turn V3 ONNX model.

    Latest turn detection model using ONNX runtime.

    Example:
        turn_analyzer = LocalSmartTurnV3Analyzer()
    """

    def __init__(self):
        pass

Usage Patterns

Basic Turn Detection

{ .api }
from pipecat.audio.turn.smart_turn import LocalSmartTurnV3Analyzer
from pipecat.transports.daily import DailyTransport, DailyParams

# Create turn analyzer
turn_analyzer = LocalSmartTurnV3Analyzer()

# Use with transport
transport = DailyTransport(
    room_url="...",
    params=DailyParams(
        audio_in_enabled=True,
        turn_analyzer=turn_analyzer
    )
)

# Turn analyzer determines optimal speaking moments

Combined VAD and Turn Detection

{ .api }
from pipecat.audio.vad.vad_analyzer import SileroVADAnalyzer, VADParams
from pipecat.audio.turn.smart_turn import LocalSmartTurnV3Analyzer

# VAD for speech detection
vad = SileroVADAnalyzer(
    params=VADParams(threshold=0.5)
)

# Turn analyzer for turn-taking
turn_analyzer = LocalSmartTurnV3Analyzer()

transport = DailyTransport(
    params=DailyParams(
        vad_enabled=True,
        vad_analyzer=vad,          # Detects speech
        turn_analyzer=turn_analyzer # Detects turn-taking
    )
)

# VAD: "Is someone speaking?"
# Turn: "Should bot speak now?"

Best Practices

Use Latest Model

{ .api }
# Good: Use latest model
turn_analyzer = LocalSmartTurnV3Analyzer()  # Latest, most accurate

# Okay: V2 for compatibility
turn_analyzer = LocalSmartTurnV2Analyzer()

# Avoid: V1 (deprecated)
turn_analyzer = LocalSmartTurnAnalyzer()  # Old model

Combine with VAD

{ .api }
# Good: VAD + Turn detection
transport = DailyTransport(
    params=DailyParams(
        vad_enabled=True,
        vad_analyzer=vad,
        turn_analyzer=turn_analyzer
    )
)

# Bad: Turn detection without VAD
transport = DailyTransport(
    params=DailyParams(
        vad_enabled=False,
        turn_analyzer=turn_analyzer  # Less effective without VAD
    )
)