This directory contains samples for Google Cloud Text-to-Speech API. The `Google Cloud Text To Speech API`_ enables you to generate and customize synthesized speech from text or SSML.
This sample requires you to have authentication setup. Refer to the Authentication Getting Started Guide for instructions on setting up credentials for applications.
Clone python-docs-samples and change directory to the sample directory you want to use.
$ git clone https://github.com/GoogleCloudPlatform/python-docs-samples.git
Install pip and virtualenv if you do not already have them. You may want to refer to the Python Development Environment Setup Guide for Google Cloud Platform for instructions.
Create a virtualenv. Samples are compatible with Python 3.6+.
$ virtualenv env $ source env/bin/activate
Install the dependencies needed to run the samples.
$ pip install -r requirements.txt
To run this sample:
$ python quickstart.py
To run this sample:
$ python list_voices.py
To run this sample:
$ python synthesize_text.py
usage: synthesize_text.py [-h] (--text TEXT | --ssml SSML)
Google Cloud Text-To-Speech API sample application .
Example usage:
python synthesize_text.py --text "hello"
python synthesize_text.py --ssml "<speak>Hello there.</speak>"
optional arguments:
-h, --help show this help message and exit
--text TEXT The text from which to synthesize speech.
--ssml SSML The ssml string from which to synthesize speech.
To run this sample:
$ python synthesize_file.py
usage: synthesize_file.py [-h] (--text TEXT | --ssml SSML)
Google Cloud Text-To-Speech API sample application .
Example usage:
python synthesize_file.py --text resources/hello.txt
python synthesize_file.py --ssml resources/hello.ssml
optional arguments:
-h, --help show this help message and exit
--text TEXT The text file from which to synthesize speech.
--ssml SSML The ssml file from which to synthesize speech.
To run this sample:
$ python audio_profile.py
usage: audio_profile.py [-h] [--output OUTPUT] [--text TEXT]
[--effects_profile_id EFFECTS_PROFILE_ID]
Google Cloud Text-To-Speech API sample application for audio profile.
Example usage:
python audio_profile.py --text "hello" --effects_profile_id
"telephony-class-application" --output "output.mp3"
optional arguments:
-h, --help show this help message and exit
--output OUTPUT The output mp3 file.
--text TEXT The text from which to synthesize speech.
--effects_profile_id EFFECTS_PROFILE_ID
The audio effects profile id to be applied.
This sample uses the Google Cloud Client Library for Python. You can read the documentation for more details on API usage and use GitHub to browse the source and report issues.