o
    ØRWj*  ã                   @  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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)ÚBodyÚOmitÚQueryÚHeadersÚNotGivenÚomitÚ	not_given)Ú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                	   @  óJ   e Zd ZdZed$dd„ƒZed%dd„ƒZeeeed	d	d	ed
œd&d"d#„Z	d	S )'r   ú(Turn audio into text or text into audio.ÚreturnÚSpeechWithRawResponsec                 C  ó   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$   úl/home/esfera/Documents/content_generation/venv/lib/python3.10/site-packages/openai/resources/audio/speech.pyÚwith_raw_response   ó   zSpeech.with_raw_responseÚSpeechWithStreamingResponsec                 C  r    ©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)   ó   zSpeech.with_streaming_responseN©ÚinstructionsÚresponse_formatÚspeedÚstream_formatÚextra_headersÚextra_queryÚ
extra_bodyÚtimeoutÚinputÚstrÚmodelúUnion[str, SpeechModel]Úvoiceúspeech_create_params.Voicer-   ú
str | Omitr.   ú:Literal['mp3', 'opus', 'aac', 'flac', 'wav', 'pcm'] | Omitr/   úfloat | Omitr0   úLiteral['sse', 'audio'] | Omitr1   úHeaders | Noner2   úQuery | Noner3   úBody | Noner4   ú'float | httpx.Timeout | None | NotGivenú+_legacy_response.HttpxBinaryResponseContentc                C  sN   ddi|pi ¥}| j dt|||||||dœtjƒt||	|
|ddid�tjd�S )	á  
        Generates audio from the input text.

        Returns the audio file content, or a stream of audio events.

        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`, `gpt-4o-mini-tts`, or `gpt-4o-mini-tts-2025-12-15`.

          voice: The voice to use when generating the audio. Supported built-in voices are
              `alloy`, `ash`, `ballad`, `coral`, `echo`, `fable`, `onyx`, `nova`, `sage`,
              `shimmer`, `verse`, `marin`, and `cedar`. You may also provide a custom voice
              object with an `id`, for example `{ "id": "voice_1234" }`. 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.

          stream_format: The format to stream the audio in. Supported formats are `sse` and `audio`.
              `sse` is not supported for `tts-1` or `tts-1-hd`.

          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©r5   r7   r9   r-   r.   r/   r0   Úbearer_authT©r1   r2   r3   r4   Úsecurity©ÚbodyÚoptionsÚcast_to)Ú_postr   r   ÚSpeechCreateParamsr   r   ÚHttpxBinaryResponseContent©r#   r5   r7   r9   r-   r.   r/   r0   r1   r2   r3   r4   r$   r$   r%   Úcreate2   s.   8ù	öûëzSpeech.create)r   r   )r   r(   ©r5   r6   r7   r8   r9   r:   r-   r;   r.   r<   r/   r=   r0   r>   r1   r?   r2   r@   r3   rA   r4   rB   r   rC   ©
Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r&   r*   r   r   rT   r$   r$   r$   r%   r      ó    	ñc                	   @  r   )'r   r   r   ÚAsyncSpeechWithRawResponsec                 C  r    r!   )r\   r"   r$   r$   r%   r&   ‡   r'   zAsyncSpeech.with_raw_responseÚ AsyncSpeechWithStreamingResponsec                 C  r    r)   )r]   r"   r$   r$   r%   r*   ‘   r+   z#AsyncSpeech.with_streaming_responseNr,   r5   r6   r7   r8   r9   r:   r-   r;   r.   r<   r/   r=   r0   r>   r1   r?   r2   r@   r3   rA   r4   rB   rC   c                Ã  s\   �ddi|pi ¥}| j dt|||||||dœtjƒI dH t||	|
|ddid�tjd	�I dH S )
rD   rE   rF   rG   rH   NrI   TrJ   rL   )rP   r   r   rQ   r   r   rR   rS   r$   r$   r%   rT   š   s0   €8ù	öûëzAsyncSpeech.create)r   r\   )r   r]   rU   rV   r$   r$   r$   r%   r   „   r[   c                   @  ó   e Zd Zddd„ZdS )	r   Úspeechr   r   ÚNonec                 C  ó   || _ t |j¡| _d S ©N)Ú_speechr   Úto_raw_response_wrapperrT   ©r#   r_   r$   r$   r%   Ú__init__í   ó   
ÿzSpeechWithRawResponse.__init__N©r_   r   r   r`   ©rW   rX   rY   rf   r$   r$   r$   r%   r   ì   ó    r   c                   @  r^   )	r\   r_   r   r   r`   c                 C  ra   rb   )rc   r   Úasync_to_raw_response_wrapperrT   re   r$   r$   r%   rf   ö   rg   z#AsyncSpeechWithRawResponse.__init__N©r_   r   r   r`   ri   r$   r$   r$   r%   r\   õ   rj   r\   c                   @  r^   )	r(   r_   r   r   r`   c                 C  ó   || _ t|jtƒ| _d S rb   )rc   r   rT   r   re   r$   r$   r%   rf   ÿ   ó
   
þz$SpeechWithStreamingResponse.__init__Nrh   ri   r$   r$   r$   r%   r(   þ   rj   r(   c                   @  r^   )	r]   r_   r   r   r`   c                 C  rm   rb   )rc   r   rT   r   re   r$   r$   r%   rf   	  rn   z)AsyncSpeechWithStreamingResponse.__init__Nrl   ri   r$   r$   r$   r%   r]     rj   r]   )+Ú
__future__r   Útypingr   Útyping_extensionsr   ÚhttpxÚ r   Ú_typesr   r   r	   r
   r   r   r   Ú_utilsr   r   Ú_compatr   Ú	_resourcer   r   Ú	_responser   r   r   r   Útypes.audior   Ú_base_clientr   Útypes.audio.speech_modelr   Ú__all__r   r   r   r\   r(   r]   r$   r$   r$   r%   Ú<module>   s(   $hh		
