# 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_source_segment_update_response import DubbingSourceSegmentUpdateResponse
from ....types.dubbing_source_transcript_response import DubbingSourceTranscriptResponse
from ....types.dubbing_transcript_revision_response import DubbingTranscriptRevisionResponse
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, *, request_options: typing.Optional[RequestOptions] = None
    ) -> DubbingSourceTranscriptResponse:
        """
        The project's source transcript, as editable segments.

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

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

        Returns
        -------
        DubbingSourceTranscriptResponse
            Successful Response

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

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

    def delete_segment(
        self, project_id: str, segment_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> DubbingTranscriptRevisionResponse:
        """
        Remove a source segment from the transcript.

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

        segment_id : str
            Identifier of the segment to remove.

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

        Returns
        -------
        DubbingTranscriptRevisionResponse
            Successful Response

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

        client = ElevenLabs(
            api_key="YOUR_API_KEY",
        )
        client.dubbing.project.transcript.delete_segment(
            project_id="proj_1601kwkyxp0hfzvtmyxwqxx6mcy3",
            segment_id="0199a3f0-1c2d-7abc-8def-0123456789ab",
        )
        """
        _response = self._raw_client.delete_segment(project_id, segment_id, request_options=request_options)
        return _response.data

    def update_segment(
        self,
        project_id: str,
        segment_id: str,
        *,
        text: typing.Optional[str] = OMIT,
        speaker_id: typing.Optional[str] = OMIT,
        start_s: typing.Optional[float] = OMIT,
        end_s: typing.Optional[float] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> DubbingSourceSegmentUpdateResponse:
        """
        Edit a source segment's text, speaker, or timing.

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

        segment_id : str
            Identifier of the segment to edit.

        text : typing.Optional[str]
            New text for the segment.

        speaker_id : typing.Optional[str]
            New speaker id for the segment.

        start_s : typing.Optional[float]
            New start time, in seconds.

        end_s : typing.Optional[float]
            New end time, in seconds.

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

        Returns
        -------
        DubbingSourceSegmentUpdateResponse
            Successful Response

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

        client = ElevenLabs(
            api_key="YOUR_API_KEY",
        )
        client.dubbing.project.transcript.update_segment(
            project_id="proj_1601kwkyxp0hfzvtmyxwqxx6mcy3",
            segment_id="0199a3f0-1c2d-7abc-8def-0123456789ab",
            text="Welcome to our latest product demo.",
        )
        """
        _response = self._raw_client.update_segment(
            project_id,
            segment_id,
            text=text,
            speaker_id=speaker_id,
            start_s=start_s,
            end_s=end_s,
            request_options=request_options,
        )
        return _response.data

    def create_segment(
        self,
        project_id: str,
        *,
        text: str,
        speaker_id: str,
        start_s: float,
        end_s: float,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> DubbingSourceSegmentUpdateResponse:
        """
        Add a new source segment to the transcript.

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

        text : str
            The text of the new segment.

        speaker_id : str
            Identifier of the segment's speaker.

        start_s : float
            Start time of the segment, in seconds.

        end_s : float
            End time of the segment, in seconds.

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

        Returns
        -------
        DubbingSourceSegmentUpdateResponse
            Successful Response

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

        client = ElevenLabs(
            api_key="YOUR_API_KEY",
        )
        client.dubbing.project.transcript.create_segment(
            project_id="proj_1601kwkyxp0hfzvtmyxwqxx6mcy3",
            text="Thanks for watching.",
            speaker_id="default_speaker",
            start_s=42.0,
            end_s=44.0,
        )
        """
        _response = self._raw_client.create_segment(
            project_id, text=text, speaker_id=speaker_id, start_s=start_s, end_s=end_s, 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, *, request_options: typing.Optional[RequestOptions] = None
    ) -> DubbingSourceTranscriptResponse:
        """
        The project's source transcript, as editable segments.

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

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

        Returns
        -------
        DubbingSourceTranscriptResponse
            Successful Response

        Examples
        --------
        import asyncio

        from elevenlabs import AsyncElevenLabs

        client = AsyncElevenLabs(
            api_key="YOUR_API_KEY",
        )


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


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

    async def delete_segment(
        self, project_id: str, segment_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> DubbingTranscriptRevisionResponse:
        """
        Remove a source segment from the transcript.

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

        segment_id : str
            Identifier of the segment to remove.

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

        Returns
        -------
        DubbingTranscriptRevisionResponse
            Successful Response

        Examples
        --------
        import asyncio

        from elevenlabs import AsyncElevenLabs

        client = AsyncElevenLabs(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.dubbing.project.transcript.delete_segment(
                project_id="proj_1601kwkyxp0hfzvtmyxwqxx6mcy3",
                segment_id="0199a3f0-1c2d-7abc-8def-0123456789ab",
            )


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

    async def update_segment(
        self,
        project_id: str,
        segment_id: str,
        *,
        text: typing.Optional[str] = OMIT,
        speaker_id: typing.Optional[str] = OMIT,
        start_s: typing.Optional[float] = OMIT,
        end_s: typing.Optional[float] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> DubbingSourceSegmentUpdateResponse:
        """
        Edit a source segment's text, speaker, or timing.

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

        segment_id : str
            Identifier of the segment to edit.

        text : typing.Optional[str]
            New text for the segment.

        speaker_id : typing.Optional[str]
            New speaker id for the segment.

        start_s : typing.Optional[float]
            New start time, in seconds.

        end_s : typing.Optional[float]
            New end time, in seconds.

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

        Returns
        -------
        DubbingSourceSegmentUpdateResponse
            Successful Response

        Examples
        --------
        import asyncio

        from elevenlabs import AsyncElevenLabs

        client = AsyncElevenLabs(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.dubbing.project.transcript.update_segment(
                project_id="proj_1601kwkyxp0hfzvtmyxwqxx6mcy3",
                segment_id="0199a3f0-1c2d-7abc-8def-0123456789ab",
                text="Welcome to our latest product demo.",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.update_segment(
            project_id,
            segment_id,
            text=text,
            speaker_id=speaker_id,
            start_s=start_s,
            end_s=end_s,
            request_options=request_options,
        )
        return _response.data

    async def create_segment(
        self,
        project_id: str,
        *,
        text: str,
        speaker_id: str,
        start_s: float,
        end_s: float,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> DubbingSourceSegmentUpdateResponse:
        """
        Add a new source segment to the transcript.

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

        text : str
            The text of the new segment.

        speaker_id : str
            Identifier of the segment's speaker.

        start_s : float
            Start time of the segment, in seconds.

        end_s : float
            End time of the segment, in seconds.

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

        Returns
        -------
        DubbingSourceSegmentUpdateResponse
            Successful Response

        Examples
        --------
        import asyncio

        from elevenlabs import AsyncElevenLabs

        client = AsyncElevenLabs(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.dubbing.project.transcript.create_segment(
                project_id="proj_1601kwkyxp0hfzvtmyxwqxx6mcy3",
                text="Thanks for watching.",
                speaker_id="default_speaker",
                start_s=42.0,
                end_s=44.0,
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.create_segment(
            project_id, text=text, speaker_id=speaker_id, start_s=start_s, end_s=end_s, request_options=request_options
        )
        return _response.data
