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

import typing

from .. import core
from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
from ..core.request_options import RequestOptions
from ..types.create_custom_voice_out import CreateCustomVoiceOut
from ..types.gender import Gender
from ..types.languages import Languages
from .raw_client import AsyncRawVoiceCloningClient, RawVoiceCloningClient
from .types.list_voices_list_voices_get_response_item import ListVoicesListVoicesGetResponseItem

# this is used as the default value for optional parameters
OMIT = typing.cast(typing.Any, ...)


class VoiceCloningClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawVoiceCloningClient(client_wrapper=client_wrapper)

    @property
    def with_raw_response(self) -> RawVoiceCloningClient:
        """
        Retrieves a raw implementation of this client that returns raw responses.

        Returns
        -------
        RawVoiceCloningClient
        """
        return self._raw_client

    def list_voices(
        self, *, run_id: typing.Optional[int] = None, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.List[ListVoicesListVoicesGetResponseItem]:
        """
        Parameters
        ----------
        run_id : typing.Optional[int]

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        typing.List[ListVoicesListVoicesGetResponseItem]
            Successful Response

        Examples
        --------
        from camb import CambApi

        client = CambApi(
            api_key="YOUR_API_KEY",
        )
        client.voice_cloning.list_voices()
        """
        _response = self._raw_client.list_voices(run_id=run_id, request_options=request_options)
        return _response.data

    def create_custom_voice(
        self,
        *,
        voice_name: str,
        gender: Gender,
        file: core.File,
        run_id: typing.Optional[int] = None,
        description: typing.Optional[str] = OMIT,
        publish_voice_to_market_place: typing.Optional[bool] = OMIT,
        age: typing.Optional[int] = OMIT,
        language: typing.Optional[Languages] = OMIT,
        enhance_audio: typing.Optional[bool] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> CreateCustomVoiceOut:
        """
        Parameters
        ----------
        voice_name : str

        gender : Gender

        file : core.File
            See core.File for more documentation

        run_id : typing.Optional[int]

        description : typing.Optional[str]

        publish_voice_to_market_place : typing.Optional[bool]
            By setting true, you consent to making this voice available for other users in the marketplace.

        age : typing.Optional[int]

        language : typing.Optional[Languages]
            Language of the voice

        enhance_audio : typing.Optional[bool]
            Enables advanced audio processing to enhance the clarity and quality of the cloned voice output. When set to `true`, additional processing is applied to improve the overall sound experience.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        CreateCustomVoiceOut
            Successful Response

        Examples
        --------
        from camb import CambApi

        client = CambApi(
            api_key="YOUR_API_KEY",
        )
        client.voice_cloning.create_custom_voice(
            voice_name="voice_name",
            gender=1,
        )
        """
        _response = self._raw_client.create_custom_voice(
            voice_name=voice_name,
            gender=gender,
            file=file,
            run_id=run_id,
            description=description,
            publish_voice_to_market_place=publish_voice_to_market_place,
            age=age,
            language=language,
            enhance_audio=enhance_audio,
            request_options=request_options,
        )
        return _response.data


class AsyncVoiceCloningClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawVoiceCloningClient(client_wrapper=client_wrapper)

    @property
    def with_raw_response(self) -> AsyncRawVoiceCloningClient:
        """
        Retrieves a raw implementation of this client that returns raw responses.

        Returns
        -------
        AsyncRawVoiceCloningClient
        """
        return self._raw_client

    async def list_voices(
        self, *, run_id: typing.Optional[int] = None, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.List[ListVoicesListVoicesGetResponseItem]:
        """
        Parameters
        ----------
        run_id : typing.Optional[int]

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        typing.List[ListVoicesListVoicesGetResponseItem]
            Successful Response

        Examples
        --------
        import asyncio

        from camb import AsyncCambApi

        client = AsyncCambApi(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.voice_cloning.list_voices()


        asyncio.run(main())
        """
        _response = await self._raw_client.list_voices(run_id=run_id, request_options=request_options)
        return _response.data

    async def create_custom_voice(
        self,
        *,
        voice_name: str,
        gender: Gender,
        file: core.File,
        run_id: typing.Optional[int] = None,
        description: typing.Optional[str] = OMIT,
        publish_voice_to_market_place: typing.Optional[bool] = OMIT,
        age: typing.Optional[int] = OMIT,
        language: typing.Optional[Languages] = OMIT,
        enhance_audio: typing.Optional[bool] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> CreateCustomVoiceOut:
        """
        Parameters
        ----------
        voice_name : str

        gender : Gender

        file : core.File
            See core.File for more documentation

        run_id : typing.Optional[int]

        description : typing.Optional[str]

        publish_voice_to_market_place : typing.Optional[bool]
            By setting true, you consent to making this voice available for other users in the marketplace.

        age : typing.Optional[int]

        language : typing.Optional[Languages]
            Language of the voice

        enhance_audio : typing.Optional[bool]
            Enables advanced audio processing to enhance the clarity and quality of the cloned voice output. When set to `true`, additional processing is applied to improve the overall sound experience.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        CreateCustomVoiceOut
            Successful Response

        Examples
        --------
        import asyncio

        from camb import AsyncCambApi

        client = AsyncCambApi(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.voice_cloning.create_custom_voice(
                voice_name="voice_name",
                gender=1,
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.create_custom_voice(
            voice_name=voice_name,
            gender=gender,
            file=file,
            run_id=run_id,
            description=description,
            publish_voice_to_market_place=publish_voice_to_market_place,
            age=age,
            language=language,
            enhance_audio=enhance_audio,
            request_options=request_options,
        )
        return _response.data
