U
    ·ÜŸjË  ã                   @  sÊ   d dl mZ d dlZd dlmZmZmZmZ d dl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lmZ erˆd dlmZ dddœdd„ZG dd„ deƒZG dd„ deƒZG dd„ dƒZdS )é    )ÚannotationsN)ÚTYPE_CHECKINGÚAnyÚOptionalÚcast)ÚArgumentParseré   )Ú
get_clientÚprint_modelé   )Ú	NOT_GIVEN)Ú	BaseModel)ÚBufferReader)ÚTranscription)Ú_SubParsersActionz!_SubParsersAction[ArgumentParser]ÚNone)Ú	subparserÚreturnc                 C  sæ   |   d¡}|jddtdd� |jddtdd	� |jd
td� |jdtd� |jddtd� |jdtd� |jtjtd� |   d¡}|jddtdd	� |jddtdd� |jd
td� |jddtd� |jdtd� |jtjt	d� d S )Nzaudio.transcriptions.createz-mz--modelz	whisper-1)ÚtypeÚdefaultz-fz--fileT)r   Úrequiredz--response-format)r   z
--languagez-tz--temperaturez--prompt)ÚfuncZ
args_modelzaudio.translations.create)
Ú
add_parserÚadd_argumentÚstrÚfloatÚset_defaultsÚCLIAudioÚ
transcribeÚCLITranscribeArgsÚ	translateÚCLITranslationArgs)r   Úsub© r#   ú9/tmp/pip-unpacked-wheel-2qj3ofc_/openai/cli/_api/audio.pyÚregister   s    

r%   c                   @  sN   e Zd ZU ded< ded< dZded< dZded< dZded	< dZded
< dS )r   r   ÚmodelÚfileNúOptional[str]Úresponse_formatÚlanguageúOptional[float]ÚtemperatureÚprompt©Ú__name__Ú
__module__Ú__qualname__Ú__annotations__r)   r*   r,   r-   r#   r#   r#   r$   r   .   s   
r   c                   @  sN   e Zd ZU ded< ded< dZded< dZded< dZded	< dZded
< dS )r!   r   r&   r'   Nr(   r)   r*   r+   r,   r-   r.   r#   r#   r#   r$   r!   7   s   
r!   c                   @  s4   e Zd Zedddœdd„ƒZedddœdd„ƒZd	S )
r   r   r   )Úargsr   c                 C  s”   t | jdƒ�}t| ¡ dd�}W 5 Q R X tdtƒ jjj| j|f| j	| j
pJt| jpRt| jpZttt| jƒd�ƒ}t|tƒrˆtj |d ¡ nt|ƒ d S )NÚrbúUpload progress©ÚdescúTranscription | str)r'   r&   r*   r,   r-   r)   Ú
)Úopenr'   r   Úreadr   r	   ÚaudioZtranscriptionsÚcreater&   r*   r   r,   r-   r   r)   Ú
isinstancer   ÚsysÚstdoutÚwriter
   ©r3   Zfile_readerZbuffer_readerr&   r#   r#   r$   r   A   s     

øþ
zCLIAudio.transcriber!   c              
   C  sŒ   t | jdƒ�}t| ¡ dd�}W 5 Q R X tdtƒ jjj| j|f| j	| j
pJt| jpRttt| jƒd�ƒ}t|tƒr€tj |d ¡ nt|ƒ d S )Nr4   r5   r6   r8   )r'   r&   r,   r-   r)   r9   )r:   r'   r   r;   r   r	   r<   Ztranslationsr=   r&   r,   r   r-   r   r)   r>   r   r?   r@   rA   r
   rB   r#   r#   r$   r    X   s    

ùþ
zCLIAudio.translateN)r/   r0   r1   Ústaticmethodr   r    r#   r#   r#   r$   r   @   s   r   )Ú
__future__r   r?   Útypingr   r   r   r   Úargparser   Ú_utilsr	   r
   Ú_typesr   Z_modelsr   Z	_progressr   Ztypes.audior   r   r%   r   r!   r   r#   r#   r#   r$   Ú<module>   s   		