
    dh                        S SK Jr  S SKrS SKJrJrJr  S SKJr  S SK	J
r
  S SKJr  S SKJr  \(       a  S SKJr  SS	 jrSS
 jr\" SSSS9 " S S\5      5       rg)    )annotationsN)TYPE_CHECKINGAnyOptional)
deprecated)CallbackManagerForToolRun)BaseTool)get_client_infotexttospeechc                 P     SSK Jn   U $ ! [         a  n[        S5      UeS nAff = f)Nr   r   z`Cannot import google.cloud.texttospeech, please install `pip install google-cloud-texttospeech`.)google.cloudr   ImportError)r   es     k/var/www/html/shao/venv/lib/python3.13/site-packages/langchain_community/tools/google_cloud/texttospeech.py!_import_google_cloud_texttospeechr      s;    -   7
 	s   
 
% %c           
        [        5       nUR                  R                  SUR                  R                  SUR                  R                  SUR                  R
                  SUR                  R                  S0nUR                  U 5      $ )Nz.wavz.mp3z.ogg)r   AudioEncodingLINEAR16MP3OGG_OPUSMULAWALAWget)encodingr   ENCODING_FILE_EXTENSION_MAPs      r   _encoding_file_extension_mapr      s|    46L 	""++V""&&""++V""((&""''# '**844    z0.0.33z1.0z+langchain_google_community.TextToSpeechTool)sinceremovalalternative_importc                     ^  \ rS rSr% SrSrS\S'   SrS\S'   S\S	'   SU 4S
 jjr    S           SS jjr	Sr
U =r$ )GoogleCloudTextToSpeechTool(   zTool that queries the Google Cloud Text to Speech API.

In order to set this up, follow instructions at:
https://cloud.google.com/text-to-speech/docs/before-you-begin
google_cloud_texttospeechstrnamezA wrapper around Google Cloud Text-to-Speech. Useful for when you need to synthesize audio from text. It supports multiple languages, including English, German, Polish, Spanish, Italian, French, Portuguese, and Hindi. descriptionr   _clientc                r   > [        5       n[        TU ]  " S0 UD6  UR                  " [	        SS9S9U l        g)zInitializes private fields.ztext-to-speech)module)client_infoN )r   super__init__TextToSpeechClientr
   r)   )selfkwargsr   	__class__s      r   r/   $GoogleCloudTextToSpeechTool.__init__>   s6    8:"6"#66'/?@
r   c                   [        5       nU=(       d    UR                  R                  nU=(       d    UR                  R                  nU R
                  R                  UR                  " US9UR                  " X#S9UR                  " US9S9n[        U5      n[        R                  " SUSS9 n	U	R                  UR                  5        SSS5        U	R                  $ ! , (       d  f       W	R                  $ = f)	zUse the tool.)text)language_codessml_gender)audio_encoding)inputvoiceaudio_configbxF)modesuffixdeleteN)r   SsmlVoiceGenderNEUTRALr   r   r)   synthesize_speechSynthesisInputVoiceSelectionParamsAudioConfigr   tempfileNamedTemporaryFilewriteaudio_contentr'   )
r1   
input_textr7   r8   r9   run_managerr   responser?   fs
             r   _run GoogleCloudTextToSpeechTool._runH   s     9:!I\%A%A%I%I'I<+E+E+I+I<<11--:>33+ &11P 2 
 .n=((d6%PTUGGH**+ Qvv QPvvs   /C
C8)r)   )r2   r   returnNone)zen-USNNN)rK   r&   r7   r&   r8   z&Optional[texttospeech.SsmlVoiceGender]r9   z$Optional[texttospeech.AudioEncoding]rL   z#Optional[CallbackManagerForToolRun]rQ   r&   )__name__
__module____qualname____firstlineno____doc__r'   __annotations__r(   r/   rO   __static_attributes____classcell__)r3   s   @r   r#   r#   (   s     ,D#+	<   L
 %>B?C;?  <	
 = 9 
 r   r#   )rQ   r   )r   ztexttospeech.AudioEncodingrQ   zOptional[str])
__future__r   rG   typingr   r   r   langchain_core._api.deprecationr   langchain_core.callbacksr   langchain_core.toolsr	   &langchain_community.utilities.vertexair
   r   r   r   r   r#   r-   r   r   <module>ra      sV    "  / / 6 > ) B)
5 
D
4( 4
4r   