Create and save these credentials as a ~/key.json JSON file by using the following command: gcloud iam service-accounts keys create ~/key.json \
Next, create credentials that your Python code will use to login as your new service account. Next, create a new service account to access the Text-to-Speech API by using: gcloud iam service-accounts create my-tts-sa \ In this section, you will use the Cloud SDK to create a service account and then create credentials you will need to authenticate as the service account.įirst, set a PROJECT_ID environment variable: export PROJECT_ID=$(gcloud config get-value core/project) Like any other user account, a service account is represented by an email address. A Service Account belongs to your project and it is used by the Python client library to make Text-to-Speech API requests. In order to make requests to the Text-to-Speech API, you need to use a Service Account. Note: In case of error, go back to the previous step and check your setup. Using Cloud Shell, you can enable the API with the following command: gcloud services enable
īefore you can begin using the Text-to-Speech API, you must enable the API. If it is not, you can set it with this command: gcloud config set project Ĭommand output Updated property.
If you've never started Cloud Shell before, you're presented with an intermediate screen (below the fold) describing what it is.
New users of Google Cloud are eligible for the $300 USD Free Trial program.
Be sure to to follow any instructions in the "Cleaning up" section which advises you how to shut down resources so you don't incur billing beyond this tutorial. Running through this codelab shouldn't cost much, if anything at all. Next, you'll need to enable billing in Cloud Console in order to use Google Cloud resources.If you're using a Google Workspace account, then choose a location that makes sense for your organization. Note: If you're using a Gmail account, you can leave the default location set to No organization. It will be referred to later in this codelab as PROJECT_ID. Remember the project ID, a unique name across all Google Cloud projects (the name above has already been taken and will not work for you, sorry!). Note: You can easily access Cloud Console by memorizing its URL, which is. (If you don't already have a Gmail or Google Workspace account, you must create one.)
How to install the client library for Python.In this tutorial, you will focus on using the Text-to-Speech API with Python. It also supports Speech Synthesis Markup Language (SSML) inputs to specify pauses, numbers, date and time formatting, and other pronunciation instructions. The API converts text into audio formats such as WAV, MP3, or Ogg Opus. The Text-to-Speech API enables developers to generate human-like speech.