# 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_bulk_target_segment_update_response import DubbingBulkTargetSegmentUpdateResponse from .....types.dubbing_regenerate_response import DubbingRegenerateResponse from .....types.dubbing_target_segment_update_request import DubbingTargetSegmentUpdateRequest 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. Available once the target has produced an output. Returns a conflict while the target is still on its first dub, since it has no translations to return yet. 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, *, request: DubbingTargetSegmentUpdateRequest, request_options: typing.Optional[RequestOptions] = None, ) -> DubbingTargetSegmentUpdateResponse: """ Enterprise only. Edit a segment's translation for a language target. Omitted fields are left unchanged; an explicit null clears the field. Bumps the target's `revision` and marks it `stale` if it had already completed. The source transcript and the project's other languages are untouched, and no audio changes until you regenerate the 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. request : DubbingTargetSegmentUpdateRequest request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- DubbingTargetSegmentUpdateResponse Successful Response Examples -------- from elevenlabs import DubbingTargetSegmentUpdateRequest, 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", request=DubbingTargetSegmentUpdateRequest( translation="Bienvenido a nuestra última demostración de producto.", ), ) """ _response = self._raw_client.update_segment( project_id, language_id, segment_id, request=request, request_options=request_options ) return _response.data def update_segments( self, project_id: str, language_id: str, *, segments: typing.Dict[str, DubbingTargetSegmentUpdateRequest], request_options: typing.Optional[RequestOptions] = None, ) -> DubbingBulkTargetSegmentUpdateResponse: """ Enterprise only. Edit several segments' translations for a language target in one atomic request: every edit applies or none does. Bumps the target's `revision` and marks it `stale` if it had already completed. The source transcript and the project's other languages are untouched, and no audio changes until you regenerate the target. Parameters ---------- project_id : str Identifier of the dubbing project. language_id : str Identifier of the language target. segments : typing.Dict[str, DubbingTargetSegmentUpdateRequest] Map of segment ID to the translation edit to apply to that segment. At least one entry and at most 500. request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- DubbingBulkTargetSegmentUpdateResponse Successful Response Examples -------- from elevenlabs import DubbingTargetSegmentUpdateRequest, ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) client.dubbing.project.language.transcript.update_segments( project_id="proj_1601kwkyxp0hfzvtmyxwqxx6mcy3", language_id="lang_1001kwkyxp0je6ktn4knsfrasx5s", segments={ "0199a3f0-1c2d-7abc-8def-0123456789ab": DubbingTargetSegmentUpdateRequest( translation="Bienvenido a nuestra última demostración de producto.", ), "0199a3f0-3e4f-7abc-8def-0123456789cd": DubbingTargetSegmentUpdateRequest( translation="Empecemos.", ), }, ) """ _response = self._raw_client.update_segments( project_id, language_id, segments=segments, request_options=request_options ) return _response.data def regenerate( self, project_id: str, language_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> DubbingRegenerateResponse: """ Enterprise only. Re-dub a target from its edited transcript, re-synthesizing only the edited regions (charged like a generation, less the free-regeneration allowance). Accepted asynchronously: the target returns to `processing` and sends a `dubbing_language_completed` event to the project's `webhook_ids` when the re-dub lands, carrying the new output URLs. Returns a conflict when the target has no edits to apply — nothing is dispatched and nothing is charged. 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 ------- DubbingRegenerateResponse 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. Available once the target has produced an output. Returns a conflict while the target is still on its first dub, since it has no translations to return yet. 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, *, request: DubbingTargetSegmentUpdateRequest, request_options: typing.Optional[RequestOptions] = None, ) -> DubbingTargetSegmentUpdateResponse: """ Enterprise only. Edit a segment's translation for a language target. Omitted fields are left unchanged; an explicit null clears the field. Bumps the target's `revision` and marks it `stale` if it had already completed. The source transcript and the project's other languages are untouched, and no audio changes until you regenerate the 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. request : DubbingTargetSegmentUpdateRequest request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- DubbingTargetSegmentUpdateResponse Successful Response Examples -------- import asyncio from elevenlabs import AsyncElevenLabs, DubbingTargetSegmentUpdateRequest 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", request=DubbingTargetSegmentUpdateRequest( 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, request=request, request_options=request_options ) return _response.data async def update_segments( self, project_id: str, language_id: str, *, segments: typing.Dict[str, DubbingTargetSegmentUpdateRequest], request_options: typing.Optional[RequestOptions] = None, ) -> DubbingBulkTargetSegmentUpdateResponse: """ Enterprise only. Edit several segments' translations for a language target in one atomic request: every edit applies or none does. Bumps the target's `revision` and marks it `stale` if it had already completed. The source transcript and the project's other languages are untouched, and no audio changes until you regenerate the target. Parameters ---------- project_id : str Identifier of the dubbing project. language_id : str Identifier of the language target. segments : typing.Dict[str, DubbingTargetSegmentUpdateRequest] Map of segment ID to the translation edit to apply to that segment. At least one entry and at most 500. request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- DubbingBulkTargetSegmentUpdateResponse Successful Response Examples -------- import asyncio from elevenlabs import AsyncElevenLabs, DubbingTargetSegmentUpdateRequest client = AsyncElevenLabs( api_key="YOUR_API_KEY", ) async def main() -> None: await client.dubbing.project.language.transcript.update_segments( project_id="proj_1601kwkyxp0hfzvtmyxwqxx6mcy3", language_id="lang_1001kwkyxp0je6ktn4knsfrasx5s", segments={ "0199a3f0-1c2d-7abc-8def-0123456789ab": DubbingTargetSegmentUpdateRequest( translation="Bienvenido a nuestra última demostración de producto.", ), "0199a3f0-3e4f-7abc-8def-0123456789cd": DubbingTargetSegmentUpdateRequest( translation="Empecemos.", ), }, ) asyncio.run(main()) """ _response = await self._raw_client.update_segments( project_id, language_id, segments=segments, request_options=request_options ) return _response.data async def regenerate( self, project_id: str, language_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> DubbingRegenerateResponse: """ Enterprise only. Re-dub a target from its edited transcript, re-synthesizing only the edited regions (charged like a generation, less the free-regeneration allowance). Accepted asynchronously: the target returns to `processing` and sends a `dubbing_language_completed` event to the project's `webhook_ids` when the re-dub lands, carrying the new output URLs. Returns a conflict when the target has no edits to apply — nothing is dispatched and nothing is charged. 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 ------- DubbingRegenerateResponse 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