o
    ͩZhm5                     @  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 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)List)LiteralN   )_legacy_response)	NOT_GIVENBodyQueryHeadersNotGiven)maybe_transformasync_maybe_transform)cached_property)SyncAPIResourceAsyncAPIResource)to_streamed_response_wrapper"async_to_streamed_response_wrapper)make_request_options)#transcription_session_create_params)TranscriptionSessionTranscriptionSessionsAsyncTranscriptionSessionsc                   @  J   e Zd Zed!ddZed"ddZeeeeeeddded	
d#dd ZdS )$r   return$TranscriptionSessionsWithRawResponsec                 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/var/www/html/lang_env/lib/python3.10/site-packages/openai/resources/beta/realtime/transcription_sessions.pywith_raw_response      z'TranscriptionSessions.with_raw_response*TranscriptionSessionsWithStreamingResponsec                 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-TranscriptionSessions.with_streaming_responseN
includeinput_audio_formatinput_audio_noise_reductioninput_audio_transcription
modalitiesturn_detectionextra_headersextra_query
extra_bodytimeoutr(   List[str] | NotGivenr)   5Literal['pcm16', 'g711_ulaw', 'g711_alaw'] | NotGivenr*   Gtranscription_session_create_params.InputAudioNoiseReduction | NotGivenr+   Ftranscription_session_create_params.InputAudioTranscription | NotGivenr,   )List[Literal['text', 'audio']] | NotGivenr-   <transcription_session_create_params.TurnDetection | NotGivenr.   Headers | Noner/   Query | Noner0   Body | Noner1   'float | httpx.Timeout | None | NotGivenr   c       
      
   C  sD   ddi|pi }| j dt||||||dtjt|||	|
dtdS )W  
        Create an ephemeral API token for use in client-side applications with the
        Realtime API specifically for realtime transcriptions. Can be configured with
        the same session parameters as the `transcription_session.update` client event.

        It responds with a session object, plus a `client_secret` key which contains a
        usable ephemeral API token that can be used to authenticate browser clients for
        the Realtime API.

        Args:
          include:
              The set of items to include in the transcription. Current available items are:

              - `item.input_audio_transcription.logprobs`

          input_audio_format: The format of input audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`. For
              `pcm16`, input audio must be 16-bit PCM at a 24kHz sample rate, single channel
              (mono), and little-endian byte order.

          input_audio_noise_reduction: Configuration for input audio noise reduction. This can be set to `null` to turn
              off. Noise reduction filters audio added to the input audio buffer before it is
              sent to VAD and the model. Filtering the audio can improve VAD and turn
              detection accuracy (reducing false positives) and model performance by improving
              perception of the input audio.

          input_audio_transcription: Configuration for input audio transcription. The client can optionally set the
              language and prompt for transcription, these offer additional guidance to the
              transcription service.

          modalities: The set of modalities the model can respond with. To disable audio, set this to
              ["text"].

          turn_detection: Configuration for turn detection, ether Server VAD or Semantic VAD. This can be
              set to `null` to turn off, in which case the client must manually trigger model
              response. Server VAD means that the model will detect the start and end of
              speech based on audio volume and respond at the end of user speech. Semantic VAD
              is more advanced and uses a turn detection model (in conjuction with VAD) to
              semantically estimate whether the user has finished speaking, then dynamically
              sets a timeout based on this probability. For example, if user audio trails off
              with "uhhm", the model will score a low probability of turn end and wait longer
              for the user to continue speaking. This can be useful for more natural
              conversations, but may have a higher latency.

          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
        OpenAI-Betaassistants=v2 /realtime/transcription_sessionsr(   r)   r*   r+   r,   r-   r.   r/   r0   r1   bodyoptionsZcast_to)_postr   r    TranscriptionSessionCreateParamsr   r   r   r(   r)   r*   r+   r,   r-   r.   r/   r0   r1   r   r   r    create.   s$   DzTranscriptionSessions.create)r   r   )r   r#   r(   r2   r)   r3   r*   r4   r+   r5   r,   r6   r-   r7   r.   r8   r/   r9   r0   r:   r1   r;   r   r   __name__
__module____qualname__r   r!   r%   r   rH   r   r   r   r    r           	c                   @  r   )$r   r   )AsyncTranscriptionSessionsWithRawResponsec                 C  r   r   )rO   r   r   r   r    r!      r"   z,AsyncTranscriptionSessions.with_raw_response/AsyncTranscriptionSessionsWithStreamingResponsec                 C  r   r$   )rP   r   r   r   r    r%      r&   z2AsyncTranscriptionSessions.with_streaming_responseNr'   r(   r2   r)   r3   r*   r4   r+   r5   r,   r6   r-   r7   r.   r8   r/   r9   r0   r:   r1   r;   r   c       
      
     sR   ddi|pi }| j dt||||||dtjI dH t|||	|
dtdI dH S )r<   r=   r>   r?   r@   NrA   rB   )rE   r   r   rF   r   r   rG   r   r   r    rH      s&   Dz!AsyncTranscriptionSessions.create)r   rO   )r   rP   rI   rJ   r   r   r   r    r      rN   c                   @     e Zd ZdddZdS )	r   transcription_sessionsr   r   Nonec                 C     || _ t|j| _d S N)_transcription_sessionsr   Zto_raw_response_wrapperrH   r   rR   r   r   r    __init__      
z-TranscriptionSessionsWithRawResponse.__init__NrR   r   r   rS   rK   rL   rM   rX   r   r   r   r    r          r   c                   @  rQ   )	rO   rR   r   r   rS   c                 C  rT   rU   )rV   r   Zasync_to_raw_response_wrapperrH   rW   r   r   r    rX      rY   z2AsyncTranscriptionSessionsWithRawResponse.__init__NrR   r   r   rS   r[   r   r   r   r    rO      r\   rO   c                   @  rQ   )	r#   rR   r   r   rS   c                 C     || _ t|j| _d S rU   )rV   r   rH   rW   r   r   r    rX        
z3TranscriptionSessionsWithStreamingResponse.__init__NrZ   r[   r   r   r   r    r#     r\   r#   c                   @  rQ   )	rP   rR   r   r   rS   c                 C  r^   rU   )rV   r   rH   rW   r   r   r    rX     r_   z8AsyncTranscriptionSessionsWithStreamingResponse.__init__Nr]   r[   r   r   r   r    rP     r\   rP   )'
__future__r   typingr   Ztyping_extensionsr   Zhttpx r   _typesr   r   r	   r
   r   _utilsr   r   _compatr   Z	_resourcer   r   	_responser   r   Z_base_clientr   Ztypes.beta.realtimer   Z)types.beta.realtime.transcription_sessionr   __all__r   r   r   rO   r#   rP   r   r   r   r    <module>   s(   mm			