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

import typing

from .....core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
from .....core.request_options import RequestOptions
from .....types.dubbing_language_response import DubbingLanguageResponse
from .....types.dubbing_target_segment_update_response import DubbingTargetSegmentUpdateResponse
from .....types.dubbing_target_transcript_response import DubbingTargetTranscriptResponse
from .raw_client import AsyncRawTranscriptClient, RawTranscriptClient

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


class TranscriptClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawTranscriptClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawTranscriptClient
        """
        return self._raw_client

    def get(
        self, project_id: str, language_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> DubbingTargetTranscriptResponse:
        """
        A language target's transcript: source segments with their translations.

        Parameters
        ----------
        project_id : str
            Identifier of the dubbing project.

        language_id : str
            Identifier of the language target.

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

        Returns
        -------
        DubbingTargetTranscriptResponse
            Successful Response

        Examples
        --------
        from elevenlabs import ElevenLabs

        client = ElevenLabs(
            api_key="YOUR_API_KEY",
        )
        client.dubbing.project.language.transcript.get(
            project_id="proj_1601kwkyxp0hfzvtmyxwqxx6mcy3",
            language_id="lang_1001kwkyxp0je6ktn4knsfrasx5s",
        )
        """
        _response = self._raw_client.get(project_id, language_id, request_options=request_options)
        return _response.data

    def update_segment(
        self,
        project_id: str,
        language_id: str,
        segment_id: str,
        *,
        translation: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> DubbingTargetSegmentUpdateResponse:
        """
        Edit a segment's translation for a language target.

        Parameters
        ----------
        project_id : str
            Identifier of the dubbing project.

        language_id : str
            Identifier of the language target.

        segment_id : str
            Identifier of the segment to edit.

        translation : typing.Optional[str]
            New translated text, or null to mark the segment for re-translation.

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

        Returns
        -------
        DubbingTargetSegmentUpdateResponse
            Successful Response

        Examples
        --------
        from elevenlabs import ElevenLabs

        client = ElevenLabs(
            api_key="YOUR_API_KEY",
        )
        client.dubbing.project.language.transcript.update_segment(
            project_id="proj_1601kwkyxp0hfzvtmyxwqxx6mcy3",
            language_id="lang_1001kwkyxp0je6ktn4knsfrasx5s",
            segment_id="0199a3f0-1c2d-7abc-8def-0123456789ab",
            translation="Bienvenido a nuestra última demostración de producto.",
        )
        """
        _response = self._raw_client.update_segment(
            project_id, language_id, segment_id, translation=translation, request_options=request_options
        )
        return _response.data

    def regenerate(
        self, project_id: str, language_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> DubbingLanguageResponse:
        """
        Re-dub a target from its edited transcript (charged like a generation).

        Parameters
        ----------
        project_id : str
            Identifier of the dubbing project.

        language_id : str
            Identifier of the language target.

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

        Returns
        -------
        DubbingLanguageResponse
            Successful Response

        Examples
        --------
        from elevenlabs import ElevenLabs

        client = ElevenLabs(
            api_key="YOUR_API_KEY",
        )
        client.dubbing.project.language.transcript.regenerate(
            project_id="proj_1601kwkyxp0hfzvtmyxwqxx6mcy3",
            language_id="lang_1001kwkyxp0je6ktn4knsfrasx5s",
        )
        """
        _response = self._raw_client.regenerate(project_id, language_id, request_options=request_options)
        return _response.data


class AsyncTranscriptClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawTranscriptClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawTranscriptClient
        """
        return self._raw_client

    async def get(
        self, project_id: str, language_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> DubbingTargetTranscriptResponse:
        """
        A language target's transcript: source segments with their translations.

        Parameters
        ----------
        project_id : str
            Identifier of the dubbing project.

        language_id : str
            Identifier of the language target.

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

        Returns
        -------
        DubbingTargetTranscriptResponse
            Successful Response

        Examples
        --------
        import asyncio

        from elevenlabs import AsyncElevenLabs

        client = AsyncElevenLabs(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.dubbing.project.language.transcript.get(
                project_id="proj_1601kwkyxp0hfzvtmyxwqxx6mcy3",
                language_id="lang_1001kwkyxp0je6ktn4knsfrasx5s",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.get(project_id, language_id, request_options=request_options)
        return _response.data

    async def update_segment(
        self,
        project_id: str,
        language_id: str,
        segment_id: str,
        *,
        translation: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> DubbingTargetSegmentUpdateResponse:
        """
        Edit a segment's translation for a language target.

        Parameters
        ----------
        project_id : str
            Identifier of the dubbing project.

        language_id : str
            Identifier of the language target.

        segment_id : str
            Identifier of the segment to edit.

        translation : typing.Optional[str]
            New translated text, or null to mark the segment for re-translation.

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

        Returns
        -------
        DubbingTargetSegmentUpdateResponse
            Successful Response

        Examples
        --------
        import asyncio

        from elevenlabs import AsyncElevenLabs

        client = AsyncElevenLabs(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.dubbing.project.language.transcript.update_segment(
                project_id="proj_1601kwkyxp0hfzvtmyxwqxx6mcy3",
                language_id="lang_1001kwkyxp0je6ktn4knsfrasx5s",
                segment_id="0199a3f0-1c2d-7abc-8def-0123456789ab",
                translation="Bienvenido a nuestra última demostración de producto.",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.update_segment(
            project_id, language_id, segment_id, translation=translation, request_options=request_options
        )
        return _response.data

    async def regenerate(
        self, project_id: str, language_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> DubbingLanguageResponse:
        """
        Re-dub a target from its edited transcript (charged like a generation).

        Parameters
        ----------
        project_id : str
            Identifier of the dubbing project.

        language_id : str
            Identifier of the language target.

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

        Returns
        -------
        DubbingLanguageResponse
            Successful Response

        Examples
        --------
        import asyncio

        from elevenlabs import AsyncElevenLabs

        client = AsyncElevenLabs(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.dubbing.project.language.transcript.regenerate(
                project_id="proj_1601kwkyxp0hfzvtmyxwqxx6mcy3",
                language_id="lang_1001kwkyxp0je6ktn4knsfrasx5s",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.regenerate(project_id, language_id, request_options=request_options)
        return _response.data
