
    љi?
                     v    S SK r 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\\\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$ )GoogleSpeechSynthesizer   zja-JPNLINEAR16d      g      $@F)default_languagestyle_mapperaudio_formatmax_connectionsmax_keepalive_connectionstimeoutpreprocessorsdebuggoogle_api_keyspeakerr   r   r   r   r   r   r   r   c       
   	         > [         TU ]  UUUUU	U
S9  Xl        X l        X0l        XPl        U R                  U R                  0U l        g )N)r   r   r   r   r   r   )super__init__r   r   r   r   	voice_map)selfr   r   r   r   r   r   r   r   r   r   	__class__s              Q/home/james-whalen/.local/lib/python3.13/site-packages/aiavatar/sts/tts/google.pyr    GoogleSpeechSynthesizer.__init__   sX     	%+&?' 	 	
 - 0(//>    returnc                 ~   > [         TU ]  5       nU R                  US'   U R                  US'   U R                  US'   U$ )Nr   r   r   )r   
get_configr   r   r   )r   configr   s     r   r#   "GoogleSpeechSynthesizer.get_config(   sD    #% LLy%)%:%:!"!%!2!2~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U R                  U R                  S.nU(       aH  UR                  S5      (       a  UR                  SS5      nX0R                  ;   a  X0R                  U   S.nU R                  R                  SU R                   3SU0USU R                  0S.S	9I S h  vN nUR                  5       n[         R"                  " US
   5      $  N N/7f)NzSpeech synthesize: )languageCodenamezzh-zcmn-CNz;https://texttospeech.googleapis.com/v1/text:synthesize?key=r&   audioEncoding)inputvoiceaudioConfig)urljsonaudioContent)stripbytesr   loggerinfo
preprocessr   r   
startswithreplacer   http_clientpostr   r   r1   base64	b64decode)r   r&   r'   r(   processed_textr.   resp	resp_jsons           r   
synthesize"GoogleSpeechSynthesizer.synthesize/   s    4::<<7N::KK-dV45  $tJJ "&!6!6M""5))#++E8<>>))1>>(;ST %%**MdNaNaMbc .1 /1B1BC + 
 
 IIK		. 9::- K
s%   A%E'D>(B(EE .E E)r   r   r   r   r   )NN)__name__
__module____qualname____firstlineno__strr   intfloatr   r   boolr   dictr#   r4   rA   __static_attributes____classcell__)r   s   @r   r	   r	      s     !('+&")+/3? ? 	?
 ? 38n? ? ? $'? ? O,? ? ?8D ;S ;d ;S ;\a ; ;r    r	   )r<   loggingtypingr   r    r   preprocessorr   	getLoggerrC   r5   r	    r    r   <module>rT      s5        ) 
		8	$B;/ B;r    