[docs]@deprecated(since="0.0.33",removal="1.0",alternative_import="langchain_google_community.TextToSpeechTool",)classGoogleCloudTextToSpeechTool(BaseTool):# type: ignore[override]"""Tool 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 """name:str="google_cloud_texttospeech"description:str=("A 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. ")_client:Anydef__init__(self,**kwargs:Any)->None:"""Initializes private fields."""texttospeech=_import_google_cloud_texttospeech()super().__init__(**kwargs)self._client=texttospeech.TextToSpeechClient(client_info=get_client_info(module="text-to-speech"))def_run(self,input_text:str,language_code:str="en-US",ssml_gender:Optional[texttospeech.SsmlVoiceGender]=None,audio_encoding:Optional[texttospeech.AudioEncoding]=None,run_manager:Optional[CallbackManagerForToolRun]=None,)->str:"""Use the tool."""texttospeech=_import_google_cloud_texttospeech()ssml_gender=ssml_genderortexttospeech.SsmlVoiceGender.NEUTRALaudio_encoding=audio_encodingortexttospeech.AudioEncoding.MP3response=self._client.synthesize_speech(input=texttospeech.SynthesisInput(text=input_text),voice=texttospeech.VoiceSelectionParams(language_code=language_code,ssml_gender=ssml_gender),audio_config=texttospeech.AudioConfig(audio_encoding=audio_encoding),)suffix=_encoding_file_extension_map(audio_encoding)withtempfile.NamedTemporaryFile(mode="bx",suffix=suffix,delete=False)asf:f.write(response.audio_content)returnf.name