# 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 .pronunciation_dictionary_locator import PronunciationDictionaryLocator
from .text_to_dialogue_websocket_voice_input import TextToDialogueWebsocketVoiceInput
from .text_to_dialogue_websocket_voice_settings import TextToDialogueWebsocketVoiceSettings


class TextToDialogueWebsocketClientMessage(UncheckedBaseModel):
    """
    All fields are optional unless noted for the **first** message.

    **First message requirements**
    - `voices`: non-empty array of voice IDs (maximum 10 for `eleven_v3`; exactly 1 for `eleven_v3_conversational`).
    - Credentials if not supplied via `xi-api-key` / `Authorization` headers or `single_use_token` query parameter.

    **Subsequent messages**
    - Do not resend `voices`, `pronunciation_dictionary_locators`, or credential fields.
    """

    inputs: typing.Optional[typing.List[TextToDialogueWebsocketVoiceInput]] = pydantic.Field(default=None)
    """
    Dialogue lines to append for synthesis.
    """

    flush: typing.Optional[bool] = pydantic.Field(default=None)
    """
    Force generation of buffered text without closing the connection.
    """

    close_socket: typing.Optional[bool] = pydantic.Field(default=None)
    """
    Flush buffers, emit remaining audio, send `is_final`, and close the WebSocket.
    """

    keep_alive: typing.Optional[bool] = pydantic.Field(default=None)
    """
    Resets the 20s inactivity timer; performs no synthesis.
    """

    xi_api_key: typing.Optional[str] = pydantic.Field(default=None)
    """
    API key for the first message if not provided via the `xi-api-key` header.
    """

    authorization: typing.Optional[str] = pydantic.Field(default=None)
    """
    Bearer token for the first message if not provided via the `Authorization` header.
    """

    single_use_token: typing.Optional[str] = pydantic.Field(default=None)
    """
    Single-use token for the first message if not provided via the `single_use_token` query parameter.
    """

    voices: typing.Optional[typing.List[str]] = pydantic.Field(default=None)
    """
    Voice IDs to load for the session (first message only, required on first message).
    """

    voice_settings: typing.Optional[TextToDialogueWebsocketVoiceSettings] = pydantic.Field(default=None)
    """
    Optional voice settings (first message only).
    """

    pronunciation_dictionary_locators: typing.Optional[typing.List[PronunciationDictionaryLocator]] = pydantic.Field(
        default=None
    )
    """
    Optional pronunciation dictionaries (first message only).
    """

    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
