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

import typing

import pydantic
from ....core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
from .listen_v1results_channel import ListenV1ResultsChannel
from .listen_v1results_entities_item import ListenV1ResultsEntitiesItem
from .listen_v1results_metadata import ListenV1ResultsMetadata


class ListenV1Results(UniversalBaseModel):
    type: typing.Literal["Results"] = pydantic.Field(default="Results")
    """
    Message type identifier
    """

    channel_index: typing.List[float] = pydantic.Field()
    """
    The index of the channel
    """

    duration: float = pydantic.Field()
    """
    The duration of the transcription
    """

    start: float = pydantic.Field()
    """
    The start time of the transcription
    """

    is_final: typing.Optional[bool] = pydantic.Field(default=None)
    """
    Whether the transcription is final
    """

    speech_final: typing.Optional[bool] = pydantic.Field(default=None)
    """
    Whether the transcription is speech final
    """

    channel: ListenV1ResultsChannel
    metadata: ListenV1ResultsMetadata
    from_finalize: typing.Optional[bool] = pydantic.Field(default=None)
    """
    Whether the transcription is from a finalize message
    """

    entities: typing.Optional[typing.List[ListenV1ResultsEntitiesItem]] = pydantic.Field(default=None)
    """
    Extracted entities from the audio when detect_entities is enabled. Only present in is_final messages. Returns an empty array if no entities are detected
    """

    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
