o
    ¨Ýjn+  ã                   @  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$   úX/var/www/html/chatgpt/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 | httpx2.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://developers.openai.com/api/docs/guides/text-to-speech):
              `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://developers.openai.com/api/docs/guides/text-to-speech#voice-options).
              Custom voices must be created from audio samples. Voices created from text
              prompts are supported only in Live.

          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©r7   r5   r9   r-   r.   r/   r0   Úbearer_authT©r1   r2   r3   r4   Úsecurity©ÚbodyÚoptionsZcast_to)Ú_postr   r   ÚSpeechCreateParamsr   r   ÚHttpxBinaryResponseContent©r#   r5   r7   r9   r-   r.   r/   r0   r1   r2   r3   r4   r$   r$   r%   Úcreate2   s.   ;ù	öûë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   rS   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   )rO   r   r   rP   r   r   rQ   rR   r$   r$   r%   rS   �   s0   €;ù	öûëzAsyncSpeech.create)r   r[   )r   r\   rT   rU   r$   r$   r$   r%   r   ‡   rZ   c                   @  ó   e Zd Zddd„ZdS )	r   Úspeechr   r   ÚNonec                 C  ó   || _ t |j¡| _d S ©N)Ú_speechr   Zto_raw_response_wrapperrS   ©r#   r^   r$   r$   r%   Ú__init__ó   ó   
ÿzSpeechWithRawResponse.__init__N©r^   r   r   r_   ©rV   rW   rX   rd   r$   r$   r$   r%   r   ò   ó    r   c                   @  r]   )	r[   r^   r   r   r_   c                 C  r`   ra   )rb   r   Zasync_to_raw_response_wrapperrS   rc   r$   r$   r%   rd   ü   re   z#AsyncSpeechWithRawResponse.__init__N©r^   r   r   r_   rg   r$   r$   r$   r%   r[   û   rh   r[   c                   @  r]   )	r(   r^   r   r   r_   c                 C  ó   || _ t|jtƒ| _d S ra   )rb   r   rS   r   rc   r$   r$   r%   rd     ó
   
þz$SpeechWithStreamingResponse.__init__Nrf   rg   r$   r$   r$   r%   r(     rh   r(   c                   @  r]   )	r\   r^   r   r   r_   c                 C  rj   ra   )rb   r   rS   r   rc   r$   r$   r%   rd     rk   z)AsyncSpeechWithStreamingResponse.__init__Nri   rg   r$   r$   r$   r%   r\     rh   r\   )+Ú
__future__r   Útypingr   Ztyping_extensionsr   Zhttpx2Ú r   Ú_typesr   r   r	   r
   r   r   r   Z_utilsr   r   Z_compatr   Z	_resourcer   r   Ú	_responser   r   r   r   Ztypes.audior   Z_base_clientr   Ztypes.audio.speech_modelr   Ú__all__r   r   r   r[   r(   r\   r$   r$   r$   r%   Ú<module>   s(   $kk		
