# 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_end_of_speech import (
    StartAgentsRequestPropertiesTurnDetectionConfigEndOfSpeech,
)
from .start_agents_request_properties_turn_detection_config_start_of_speech import (
    StartAgentsRequestPropertiesTurnDetectionConfigStartOfSpeech,
)


class StartAgentsRequestPropertiesTurnDetectionConfig(UncheckedBaseModel):
    """
    Detailed configuration for conversation turn detection.
    """

    speech_threshold: typing.Optional[float] = pydantic.Field(default=None)
    """
    Voice activity detection sensitivity. Determines the sound level in the audio signal that is considered voice activity. Lower values make it easier for the agent to detect speech, and higher values ignore weak sounds.
    """

    start_of_speech: typing.Optional[StartAgentsRequestPropertiesTurnDetectionConfigStartOfSpeech] = pydantic.Field(
        default=None
    )
    """
    Start of Speech (SoS) detection configuration. Determines when a user begins speaking.
    """

    end_of_speech: typing.Optional[StartAgentsRequestPropertiesTurnDetectionConfigEndOfSpeech] = pydantic.Field(
        default=None
    )
    """
    End of Speech (EoS) detection configuration. Determines when a user ends their speech.
    """

    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
