
    j                         d dl mZ d dl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 d dlmZ d dlmZmZmZ dd	lmZ dd
lmZ  G d de      Zy)    )uuid)Any	CoroutineOptionalUnion)AsyncAzureOpenAIAzureOpenAI)	BaseModel)get_audio_file_name)	FileTypes)TranscriptionResponse convert_to_model_response_object extract_duration_from_srt_or_vtt   )AzureChatCompletion)AzureOpenAIErrorc            "           e Zd Z	 	 	 	 	 	 	 ddedededededede	d	e
e   d
e
e   de
e   de
e   dede
e   deeeeeef   f   fdZ	 	 	 	 	 	 ddedededededede
e   d	e
e   d
e
e   de
e   defdZy)AzureAudioTranscriptionNmodel
audio_fileoptional_paramslogging_objmodel_responsetimeoutmax_retriesapi_keyapi_baseapi_versionazure_ad_tokenatranscriptionlitellm_paramsreturnc                    ||d|}|du r| j                  ||||||	|||||      S | j                  |
|	||d||      }t        |t              st	        dd      |j                  d	t        j                          |j                  d
d|j                   i|j                  j                  d|d        |j                  j                  j                  di |d|i}t        |t              r|j                         }nt!        |      j                         }|j#                  t%        |      |d|i|       |dd}t'        |||d      }|S )N)r   fileT)r   datar   r   r   r   clientr   r   r   r!   Fr   r   r   r   	_is_asyncr&   r!     z.azure_client is not an instance of AzureOpenAIstatus_codemessageaudio_file_AuthorizationBearer headersr   r    complete_input_dictinputr   additional_argsr   textr2   r4   r   r5   original_responseazurer   custom_llm_provideraudio_transcription)response_objectmodel_response_objecthidden_paramsresponse_type )async_audio_transcriptionsget_azure_openai_client
isinstancer	   r   pre_callr   uuid4r   	_base_url_uri_referenceaudiotranscriptionscreater
   
model_dumpr   	post_callr   r   )selfr   r   r   r   r   r   r   r   r   r   r&   r   r    r!   r%   azure_clientresponsestringified_responser@   final_responses                        /Users/manta/Documents/Projects/TheRoad-I1/backend/.venv/lib/python3.12/site-packages/litellm/llms/azure/audio_transcriptions.pyaudio_transcriptionsz,AzureAudioTranscription.audio_transcriptions   s   " 
FoFT!22%-!''- 3   33#) 4 
 ,4"H  	

~. ((+w|7K7K6L-MN(22AA"&'+	 	 		
 <<%%44;; 

#
 h	*#+#6#6#8 #8h#G#R#R#T  	%j12D92	 	 	
 #(H0Pau  N\  ly  I^  1_    r%   c           	        K   d }	 | j                  ||	||d|
|      }t        |t              st        dd      |j	                  dt        j                          |j                  dd|j                   i|j                  j                  d|d	
        |j                  j                  j                  j                  di |d|i d {   }t        |j                        }|j!                         }t        |t"              r|j%                         }n*t'        |      j%                         }t)        |      }||d<   |j+                  t-        |      |dd|j                   i|j                  j                  d|d	|       |dd}t/        ||||d      }t        |t&              st        dd      |S 7 # t0        $ r(}|j+                  t2        |t5        |             |d }~ww xY ww)NTr'   r)   z9async_azure_client is not an instance of AsyncAzureOpenAIr*   r-   r.   r/   r0   r3   r   r6   durationr8   r:   r;   r=   )_response_headersr>   r?   r@   rA   z4response is not an instance of TranscriptionResponse)r4   r   r9   rB   )rD   rE   r   r   rF   r   rG   r   rH   rI   rJ   rK   with_raw_responserL   dictr1   parser
   rM   r   r   rN   r   r   	Exceptionr4   str)rO   r   r   r%   r   r   r   r   r   r   r&   r   r!   rQ   async_azure_clientraw_responser1   rR   rX   r@   es                        rT   rC   z2AzureAudioTranscription.async_audio_transcriptionse   sM     Q	!%!=!='!- "> " 02BC& #W    #DJJL>2*22 (73E3M3M2N)O  !3 < < K K&*+/! !  W(..==OOVV $+   <//0G#))+H(I.'/':':'<$'<('K'V'V'X$;HE3;$Z0 !!)*5 (73E3M3M2N)O  !3 < < K K&*+/! #7 "  ',GLM7") 4&4+3H h(=>& #R  OUV  	!!"%a& " 
 G	s<   G2CF> F<C-F> ;G2<F> >	G/#G**G//G2)NNNNNFN)NNNNNN)__name__
__module____qualname__r^   r   r[   r   r   floatintr   boolr   r   rU   rC   rB   rV   rT   r   r      s    "&"&%)(,$)-OO O 	O
 O .O O O #O 3-O c]O !O O !O  
$iS:O0O&PP	Q!Or &*!%"&)-aa a 	a
 .a a a c]a #a 3-a !a 
arV   r   N)litellm._uuidr   typingr   r   r   r   openair   r	   pydanticr
   ,litellm.litellm_core_utils.audio_utils.utilsr   litellm.types.utilsr   litellm.utilsr   r   r   r:   r   common_utilsr   r   rB   rV   rT   <module>rp      s;     2 2 0  L )  ' *s1 srV   