"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""

from __future__ import annotations
from .apiconverttexttospeechusingcharacterrequest import (
    APIConvertTextToSpeechUsingCharacterRequest,
    APIConvertTextToSpeechUsingCharacterRequestTypedDict,
)
import httpx
from supertone.types import BaseModel
from supertone.utils import FieldMetadata, PathParamMetadata, RequestMetadata
from typing import Dict, List, Optional, Union
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict


class CreateSpeechRequestTypedDict(TypedDict):
    voice_id: str
    api_convert_text_to_speech_using_character_request: (
        APIConvertTextToSpeechUsingCharacterRequestTypedDict
    )


class CreateSpeechRequest(BaseModel):
    voice_id: Annotated[
        str, FieldMetadata(path=PathParamMetadata(style="simple", explode=False))
    ]

    api_convert_text_to_speech_using_character_request: Annotated[
        APIConvertTextToSpeechUsingCharacterRequest,
        FieldMetadata(request=RequestMetadata(media_type="application/json")),
    ]


class PhonemesTypedDict(TypedDict):
    r"""Phoneme timing data with IPA symbols"""

    symbols: NotRequired[List[str]]
    r"""List of IPA phonetic symbols"""
    start_times_seconds: NotRequired[List[float]]
    r"""Start times for each phoneme in seconds"""
    durations_seconds: NotRequired[List[float]]
    r"""Duration for each phoneme in seconds"""


class Phonemes(BaseModel):
    r"""Phoneme timing data with IPA symbols"""

    symbols: Optional[List[str]] = None
    r"""List of IPA phonetic symbols"""

    start_times_seconds: Optional[List[float]] = None
    r"""Start times for each phoneme in seconds"""

    durations_seconds: Optional[List[float]] = None
    r"""Duration for each phoneme in seconds"""


class CreateSpeechResponseBodyTypedDict(TypedDict):
    r"""JSON response with base64 audio and phoneme data (when include_phonemes=true)"""

    audio_base64: str
    r"""Base64 encoded audio data"""
    phonemes: NotRequired[PhonemesTypedDict]
    r"""Phoneme timing data with IPA symbols"""


class CreateSpeechResponseBody(BaseModel):
    r"""JSON response with base64 audio and phoneme data (when include_phonemes=true)"""

    audio_base64: str
    r"""Base64 encoded audio data"""

    phonemes: Optional[Phonemes] = None
    r"""Phoneme timing data with IPA symbols"""


CreateSpeechResponseResultTypedDict = TypeAliasType(
    "CreateSpeechResponseResultTypedDict",
    Union[CreateSpeechResponseBodyTypedDict, httpx.Response, httpx.Response],
)


CreateSpeechResponseResult = TypeAliasType(
    "CreateSpeechResponseResult",
    Union[CreateSpeechResponseBody, httpx.Response, httpx.Response],
)


class CreateSpeechResponseTypedDict(TypedDict):
    headers: Dict[str, List[str]]
    result: CreateSpeechResponseResultTypedDict


class CreateSpeechResponse(BaseModel):
    headers: Dict[str, List[str]]

    result: CreateSpeechResponseResult
