o
    i!                     @   s   d dl Z ddlmZmZ ddlmZ ddlmZmZ ddl	m
Z
 ddlmZ dd	lmZ dd
lmZ e e jdZG dd dZG dd dZdS )    N   )AsyncClientWrapperSyncClientWrapper)RequestOptions   )AsyncRawAudioClientRawAudioClient)"AudioGenerateRequestCallbackMethod)AudioGenerateRequestContainer)AudioGenerateRequestEncoding)AudioGenerateRequestModel.c                   @      e Zd ZdefddZedefddZddddddddddd
d	ed
e	j
e de	j
e de	j
e de	j
e	jee	je f  de	j
e de	j
e de	j
e de	j
e de	j
e de	j
e de	je fddZdS )AudioClientclient_wrapperc                C      t |d| _d S N)r   )r   _raw_clientselfr    r   R/home/ubuntu/.local/lib/python3.10/site-packages/deepgram/speak/v1/audio/client.py__init__      zAudioClient.__init__returnc                 C      | j S )z
        Retrieves a raw implementation of this client that returns raw responses.

        Returns
        -------
        RawAudioClient
        r   r   r   r   r   with_raw_response      	zAudioClient.with_raw_responseN
callbackcallback_methodmip_opt_outtagbit_rate	containerencodingmodelsample_raterequest_optionstextr    r!   r"   r#   r$   r%   r&   r'   r(   r)   c                c   sV    | j j|||||||||	|
|d}|jE dH  W d   dS 1 s$w   Y  dS )a  
        Convert text into natural-sounding speech using Deepgram's TTS REST API

        Parameters
        ----------
        text : str
            The text content to be converted to speech

        callback : typing.Optional[str]
            URL to which we'll make the callback request

        callback_method : typing.Optional[AudioGenerateRequestCallbackMethod]
            HTTP method by which the callback request will be made

        mip_opt_out : typing.Optional[bool]
            Opts out requests from the Deepgram Model Improvement Program. Refer to our Docs for pricing impacts before setting this to true. https://dpgr.am/deepgram-mip

        tag : typing.Optional[typing.Union[str, typing.Sequence[str]]]
            Label your requests for the purpose of identification during usage reporting

        bit_rate : typing.Optional[float]
            The bitrate of the audio in bits per second. Choose from predefined ranges or specific values based on the encoding type.

        container : typing.Optional[AudioGenerateRequestContainer]
            Container specifies the file format wrapper for the output audio. The available options depend on the encoding type.

        encoding : typing.Optional[AudioGenerateRequestEncoding]
            Encoding allows you to specify the expected encoding of your audio output

        model : typing.Optional[AudioGenerateRequestModel]
            AI model used to process submitted text

        sample_rate : typing.Optional[float]
            Sample Rate specifies the sample rate for the output audio. Based on the encoding, different sample rates are supported. For some encodings, the sample rate is not configurable

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.

        Returns
        -------
        typing.Iterator[bytes]
            Successful text-to-speech transformation

        Examples
        --------
        from deepgram import DeepgramClient

        client = DeepgramClient(
            api_key="YOUR_API_KEY",
        )
        client.speak.v1.audio.generate(
            text="text",
        )
        r*   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   Nr   generatedata)r   r*   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   rr   r   r   r-       s"   E"zAudioClient.generate)__name__
__module____qualname__r   r   propertyr   r   strtypingOptionalr	   boolUnionSequencefloatr
   r   r   r   Iteratorbytesr-   r   r   r   r   r      N    	
r   c                   @   r   )AsyncAudioClientr   c                C   r   r   )r   r   r   r   r   r   r   v   r   zAsyncAudioClient.__init__r   c                 C   r   )z
        Retrieves a raw implementation of this client that returns raw responses.

        Returns
        -------
        AsyncRawAudioClient
        r   r   r   r   r   r   y   r   z"AsyncAudioClient.with_raw_responseNr   r*   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   c                C  sz   | j j|||||||||	|
|d4 I dH }|j2 z	3 dH W }|V  q6 W d  I dH  dS 1 I dH s6w   Y  dS )aE	  
        Convert text into natural-sounding speech using Deepgram's TTS REST API

        Parameters
        ----------
        text : str
            The text content to be converted to speech

        callback : typing.Optional[str]
            URL to which we'll make the callback request

        callback_method : typing.Optional[AudioGenerateRequestCallbackMethod]
            HTTP method by which the callback request will be made

        mip_opt_out : typing.Optional[bool]
            Opts out requests from the Deepgram Model Improvement Program. Refer to our Docs for pricing impacts before setting this to true. https://dpgr.am/deepgram-mip

        tag : typing.Optional[typing.Union[str, typing.Sequence[str]]]
            Label your requests for the purpose of identification during usage reporting

        bit_rate : typing.Optional[float]
            The bitrate of the audio in bits per second. Choose from predefined ranges or specific values based on the encoding type.

        container : typing.Optional[AudioGenerateRequestContainer]
            Container specifies the file format wrapper for the output audio. The available options depend on the encoding type.

        encoding : typing.Optional[AudioGenerateRequestEncoding]
            Encoding allows you to specify the expected encoding of your audio output

        model : typing.Optional[AudioGenerateRequestModel]
            AI model used to process submitted text

        sample_rate : typing.Optional[float]
            Sample Rate specifies the sample rate for the output audio. Based on the encoding, different sample rates are supported. For some encodings, the sample rate is not configurable

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.

        Returns
        -------
        typing.AsyncIterator[bytes]
            Successful text-to-speech transformation

        Examples
        --------
        import asyncio

        from deepgram import AsyncDeepgramClient

        client = AsyncDeepgramClient(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.speak.v1.audio.generate(
                text="text",
            )


        asyncio.run(main())
        r+   Nr,   )r   r*   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   r/   _chunkr   r   r   r-      s&   M.zAsyncAudioClient.generate)r0   r1   r2   r   r   r3   r   r   r4   r5   r6   r	   r7   r8   r9   r:   r
   r   r   r   AsyncIteratorr<   r-   r   r   r   r   r>   u   r=   r>   )r5   core.client_wrapperr   r   core.request_optionsr   
raw_clientr   r   ,types.audio_generate_request_callback_methodr	   &types.audio_generate_request_containerr
   %types.audio_generate_request_encodingr   "types.audio_generate_request_modelr   castAnyOMITr   r>   r   r   r   r   <module>   s   d