
    љi#
                     n    S SK r S SKJrJr  SSKJr  SSKJr  \ R                  " \	5      r
 " S S\5      rg)    N)DictList   )SpeechSynthesizer)TTSPreprocessorc                      ^  \ rS rSrSSSSSSSSS	SS
S.S\S\S\S\S\S\\\4   S\S\S\S\S\\	   S\
4U 4S jjjrS\4U 4S jjrS S\S\S\S\4S jjrSrU =r$ )!OpenAISpeechSynthesizer	   zhttps://api.openai.com/v1sageztts-1Nwavd      g      $@F)base_urlspeakermodelinstructionsstyle_mapperaudio_formatmax_connectionsmax_keepalive_connectionstimeoutpreprocessorsdebugopenai_api_keyr   r   r   r   r   r   r   r   r   r   r   c          	      r   > [         TU ]  UUU	U
UUS9  Xl        X l        X0l        X@l        XPl        Xpl        g )N)r   r   r   r   r   r   )super__init__r   r   r   r   r   r   )selfr   r   r   r   r   r   r   r   r   r   r   r   	__class__s                Q/home/james-whalen/.local/lib/python3.13/site-packages/aiavatar/sts/tts/openai.pyr    OpenAISpeechSynthesizer.__init__
   sL      	%+&?' 	 	
 - 
((    returnc                    > [         TU ]  5       nU R                  US'   U R                  US'   U R                  US'   U R
                  US'   U R                  US'   U$ )Nr   r   r   r   r   )r   
get_configr   r   r   r   r   )r   configr   s     r    r%   "OpenAISpeechSynthesizer.get_config)   s^    #% LLy**w!%!2!2~!%!2!2~!]]zr"   text
style_infolanguagec           
         #    U(       a  UR                  5       (       d
  [        5       $ U R                  (       a  [        R	                  SU 35        U R                  XU5      I S h  vN nSU R                  ;   a  U R                  nSU R                  0nO U R                   S3nSSU R                   30nU R                  R                  UUU R                  U R                  UU R                  SS.S	9I S h  vN nUR                  $  N N7f)
NzSpeech synthesize: azurezapi-keyz/audio/speechAuthorizationzBearer r   )r   voiceinputr   response_format)urlheadersjson)stripbytesr   loggerinfo
preprocessr   r   http_clientpostr   r   r   content)r   r(   r)   r*   processed_textr1   r2   resps           r    
synthesize"OpenAISpeechSynthesizer.synthesize2   s     4::<<7N::KK-dV45  $tJJ dmm#--C $"5"56G]]O=1C&'$2E2E1F(GHG %%**' $ 1 1#( + 
 
 ||1 K
s%   A%D'D
(BD9D:DD)r   r   r   r   r   r   )NN)__name__
__module____qualname____firstlineno__strr   intfloatr   r   boolr   dictr%   r5   r>   __static_attributes____classcell__)r   s   @r    r	   r	   	   s    
 4 '+!")+/3) ) 	)
 ) ) ) 38n) ) ) $') ) O,) ) )>D  S  d  S  \a    r"   r	   )loggingtypingr   r    r   preprocessorr   	getLoggerr@   r6   r	    r"   r    <module>rQ      s0       )			8	$I/ Ir"   