mirror of
https://github.com/hwchase17/langchain.git
synced 2025-05-10 01:26:29 +00:00
97 lines
2.5 KiB
Plaintext
97 lines
2.5 KiB
Plaintext
{
|
||
"cells": [
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "a991a6f8-1897-4f49-a191-ae3bdaeda856",
|
||
"metadata": {},
|
||
"source": [
|
||
"# Google Cloud Text-to-Speech\n",
|
||
"\n",
|
||
">[Google Cloud Text-to-Speech](https://cloud.google.com/text-to-speech) enables developers to synthesize natural-sounding speech with 100+ voices, available in multiple languages and variants. It applies DeepMind’s groundbreaking research in WaveNet and Google’s powerful neural networks to deliver the highest fidelity possible.\n",
|
||
"\n",
|
||
"This notebook shows how to interact with the `Google Cloud Text-to-Speech API` to achieve speech synthesis capabilities."
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "9eeb311e-e1bd-4959-8536-4d267f302eb3",
|
||
"metadata": {},
|
||
"source": [
|
||
"First, you need to set up an Google Cloud project. You can follow the instructions [here](https://cloud.google.com/text-to-speech/docs/before-you-begin)."
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 1,
|
||
"id": "0a309c0e-5310-4eaa-8af9-bcbc252e45da",
|
||
"metadata": {},
|
||
"outputs": [],
|
||
"source": [
|
||
"%pip install --upgrade --quiet google-cloud-text-to-speech"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "434b2454-2bff-484d-822c-4026a9dc1383",
|
||
"metadata": {},
|
||
"source": [
|
||
"## Usage"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"id": "2f57a647-9214-4562-a8cf-f263a15d1f40",
|
||
"metadata": {},
|
||
"outputs": [],
|
||
"source": [
|
||
"from langchain_community.tools import GoogleCloudTextToSpeechTool\n",
|
||
"\n",
|
||
"text_to_speak = \"Hello world!\"\n",
|
||
"\n",
|
||
"tts = GoogleCloudTextToSpeechTool()\n",
|
||
"tts.name"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "d4613fed-66f0-47c6-be50-7e7670654427",
|
||
"metadata": {},
|
||
"source": [
|
||
"We can generate audio, save it to the temporary file and then play it."
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 7,
|
||
"id": "f1984844-aa75-4f83-9d42-1c8052d87cc0",
|
||
"metadata": {},
|
||
"outputs": [],
|
||
"source": [
|
||
"speech_file = tts.run(text_to_speak)"
|
||
]
|
||
}
|
||
],
|
||
"metadata": {
|
||
"kernelspec": {
|
||
"display_name": "Python 3 (ipykernel)",
|
||
"language": "python",
|
||
"name": "python3"
|
||
},
|
||
"language_info": {
|
||
"codemirror_mode": {
|
||
"name": "ipython",
|
||
"version": 3
|
||
},
|
||
"file_extension": ".py",
|
||
"mimetype": "text/x-python",
|
||
"name": "python",
|
||
"nbconvert_exporter": "python",
|
||
"pygments_lexer": "ipython3",
|
||
"version": "3.10.12"
|
||
}
|
||
},
|
||
"nbformat": 4,
|
||
"nbformat_minor": 5
|
||
}
|