
    g                         d dl Z d dlmZmZ d dlmZmZ 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 dd	lmZmZmZ  G d
 de      Zy)    N)AnyOptional)AsyncAzureOpenAIAzureOpenAI)	BaseModel)get_audio_file_name)	FileTypes)TranscriptionResponse convert_to_model_response_object   )AzureChatCompletionget_azure_ad_token_from_oidc!select_azure_base_url_or_endpointc                       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fdZ	 	 	 	 ddedededededed	e
e   d
e
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returnc                    ||d|}|
|	||d}t        |      }|||d<   n#|!|j                  d      rt        |      }||d<   |||d<   |du r| j                  ||||||	||||	
      S |t	        dd
t
        j                  i|}n|}|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d}t-        |||d      }|S )N)r   file)r   azure_endpointazure_deploymentr   )azure_client_paramsr   zoidc/r   r   T)
r   datar   r   r   r   clientr#   r   r   http_clientaudio_file_AuthorizationBearer headersr   r   complete_input_dictinputr   additional_argsr   textr,   r.   r   r/   original_response	whisper-1azurer   custom_llm_provideraudio_transcription)response_objectmodel_response_objecthidden_paramsresponse_type )r   
startswithr   async_audio_transcriptionsr   litellmclient_sessionpre_calluuiduuid4r   	_base_url_uri_referenceaudiotranscriptionscreate
isinstancer   
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                        \/var/www/openai/venv/lib/python3.12/site-packages/litellm/llms/azure/audio_transcriptions.pyaudio_transcriptionsz,AzureAudioTranscription.audio_transcriptions   s     
FoF '& %	
 @ 3
 -4	*'((1!=n!M4B 01"1<.T!22%-!$7'' 3   >&a73I3IaM`aL!L 	

~. ((+w|7K7K6L-MN(22AA"&'+	 	 		
 <<%%44;; 

#
 h	*#+#6#6#8 #8h#G#R#R#T  	%j12D92	 	 	
 #.gN0Pau  N\  ly  I^  1_    r$   r#   c           	      h  K   d }	 |	t        di |dt        j                  i}n|	}|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%                         }|j)                  t+        |      |dd|j                   i|j                  j                  d|d|
       ddd}t-        ||||d      }|S 7 # t.        $ r(}|j)                  t0        |t3        |             |d }~ww xY ww)Nr&   r'   r(   r)   Tr*   r-   r   r0   r2   r4   r5   r6   r8   )_response_headersr9   r:   r;   r<   )r.   r   r3   r=   )r   r@   aclient_sessionrB   rC   rD   r   rE   rF   rG   rH   with_raw_responserI   dictr+   parserJ   r   rK   r
   rL   r   r   	Exceptionr.   str)rM   r   r$   r   r   r#   r   r   r   r%   r   rO   async_azure_clientraw_responser+   rP   r;   es                     rR   r?   z2AzureAudioTranscription.async_audio_transcriptionsm   s     C	~%5 &)& ' 7 7&"
 &,"   #DJJL>2*22 (73E3M3M2N)O  !3 < < K K&*+/! !  W(..==OOVV $+   <//0G#))+H(I.'/':':'<$'<('K'V'V'X$ !!)*5 (73E3M3M2N)O  !3 < < K K&*+/! #7 "  '2'RM7") 4&4+3H OGH  	!!"%a& " 
 G	s<   F2B4E> :E<;C E> ;F2<E> >	F/#F**F//F2)NNNNNF)NNNN)__name__
__module____qualname__r\   r	   rY   r   r
   floatintr   boolrS   r?   r=   rT   rR   r   r      s,    "&"&%)(,$WW W 	W
 W .W W W #W 3-W c]W !W W 
WB "&"&QQ Q .	Q
 Q "Q Q #Q 3-QrT   r   )rC   typingr   r   openair   r   pydanticr   r@   ,litellm.litellm_core_utils.audio_utils.utilsr   litellm.types.utilsr	   litellm.utilsr
   r   r5   r   r   r   r   r=   rT   rR   <module>rl      s6       0   L ) Q k1 krT   