Google Cloud 文字轉語音
Google Cloud Text-to-Speech 使開發人員能夠合成具有 100 多種聲音的自然語音,這些聲音以多種語言和變體提供。 它應用 DeepMind 在 WaveNet 方面的開創性研究和 Google 強大的神經網路,以提供最高的保真度。
它支持多種語言,包括英語、德語、波蘭語、西班牙語、意大利語、法語、葡萄牙語和印地語。
此筆記本展示了如何與Google Cloud Text-to-Speech API
交互以實現語音合成功能。
首先,您需要設置一個 Google Cloud 專案。 您可以按照此處的說明進行操作。
!pip install --upgrade langchain-google-community[texttospeech]
實例化
from langchain_google_community import TextToSpeechTool
API 參考:TextToSpeechTool
已棄用的 GoogleCloudTextToSpeechTool
from langchain_community.tools import GoogleCloudTextToSpeechTool
API 參考:GoogleCloudTextToSpeechTool
text_to_speak = "Hello world!"
tts = GoogleCloudTextToSpeechTool()
tts.name
我們可以產生音訊,將其保存到臨時文件,然後播放。
speech_file = tts.run(text_to_speak)