U
    ·ÜŸjÑ%  ã                   @  s   d dl mZ d dlmZ d dlmZ d dlZddlmZ ddl	m
Z
mZmZmZm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mZmZmZ ddlmZ ddlmZ ddl m!Z! ddgZ"G dd„ deƒZ#G dd„ deƒZ$G dd„ dƒZ%G dd„ dƒZ&G dd„ dƒZ'G dd„ dƒZ(dS )é    )Úannotations)ÚUnion)ÚLiteralNé   )Ú_legacy_response)Ú	NOT_GIVENÚBodyÚQueryÚHeadersÚNotGiven)Úmaybe_transformÚasync_maybe_transform)Úcached_property)ÚSyncAPIResourceÚAsyncAPIResource)ÚStreamedBinaryAPIResponseÚAsyncStreamedBinaryAPIResponseÚ#to_custom_streamed_response_wrapperÚ)async_to_custom_streamed_response_wrapper)Úspeech_create_params)Úmake_request_options)ÚSpeechModelÚSpeechÚAsyncSpeechc                   @  sd   e Zd Zeddœdd„ƒZeddœdd„ƒZeeeddded	œd
dddddddddddœdd„ZdS )r   ÚSpeechWithRawResponse©Úreturnc                 C  s   t | ƒS ©a  
        This property can be used as a prefix for any HTTP method call to return
        the raw response object instead of the parsed content.

        For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
        )r   ©Úself© r    úA/tmp/pip-unpacked-wheel-2qj3ofc_/openai/resources/audio/speech.pyÚwith_raw_response    s    zSpeech.with_raw_responseÚSpeechWithStreamingResponsec                 C  s   t | ƒS ©zÌ
        An alternative to `.with_raw_response` that doesn't eagerly read the response body.

        For more information, see https://www.github.com/openai/openai-python#with_streaming_response
        )r#   r   r    r    r!   Úwith_streaming_response*   s    zSpeech.with_streaming_responseN©ÚinstructionsÚresponse_formatÚspeedÚextra_headersÚextra_queryÚ
extra_bodyÚtimeoutÚstrúUnion[str, SpeechModel]úuUnion[str, Literal[('alloy', 'ash', 'ballad', 'coral', 'echo', 'fable', 'onyx', 'nova', 'sage', 'shimmer', 'verse')]]ústr | NotGivenú@Literal[('mp3', 'opus', 'aac', 'flac', 'wav', 'pcm')] | NotGivenúfloat | NotGivenúHeaders | NoneúQuery | NoneúBody | Noneú'float | httpx.Timeout | None | NotGivenú+_legacy_response.HttpxBinaryResponseContent©ÚinputÚmodelÚvoicer'   r(   r)   r*   r+   r,   r-   r   c       
      
   C  sF   ddi|pi –}| j dt||||||dœtjƒt|||	|
d�tjd�S )áb  
        Generates audio from the input text.

        Args:
          input: The text to generate audio for. The maximum length is 4096 characters.

          model:
              One of the available [TTS models](https://platform.openai.com/docs/models#tts):
              `tts-1`, `tts-1-hd` or `gpt-4o-mini-tts`.

          voice: The voice to use when generating the audio. Supported voices are `alloy`, `ash`,
              `ballad`, `coral`, `echo`, `fable`, `onyx`, `nova`, `sage`, `shimmer`, and
              `verse`. Previews of the voices are available in the
              [Text to speech guide](https://platform.openai.com/docs/guides/text-to-speech#voice-options).

          instructions: Control the voice of your generated audio with additional instructions. Does not
              work with `tts-1` or `tts-1-hd`.

          response_format: The format to audio in. Supported formats are `mp3`, `opus`, `aac`, `flac`,
              `wav`, and `pcm`.

          speed: The speed of the generated audio. Select a value from `0.25` to `4.0`. `1.0` is
              the default.

          extra_headers: Send extra headers

          extra_query: Add additional query parameters to the request

          extra_body: Add additional JSON properties to the request

          timeout: Override the client-level default timeout for this request, in seconds
        ÚAcceptúapplication/octet-streamú/audio/speech©r:   r;   r<   r'   r(   r)   ©r*   r+   r,   r-   ©ÚbodyÚoptionsZcast_to)Ú_postr   r   ÚSpeechCreateParamsr   r   ÚHttpxBinaryResponseContent©r   r:   r;   r<   r'   r(   r)   r*   r+   r,   r-   r    r    r!   Úcreate3   s*    2ú÷   ÿðzSpeech.create©Ú__name__Ú
__module__Ú__qualname__r   r"   r%   r   rJ   r    r    r    r!   r      s   	ðc                   @  sd   e Zd Zeddœdd„ƒZeddœdd„ƒZeeeddded	œd
dddddddddddœdd„ZdS )r   ÚAsyncSpeechWithRawResponser   c                 C  s   t | ƒS r   )rO   r   r    r    r!   r"   {   s    zAsyncSpeech.with_raw_responseÚ AsyncSpeechWithStreamingResponsec                 C  s   t | ƒS r$   )rP   r   r    r    r!   r%   …   s    z#AsyncSpeech.with_streaming_responseNr&   r.   r/   r0   r1   r2   r3   r4   r5   r6   r7   r8   r9   c       
      
   Ã  sR   ddi|pi –}| j dt||||||dœtjƒI dH t|||	|
d�tjd�I dH S )r=   r>   r?   r@   rA   NrB   rC   )rF   r   r   rG   r   r   rH   rI   r    r    r!   rJ   Ž   s*    2ú÷   ÿðzAsyncSpeech.createrK   r    r    r    r!   r   z   s   	ðc                   @  s   e Zd Zdddœdd„ZdS )r   r   ÚNone©Úspeechr   c                 C  s   || _ t |j¡| _d S ©N)Ú_speechr   Zto_raw_response_wrapperrJ   ©r   rS   r    r    r!   Ú__init__Ö   s    ÿzSpeechWithRawResponse.__init__N©rL   rM   rN   rW   r    r    r    r!   r   Õ   s   r   c                   @  s   e Zd Zdddœdd„ZdS )rO   r   rQ   rR   c                 C  s   || _ t |j¡| _d S rT   )rU   r   Zasync_to_raw_response_wrapperrJ   rV   r    r    r!   rW   ß   s    ÿz#AsyncSpeechWithRawResponse.__init__NrX   r    r    r    r!   rO   Þ   s   rO   c                   @  s   e Zd Zdddœdd„ZdS )r#   r   rQ   rR   c                 C  s   || _ t|jtƒ| _d S rT   )rU   r   rJ   r   rV   r    r    r!   rW   è   s
    þz$SpeechWithStreamingResponse.__init__NrX   r    r    r    r!   r#   ç   s   r#   c                   @  s   e Zd Zdddœdd„ZdS )rP   r   rQ   rR   c                 C  s   || _ t|jtƒ| _d S rT   )rU   r   rJ   r   rV   r    r    r!   rW   ò   s
    þz)AsyncSpeechWithStreamingResponse.__init__NrX   r    r    r    r!   rP   ñ   s   rP   ))Ú
__future__r   Útypingr   Útyping_extensionsr   ZhttpxÚ r   Ú_typesr   r   r	   r
   r   Ú_utilsr   r   Ú_compatr   Z	_resourcer   r   Ú	_responser   r   r   r   Ztypes.audior   Z_base_clientr   Ztypes.audio.speech_modelr   Ú__all__r   r   r   rO   r#   rP   r    r    r    r!   Ú<module>   s&   [[		
