# 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 .raw_client import AsyncRawSpeechToTextClient, RawSpeechToTextClient
from .types.lightning_speech_to_text_request_age_detection import LightningSpeechToTextRequestAgeDetection
from .types.lightning_speech_to_text_request_emotion_detection import LightningSpeechToTextRequestEmotionDetection
from .types.lightning_speech_to_text_request_gender_detection import LightningSpeechToTextRequestGenderDetection
from .types.lightning_speech_to_text_request_language import LightningSpeechToTextRequestLanguage
from .types.lightning_speech_to_text_request_model import LightningSpeechToTextRequestModel
from .types.lightning_speech_to_text_response import LightningSpeechToTextResponse
from .types.pulse_speech_to_text_request_age_detection import PulseSpeechToTextRequestAgeDetection
from .types.pulse_speech_to_text_request_emotion_detection import PulseSpeechToTextRequestEmotionDetection
from .types.pulse_speech_to_text_request_gender_detection import PulseSpeechToTextRequestGenderDetection
from .types.pulse_speech_to_text_request_language import PulseSpeechToTextRequestLanguage
from .types.pulse_speech_to_text_request_model import PulseSpeechToTextRequestModel
from .types.pulse_speech_to_text_response import PulseSpeechToTextResponse

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


class SpeechToTextClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawSpeechToTextClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawSpeechToTextClient
        """
        return self._raw_client

    def lightning(
        self,
        *,
        model: LightningSpeechToTextRequestModel,
        request: typing.Union[bytes, typing.Iterator[bytes], typing.AsyncIterator[bytes]],
        language: typing.Optional[LightningSpeechToTextRequestLanguage] = None,
        webhook_url: typing.Optional[str] = None,
        webhook_extra: typing.Optional[str] = None,
        word_timestamps: typing.Optional[bool] = None,
        diarize: typing.Optional[bool] = None,
        age_detection: typing.Optional[LightningSpeechToTextRequestAgeDetection] = None,
        gender_detection: typing.Optional[LightningSpeechToTextRequestGenderDetection] = None,
        emotion_detection: typing.Optional[LightningSpeechToTextRequestEmotionDetection] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> LightningSpeechToTextResponse:
        """
        Convert speech to text using the Lightning ASR model. Supports two input methods - raw audio bytes (application/octet-stream) with query parameters, or audio URL (application/json) with URL in body.

        Parameters
        ----------
        model : LightningSpeechToTextRequestModel
            The ASR model to use for transcription

        request : typing.Union[bytes, typing.Iterator[bytes], typing.AsyncIterator[bytes]]

        language : typing.Optional[LightningSpeechToTextRequestLanguage]
            Language of the audio file. Use `multi` for automatic language detection

        webhook_url : typing.Optional[str]

        webhook_extra : typing.Optional[str]

        word_timestamps : typing.Optional[bool]
            Whether to include word and utterance level timestamps in the response

        diarize : typing.Optional[bool]
            Whether to perform speaker diarization

        age_detection : typing.Optional[LightningSpeechToTextRequestAgeDetection]
            Whether to predict age group of the speaker

        gender_detection : typing.Optional[LightningSpeechToTextRequestGenderDetection]
            Whether to predict the gender of the speaker

        emotion_detection : typing.Optional[LightningSpeechToTextRequestEmotionDetection]
            Whether to predict speaker emotions

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

        Returns
        -------
        LightningSpeechToTextResponse
            Speech transcribed successfully
        """
        _response = self._raw_client.lightning(
            model=model,
            request=request,
            language=language,
            webhook_url=webhook_url,
            webhook_extra=webhook_extra,
            word_timestamps=word_timestamps,
            diarize=diarize,
            age_detection=age_detection,
            gender_detection=gender_detection,
            emotion_detection=emotion_detection,
            request_options=request_options,
        )
        return _response.data

    def pulse(
        self,
        *,
        model: PulseSpeechToTextRequestModel,
        request: typing.Union[bytes, typing.Iterator[bytes], typing.AsyncIterator[bytes]],
        language: typing.Optional[PulseSpeechToTextRequestLanguage] = None,
        webhook_url: typing.Optional[str] = None,
        webhook_extra: typing.Optional[str] = None,
        word_timestamps: typing.Optional[bool] = None,
        diarize: typing.Optional[bool] = None,
        age_detection: typing.Optional[PulseSpeechToTextRequestAgeDetection] = None,
        gender_detection: typing.Optional[PulseSpeechToTextRequestGenderDetection] = None,
        emotion_detection: typing.Optional[PulseSpeechToTextRequestEmotionDetection] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> PulseSpeechToTextResponse:
        """
        Convert speech to text using the Pulse ASR model. Supports two input methods - raw audio bytes (application/octet-stream) with query parameters, or audio URL (application/json) with URL in body.

        Parameters
        ----------
        model : PulseSpeechToTextRequestModel
            The ASR model to use for transcription

        request : typing.Union[bytes, typing.Iterator[bytes], typing.AsyncIterator[bytes]]

        language : typing.Optional[PulseSpeechToTextRequestLanguage]
            Language of the audio file. Use `multi` for automatic language detection

        webhook_url : typing.Optional[str]

        webhook_extra : typing.Optional[str]

        word_timestamps : typing.Optional[bool]
            Whether to include word and utterance level timestamps in the response

        diarize : typing.Optional[bool]
            Whether to perform speaker diarization

        age_detection : typing.Optional[PulseSpeechToTextRequestAgeDetection]
            Whether to predict age group of the speaker

        gender_detection : typing.Optional[PulseSpeechToTextRequestGenderDetection]
            Whether to predict the gender of the speaker

        emotion_detection : typing.Optional[PulseSpeechToTextRequestEmotionDetection]
            Whether to predict speaker emotions

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

        Returns
        -------
        PulseSpeechToTextResponse
            Speech transcribed successfully
        """
        _response = self._raw_client.pulse(
            model=model,
            request=request,
            language=language,
            webhook_url=webhook_url,
            webhook_extra=webhook_extra,
            word_timestamps=word_timestamps,
            diarize=diarize,
            age_detection=age_detection,
            gender_detection=gender_detection,
            emotion_detection=emotion_detection,
            request_options=request_options,
        )
        return _response.data


class AsyncSpeechToTextClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawSpeechToTextClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawSpeechToTextClient
        """
        return self._raw_client

    async def lightning(
        self,
        *,
        model: LightningSpeechToTextRequestModel,
        request: typing.Union[bytes, typing.Iterator[bytes], typing.AsyncIterator[bytes]],
        language: typing.Optional[LightningSpeechToTextRequestLanguage] = None,
        webhook_url: typing.Optional[str] = None,
        webhook_extra: typing.Optional[str] = None,
        word_timestamps: typing.Optional[bool] = None,
        diarize: typing.Optional[bool] = None,
        age_detection: typing.Optional[LightningSpeechToTextRequestAgeDetection] = None,
        gender_detection: typing.Optional[LightningSpeechToTextRequestGenderDetection] = None,
        emotion_detection: typing.Optional[LightningSpeechToTextRequestEmotionDetection] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> LightningSpeechToTextResponse:
        """
        Convert speech to text using the Lightning ASR model. Supports two input methods - raw audio bytes (application/octet-stream) with query parameters, or audio URL (application/json) with URL in body.

        Parameters
        ----------
        model : LightningSpeechToTextRequestModel
            The ASR model to use for transcription

        request : typing.Union[bytes, typing.Iterator[bytes], typing.AsyncIterator[bytes]]

        language : typing.Optional[LightningSpeechToTextRequestLanguage]
            Language of the audio file. Use `multi` for automatic language detection

        webhook_url : typing.Optional[str]

        webhook_extra : typing.Optional[str]

        word_timestamps : typing.Optional[bool]
            Whether to include word and utterance level timestamps in the response

        diarize : typing.Optional[bool]
            Whether to perform speaker diarization

        age_detection : typing.Optional[LightningSpeechToTextRequestAgeDetection]
            Whether to predict age group of the speaker

        gender_detection : typing.Optional[LightningSpeechToTextRequestGenderDetection]
            Whether to predict the gender of the speaker

        emotion_detection : typing.Optional[LightningSpeechToTextRequestEmotionDetection]
            Whether to predict speaker emotions

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

        Returns
        -------
        LightningSpeechToTextResponse
            Speech transcribed successfully
        """
        _response = await self._raw_client.lightning(
            model=model,
            request=request,
            language=language,
            webhook_url=webhook_url,
            webhook_extra=webhook_extra,
            word_timestamps=word_timestamps,
            diarize=diarize,
            age_detection=age_detection,
            gender_detection=gender_detection,
            emotion_detection=emotion_detection,
            request_options=request_options,
        )
        return _response.data

    async def pulse(
        self,
        *,
        model: PulseSpeechToTextRequestModel,
        request: typing.Union[bytes, typing.Iterator[bytes], typing.AsyncIterator[bytes]],
        language: typing.Optional[PulseSpeechToTextRequestLanguage] = None,
        webhook_url: typing.Optional[str] = None,
        webhook_extra: typing.Optional[str] = None,
        word_timestamps: typing.Optional[bool] = None,
        diarize: typing.Optional[bool] = None,
        age_detection: typing.Optional[PulseSpeechToTextRequestAgeDetection] = None,
        gender_detection: typing.Optional[PulseSpeechToTextRequestGenderDetection] = None,
        emotion_detection: typing.Optional[PulseSpeechToTextRequestEmotionDetection] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> PulseSpeechToTextResponse:
        """
        Convert speech to text using the Pulse ASR model. Supports two input methods - raw audio bytes (application/octet-stream) with query parameters, or audio URL (application/json) with URL in body.

        Parameters
        ----------
        model : PulseSpeechToTextRequestModel
            The ASR model to use for transcription

        request : typing.Union[bytes, typing.Iterator[bytes], typing.AsyncIterator[bytes]]

        language : typing.Optional[PulseSpeechToTextRequestLanguage]
            Language of the audio file. Use `multi` for automatic language detection

        webhook_url : typing.Optional[str]

        webhook_extra : typing.Optional[str]

        word_timestamps : typing.Optional[bool]
            Whether to include word and utterance level timestamps in the response

        diarize : typing.Optional[bool]
            Whether to perform speaker diarization

        age_detection : typing.Optional[PulseSpeechToTextRequestAgeDetection]
            Whether to predict age group of the speaker

        gender_detection : typing.Optional[PulseSpeechToTextRequestGenderDetection]
            Whether to predict the gender of the speaker

        emotion_detection : typing.Optional[PulseSpeechToTextRequestEmotionDetection]
            Whether to predict speaker emotions

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

        Returns
        -------
        PulseSpeechToTextResponse
            Speech transcribed successfully
        """
        _response = await self._raw_client.pulse(
            model=model,
            request=request,
            language=language,
            webhook_url=webhook_url,
            webhook_extra=webhook_extra,
            word_timestamps=word_timestamps,
            diarize=diarize,
            age_detection=age_detection,
            gender_detection=gender_detection,
            emotion_detection=emotion_detection,
            request_options=request_options,
        )
        return _response.data
