o
    iJ)                     @  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$   W/home/kim/smarthome/.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  sH   ddi|pi }| j dt|||||||dtjt||	|
|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   r1   r2   r3   r4   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&   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   rQ   r$   r$   r$   r%   r          	c                	   @  r   )'r   r   r   AsyncSpeechWithRawResponsec                 C  r    r!   )rY   r"   r$   r$   r%   r&      r'   zAsyncSpeech.with_raw_response AsyncSpeechWithStreamingResponsec                 C  r    r)   )rZ   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                  sV   ddi|pi }| j dt|||||||dtjI dH t||	|
|dtjdI dH S )rD   rE   rF   rG   rH   NrI   rJ   )rM   r   r   rN   r   r   rO   rP   r$   r$   r%   rQ      s(   8	zAsyncSpeech.create)r   rY   )r   rZ   rR   rS   r$   r$   r$   r%   r      rX   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_wrapperrQ   r#   r\   r$   r$   r%   __init__      
zSpeechWithRawResponse.__init__Nr\   r   r   r]   rT   rU   rV   rb   r$   r$   r$   r%   r          r   c                   @  r[   )	rY   r\   r   r   r]   c                 C  r^   r_   )r`   r   Zasync_to_raw_response_wrapperrQ   ra   r$   r$   r%   rb      rc   z#AsyncSpeechWithRawResponse.__init__Nr\   r   r   r]   re   r$   r$   r$   r%   rY      rf   rY   c                   @  r[   )	r(   r\   r   r   r]   c                 C     || _ t|jt| _d S r_   )r`   r   rQ   r   ra   r$   r$   r%   rb      
   
z$SpeechWithStreamingResponse.__init__Nrd   re   r$   r$   r$   r%   r(      rf   r(   c                   @  r[   )	rZ   r\   r   r   r]   c                 C  rh   r_   )r`   r   rQ   r   ra   r$   r$   r%   rb     ri   z)AsyncSpeechWithStreamingResponse.__init__Nrg   re   r$   r$   r$   r%   rZ      rf   rZ   )+
__future__r   typingr   Ztyping_extensionsr   Zhttpx 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   rY   r(   rZ   r$   r$   r$   r%   <module>   s(   $dd		
