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

import typing

from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
from ...core.pagination import AsyncPager, SyncPager
from ...core.request_options import RequestOptions
from ..types.posted_custom_voice_base_voice import PostedCustomVoiceBaseVoice
from ..types.posted_custom_voice_parameters import PostedCustomVoiceParameters
from ..types.return_custom_voice import ReturnCustomVoice
from .raw_client import AsyncRawCustomVoicesClient, RawCustomVoicesClient

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


class CustomVoicesClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawCustomVoicesClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawCustomVoicesClient
        """
        return self._raw_client

    def list_custom_voices(
        self,
        *,
        page_number: typing.Optional[int] = None,
        page_size: typing.Optional[int] = None,
        name: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> SyncPager[ReturnCustomVoice]:
        """
        Fetches a paginated list of **Custom Voices**.

        Refer to our [voices guide](/docs/empathic-voice-interface-evi/configuration/voices) for details on creating a custom voice.

        Parameters
        ----------
        page_number : typing.Optional[int]
            Specifies the page number to retrieve, enabling pagination.

            This parameter uses zero-based indexing. For example, setting `page_number` to 0 retrieves the first page of results (items 0-9 if `page_size` is 10), setting `page_number` to 1 retrieves the second page (items 10-19), and so on. Defaults to 0, which retrieves the first page.

        page_size : typing.Optional[int]
            Specifies the maximum number of results to include per page, enabling pagination. The value must be between 1 and 100, inclusive.

            For example, if `page_size` is set to 10, each page will include up to 10 items. Defaults to 10.

        name : typing.Optional[str]
            Filter to only include custom voices with name.

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

        Returns
        -------
        SyncPager[ReturnCustomVoice]
            Success

        Examples
        --------
        from hume import HumeClient

        client = HumeClient(
            api_key="YOUR_API_KEY",
        )
        response = client.empathic_voice.custom_voices.list_custom_voices()
        for item in response:
            yield item
        # alternatively, you can paginate page-by-page
        for page in response.iter_pages():
            yield page
        """
        return self._raw_client.list_custom_voices(
            page_number=page_number, page_size=page_size, name=name, request_options=request_options
        )

    def create_custom_voice(
        self,
        *,
        name: str,
        base_voice: PostedCustomVoiceBaseVoice,
        parameters: typing.Optional[PostedCustomVoiceParameters] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ReturnCustomVoice:
        """
        Creates a **Custom Voice** that can be added to an [EVI configuration](/reference/empathic-voice-interface-evi/configs/create-config).

        Refer to our [voices guide](/docs/empathic-voice-interface-evi/configuration/voices) for details on creating a custom voice.

        Parameters
        ----------
        name : str
            The name of the Custom Voice. Maximum length of 75 characters. Will be converted to all-uppercase. (e.g., "sample voice" becomes "SAMPLE VOICE")

        base_voice : PostedCustomVoiceBaseVoice
            Specifies the base voice used to create the Custom Voice.

        parameters : typing.Optional[PostedCustomVoiceParameters]
            The specified attributes of a Custom Voice.

            If no parameters are specified then all attributes will be set to their defaults, meaning no modfications will be made to the base voice.

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

        Returns
        -------
        ReturnCustomVoice
            Created

        Examples
        --------
        from hume import HumeClient

        client = HumeClient(
            api_key="YOUR_API_KEY",
        )
        client.empathic_voice.custom_voices.create_custom_voice(
            name="name",
            base_voice="ITO",
        )
        """
        _response = self._raw_client.create_custom_voice(
            name=name, base_voice=base_voice, parameters=parameters, request_options=request_options
        )
        return _response.data

    def get_custom_voice(
        self, id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> ReturnCustomVoice:
        """
        Fetches a specific **Custom Voice** by ID.

        Refer to our [voices guide](/docs/empathic-voice-interface-evi/configuration/voices) for details on creating a custom voice.

        Parameters
        ----------
        id : str
            Identifier for a Custom Voice. Formatted as a UUID.

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

        Returns
        -------
        ReturnCustomVoice
            Success

        Examples
        --------
        from hume import HumeClient

        client = HumeClient(
            api_key="YOUR_API_KEY",
        )
        client.empathic_voice.custom_voices.get_custom_voice(
            id="id",
        )
        """
        _response = self._raw_client.get_custom_voice(id, request_options=request_options)
        return _response.data

    def create_custom_voice_version(
        self,
        id: str,
        *,
        name: str,
        base_voice: PostedCustomVoiceBaseVoice,
        parameters: typing.Optional[PostedCustomVoiceParameters] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ReturnCustomVoice:
        """
        Updates a **Custom Voice** by creating a new version of the **Custom Voice**.

        Refer to our [voices guide](/docs/empathic-voice-interface-evi/configuration/voices) for details on creating a custom voice.

        Parameters
        ----------
        id : str
            Identifier for a Custom Voice. Formatted as a UUID.

        name : str
            The name of the Custom Voice. Maximum length of 75 characters. Will be converted to all-uppercase. (e.g., "sample voice" becomes "SAMPLE VOICE")

        base_voice : PostedCustomVoiceBaseVoice
            Specifies the base voice used to create the Custom Voice.

        parameters : typing.Optional[PostedCustomVoiceParameters]
            The specified attributes of a Custom Voice.

            If no parameters are specified then all attributes will be set to their defaults, meaning no modfications will be made to the base voice.

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

        Returns
        -------
        ReturnCustomVoice
            Created

        Examples
        --------
        from hume import HumeClient

        client = HumeClient(
            api_key="YOUR_API_KEY",
        )
        client.empathic_voice.custom_voices.create_custom_voice_version(
            id="id",
            name="name",
            base_voice="ITO",
        )
        """
        _response = self._raw_client.create_custom_voice_version(
            id, name=name, base_voice=base_voice, parameters=parameters, request_options=request_options
        )
        return _response.data

    def delete_custom_voice(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None:
        """
        Deletes a **Custom Voice** and its versions.

        Refer to our [voices guide](/docs/empathic-voice-interface-evi/configuration/voices) for details on creating a custom voice.

        Parameters
        ----------
        id : str
            Identifier for a Custom Voice. Formatted as a UUID.

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

        Returns
        -------
        None

        Examples
        --------
        from hume import HumeClient

        client = HumeClient(
            api_key="YOUR_API_KEY",
        )
        client.empathic_voice.custom_voices.delete_custom_voice(
            id="id",
        )
        """
        _response = self._raw_client.delete_custom_voice(id, request_options=request_options)
        return _response.data

    def update_custom_voice_name(
        self, id: str, *, name: str, request_options: typing.Optional[RequestOptions] = None
    ) -> str:
        """
        Updates the name of a **Custom Voice**.

        Refer to our [voices guide](/docs/empathic-voice-interface-evi/configuration/voices) for details on creating a custom voice.

        Parameters
        ----------
        id : str
            Identifier for a Custom Voice. Formatted as a UUID.

        name : str
            The name of the Custom Voice. Maximum length of 75 characters. Will be converted to all-uppercase. (e.g., "sample voice" becomes "SAMPLE VOICE")

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

        Returns
        -------
        str
            Success

        Examples
        --------
        from hume import HumeClient

        client = HumeClient(
            api_key="YOUR_API_KEY",
        )
        client.empathic_voice.custom_voices.update_custom_voice_name(
            id="id",
            name="name",
        )
        """
        _response = self._raw_client.update_custom_voice_name(id, name=name, request_options=request_options)
        return _response.data


class AsyncCustomVoicesClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawCustomVoicesClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawCustomVoicesClient
        """
        return self._raw_client

    async def list_custom_voices(
        self,
        *,
        page_number: typing.Optional[int] = None,
        page_size: typing.Optional[int] = None,
        name: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AsyncPager[ReturnCustomVoice]:
        """
        Fetches a paginated list of **Custom Voices**.

        Refer to our [voices guide](/docs/empathic-voice-interface-evi/configuration/voices) for details on creating a custom voice.

        Parameters
        ----------
        page_number : typing.Optional[int]
            Specifies the page number to retrieve, enabling pagination.

            This parameter uses zero-based indexing. For example, setting `page_number` to 0 retrieves the first page of results (items 0-9 if `page_size` is 10), setting `page_number` to 1 retrieves the second page (items 10-19), and so on. Defaults to 0, which retrieves the first page.

        page_size : typing.Optional[int]
            Specifies the maximum number of results to include per page, enabling pagination. The value must be between 1 and 100, inclusive.

            For example, if `page_size` is set to 10, each page will include up to 10 items. Defaults to 10.

        name : typing.Optional[str]
            Filter to only include custom voices with name.

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

        Returns
        -------
        AsyncPager[ReturnCustomVoice]
            Success

        Examples
        --------
        import asyncio

        from hume import AsyncHumeClient

        client = AsyncHumeClient(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            response = await client.empathic_voice.custom_voices.list_custom_voices()
            async for item in response:
                yield item

            # alternatively, you can paginate page-by-page
            async for page in response.iter_pages():
                yield page


        asyncio.run(main())
        """
        return await self._raw_client.list_custom_voices(
            page_number=page_number, page_size=page_size, name=name, request_options=request_options
        )

    async def create_custom_voice(
        self,
        *,
        name: str,
        base_voice: PostedCustomVoiceBaseVoice,
        parameters: typing.Optional[PostedCustomVoiceParameters] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ReturnCustomVoice:
        """
        Creates a **Custom Voice** that can be added to an [EVI configuration](/reference/empathic-voice-interface-evi/configs/create-config).

        Refer to our [voices guide](/docs/empathic-voice-interface-evi/configuration/voices) for details on creating a custom voice.

        Parameters
        ----------
        name : str
            The name of the Custom Voice. Maximum length of 75 characters. Will be converted to all-uppercase. (e.g., "sample voice" becomes "SAMPLE VOICE")

        base_voice : PostedCustomVoiceBaseVoice
            Specifies the base voice used to create the Custom Voice.

        parameters : typing.Optional[PostedCustomVoiceParameters]
            The specified attributes of a Custom Voice.

            If no parameters are specified then all attributes will be set to their defaults, meaning no modfications will be made to the base voice.

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

        Returns
        -------
        ReturnCustomVoice
            Created

        Examples
        --------
        import asyncio

        from hume import AsyncHumeClient

        client = AsyncHumeClient(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.empathic_voice.custom_voices.create_custom_voice(
                name="name",
                base_voice="ITO",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.create_custom_voice(
            name=name, base_voice=base_voice, parameters=parameters, request_options=request_options
        )
        return _response.data

    async def get_custom_voice(
        self, id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> ReturnCustomVoice:
        """
        Fetches a specific **Custom Voice** by ID.

        Refer to our [voices guide](/docs/empathic-voice-interface-evi/configuration/voices) for details on creating a custom voice.

        Parameters
        ----------
        id : str
            Identifier for a Custom Voice. Formatted as a UUID.

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

        Returns
        -------
        ReturnCustomVoice
            Success

        Examples
        --------
        import asyncio

        from hume import AsyncHumeClient

        client = AsyncHumeClient(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.empathic_voice.custom_voices.get_custom_voice(
                id="id",
            )


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

    async def create_custom_voice_version(
        self,
        id: str,
        *,
        name: str,
        base_voice: PostedCustomVoiceBaseVoice,
        parameters: typing.Optional[PostedCustomVoiceParameters] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ReturnCustomVoice:
        """
        Updates a **Custom Voice** by creating a new version of the **Custom Voice**.

        Refer to our [voices guide](/docs/empathic-voice-interface-evi/configuration/voices) for details on creating a custom voice.

        Parameters
        ----------
        id : str
            Identifier for a Custom Voice. Formatted as a UUID.

        name : str
            The name of the Custom Voice. Maximum length of 75 characters. Will be converted to all-uppercase. (e.g., "sample voice" becomes "SAMPLE VOICE")

        base_voice : PostedCustomVoiceBaseVoice
            Specifies the base voice used to create the Custom Voice.

        parameters : typing.Optional[PostedCustomVoiceParameters]
            The specified attributes of a Custom Voice.

            If no parameters are specified then all attributes will be set to their defaults, meaning no modfications will be made to the base voice.

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

        Returns
        -------
        ReturnCustomVoice
            Created

        Examples
        --------
        import asyncio

        from hume import AsyncHumeClient

        client = AsyncHumeClient(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.empathic_voice.custom_voices.create_custom_voice_version(
                id="id",
                name="name",
                base_voice="ITO",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.create_custom_voice_version(
            id, name=name, base_voice=base_voice, parameters=parameters, request_options=request_options
        )
        return _response.data

    async def delete_custom_voice(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None:
        """
        Deletes a **Custom Voice** and its versions.

        Refer to our [voices guide](/docs/empathic-voice-interface-evi/configuration/voices) for details on creating a custom voice.

        Parameters
        ----------
        id : str
            Identifier for a Custom Voice. Formatted as a UUID.

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

        Returns
        -------
        None

        Examples
        --------
        import asyncio

        from hume import AsyncHumeClient

        client = AsyncHumeClient(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.empathic_voice.custom_voices.delete_custom_voice(
                id="id",
            )


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

    async def update_custom_voice_name(
        self, id: str, *, name: str, request_options: typing.Optional[RequestOptions] = None
    ) -> str:
        """
        Updates the name of a **Custom Voice**.

        Refer to our [voices guide](/docs/empathic-voice-interface-evi/configuration/voices) for details on creating a custom voice.

        Parameters
        ----------
        id : str
            Identifier for a Custom Voice. Formatted as a UUID.

        name : str
            The name of the Custom Voice. Maximum length of 75 characters. Will be converted to all-uppercase. (e.g., "sample voice" becomes "SAMPLE VOICE")

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

        Returns
        -------
        str
            Success

        Examples
        --------
        import asyncio

        from hume import AsyncHumeClient

        client = AsyncHumeClient(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.empathic_voice.custom_voices.update_custom_voice_name(
                id="id",
                name="name",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.update_custom_voice_name(id, name=name, request_options=request_options)
        return _response.data
