o
    hD                     @  s   d dl mZ d dlZd dlmZ d dlmZ d dlmZm	Z	m
Z
 ddlmZmZ ddlmZmZ dd	lmZ d
ZdZe
d Z	 eG dd dZG dd dejZG dd dejZeG dd dZG dd dejZG dd dejZdS )    )annotationsN)AsyncIterator)	dataclass)AnyCallableLiteral   )npnpt)
AudioInputStreamedAudioInput)get_sentence_based_splitterzYYou will receive partial sentences. Do not complete the sentence, just read out the text.x   )	alloyashcoralechofableonyxnovasageshimmerc                   @  sv   e Zd ZU dZdZded< 	 dZded< 	 ejZ	ded	< 	 dZ
d
ed< 	 dZded< 	 e Zded< 	 dZded< dS )TTSModelSettingszSettings for a TTS model.NzTTSVoice | Nonevoicer   intbuffer_sizeznpt.DTypeLikedtypezYCallable[[npt.NDArray[np.int16 | np.float32]], npt.NDArray[np.int16 | np.float32]] | Nonetransform_datazXYou will receive partial sentences. Do not complete the sentence just read out the text.strinstructionsz Callable[[str], tuple[str, str]]text_splitterfloat | Nonespeed)__name__
__module____qualname____doc__r   __annotations__r   r	   int16r   r   r   r   r    r"    r)   r)   S/var/www/html/openai_agents/venv/lib/python3.10/site-packages/agents/voice/model.pyr      s$   
 

r   c                   @  s4   e Zd ZdZeejdddZejdd
dZdS )TTSModelz?A text-to-speech model that can convert text into audio output.returnr   c                 C     dS )zThe name of the TTS model.Nr)   selfr)   r)   r*   
model_nameC      zTTSModel.model_nametextsettingsr   AsyncIterator[bytes]c                 C  r-   )zGiven a text string, produces a stream of audio bytes, in PCM format.

        Args:
            text: The text to convert to audio.

        Returns:
            An async iterator of audio bytes, in PCM format.
        Nr)   )r/   r2   r3   r)   r)   r*   runI      
zTTSModel.runNr,   r   )r2   r   r3   r   r,   r4   )	r#   r$   r%   r&   propertyabcabstractmethodr0   r5   r)   r)   r)   r*   r+   @   s    r+   c                   @  s0   e Zd ZdZejd
ddZejdddZd	S )StreamedTranscriptionSessionz(A streamed transcription of audio input.r,   AsyncIterator[str]c                 C  r-   )zYields a stream of text transcriptions. Each transcription is a turn in the conversation.

        This method is expected to return only after `close()` is called.
        Nr)   r.   r)   r)   r*   transcribe_turnsY   s   z-StreamedTranscriptionSession.transcribe_turnsNonec                      dS )zCloses the session.Nr)   r.   r)   r)   r*   closea   s   z"StreamedTranscriptionSession.closeN)r,   r<   )r,   r>   )r#   r$   r%   r&   r9   r:   r=   r@   r)   r)   r)   r*   r;   V   s    r;   c                   @  sH   e Zd ZU dZdZded< 	 dZded< 	 dZded< 	 dZded	< dS )
STTModelSettingsz$Settings for a speech-to-text model.N
str | Nonepromptlanguager!   temperaturezdict[str, Any] | Noneturn_detection)	r#   r$   r%   r&   rC   r'   rD   rE   rF   r)   r)   r)   r*   rA   g   s   
 rA   c                   @  sD   e Zd ZdZeejdddZejdddZejdddZ	dS )STTModelz>A speech-to-text model that can convert audio input into text.r,   r   c                 C  r-   )zThe name of the STT model.Nr)   r.   r)   r)   r*   r0   {   r1   zSTTModel.model_nameinputr   r3   rA   trace_include_sensitive_databool"trace_include_sensitive_audio_datac                   r?   )a  Given an audio input, produces a text transcription.

        Args:
            input: The audio input to transcribe.
            settings: The settings to use for the transcription.
            trace_include_sensitive_data: Whether to include sensitive data in traces.
            trace_include_sensitive_audio_data: Whether to include sensitive audio data in traces.

        Returns:
            The text transcription of the audio input.
        Nr)   r/   rH   r3   rI   rK   r)   r)   r*   
transcribe   s   zSTTModel.transcriber   r;   c                   r?   )a  Creates a new transcription session, which you can push audio to, and receive a stream
        of text transcriptions.

        Args:
            input: The audio input to transcribe.
            settings: The settings to use for the transcription.
            trace_include_sensitive_data: Whether to include sensitive data in traces.
            trace_include_sensitive_audio_data: Whether to include sensitive audio data in traces.

        Returns:
            A new transcription session.
        Nr)   rL   r)   r)   r*   create_session   s   zSTTModel.create_sessionNr7   )
rH   r   r3   rA   rI   rJ   rK   rJ   r,   r   )
rH   r   r3   rA   rI   rJ   rK   rJ   r,   r;   )
r#   r$   r%   r&   r8   r9   r:   r0   rM   rN   r)   r)   r)   r*   rG   x   s    rG   c                   @  s0   e Zd ZdZejdddZejdd	d
ZdS )VoiceModelProviderzThe base interface for a voice model provider.

    A model provider is responsible for creating speech-to-text and text-to-speech models, given a
    name.
    r0   rB   r,   rG   c                 C  r-   )zGet a speech-to-text model by name.

        Args:
            model_name: The name of the model to get.

        Returns:
            The speech-to-text model.
        Nr)   r/   r0   r)   r)   r*   get_stt_model   r6   z VoiceModelProvider.get_stt_modelr+   c                 C  r-   )z#Get a text-to-speech model by name.Nr)   rP   r)   r)   r*   get_tts_model   s    z VoiceModelProvider.get_tts_modelN)r0   rB   r,   rG   )r0   rB   r,   r+   )r#   r$   r%   r&   r9   r:   rQ   rR   r)   r)   r)   r*   rO      s    rO   )
__future__r   r9   collections.abcr   dataclassesr   typingr   r   r   importsr	   r
   rH   r   r   utilsr   DEFAULT_TTS_INSTRUCTIONSDEFAULT_TTS_BUFFER_SIZETTSVoicer   ABCr+   r;   rA   rG   rO   r)   r)   r)   r*   <module>   s*    *5