# This file was auto-generated by Fern from our API Definition.

import typing

import pydantic
from ...core.pydantic_utilities import IS_PYDANTIC_V2
from ...core.unchecked_base_model import UncheckedBaseModel
from .start_agents_request_properties_turn_detection_config_start_of_speech_disabled_config import (
    StartAgentsRequestPropertiesTurnDetectionConfigStartOfSpeechDisabledConfig,
)
from .start_agents_request_properties_turn_detection_config_start_of_speech_keywords_config import (
    StartAgentsRequestPropertiesTurnDetectionConfigStartOfSpeechKeywordsConfig,
)
from .start_agents_request_properties_turn_detection_config_start_of_speech_mode import (
    StartAgentsRequestPropertiesTurnDetectionConfigStartOfSpeechMode,
)
from .start_agents_request_properties_turn_detection_config_start_of_speech_vad_config import (
    StartAgentsRequestPropertiesTurnDetectionConfigStartOfSpeechVadConfig,
)


class StartAgentsRequestPropertiesTurnDetectionConfigStartOfSpeech(UncheckedBaseModel):
    """
    Start of Speech (SoS) detection configuration. Determines when a user begins speaking.
    """

    mode: StartAgentsRequestPropertiesTurnDetectionConfigStartOfSpeechMode = pydantic.Field()
    """
    Start of speech detection mode:
    - `vad`: Based on VAD (Voice Activity Detection). Uses audio signal detection.
    - `keywords`: (Beta) Based on keyword trigger. Conversation begins when the agent detects a specified keyword.
    - `disabled`: Disables start of speech detection. Does not actively trigger new conversation turns.
    """

    vad_config: typing.Optional[StartAgentsRequestPropertiesTurnDetectionConfigStartOfSpeechVadConfig] = pydantic.Field(
        default=None
    )
    """
    VAD configuration. Used when `mode` is `vad`.
    """

    keywords_config: typing.Optional[StartAgentsRequestPropertiesTurnDetectionConfigStartOfSpeechKeywordsConfig] = (
        pydantic.Field(default=None)
    )
    """
    Keywords configuration. Used when `mode` is `keywords`.
    """

    disabled_config: typing.Optional[StartAgentsRequestPropertiesTurnDetectionConfigStartOfSpeechDisabledConfig] = (
        pydantic.Field(default=None)
    )
    """
    Disabled mode configuration. Used when `mode` is `disabled`.
    """

    if IS_PYDANTIC_V2:
        model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True)  # type: ignore # Pydantic v2
    else:

        class Config:
            frozen = True
            smart_union = True
            extra = pydantic.Extra.allow
