Using Client Libraries
- Prerequisite
- Set up a GCP Console project
- Create or select a project
- Enable the Google Speech-to-text API for that project
- Create a service account
- Download a private key as JSON
- Set the environment variable
GOOGLE_APPLICATION_CREDENTIALS
to the file path of the JSON file that contains your service account key. This variable only applies to your current shell session, so if you open a new session, set the variable again. Example: Linux or macOSexport GOOGLE_APPLICATION_CREDENTIALS = "[PATH]"
- Install and initialize the Cloud SDK
- Set up a GCP Console project
- Install client library
pip install --upgrade google-cloud-speech
- Make an audio transcription request Run example[1]
- Clean up GCP Console to delete your project if you do not need it.
Google Cloud SDK
Google Cloud SDK is a set of tools that you can manage resources and applications hosted in Google Cloud Platform.
Google Cloud SDK includes gcloud
, gsutil
, bq
command line tools.
The gcloud
is downloaded along with Cloud SDK; More details can be found in gcloud Overview
Install the latest Cloud Tools version (206.0.0)
Linux
- Make sure your system has Python 2 with a release of Python 2.7.9 or later installed on your system, as the Google SDK doesn't currently support Python 3. You may still have other version Python installed.
python2 --version
- Download one of the following
- Linux 64-bit(x86_64)
- Linux 32-bit(x86)
Extract the contents of the file to any location on your file system. If you would like to replace an existing installation, remove the existing
google-cloud-sdk
directory and extract the archive to the same location.Optional. Use the install script to add Cloud SDK to your path. You'll also be able opt-in to command-completion for your shell and usage statistics collection. Run the script using this command
./google-cloud-sdk/install.sh
Run
cloud init
to initialize the SDK./google-cloud-sdk/bin/gcloud init
Optional. Install additional components using component manager. [Default
gcloud
,bq
,gsutil
, andcore
.
Install the Client Library
Before installing the library, make sure you've prepared your environment for Python development.
type
pip install --upgrade google-cloud-speech
Setting Up a Python Development Environment
This tutorial shows how to prepare your local machine for Python development, including developing Python application that run on Google Cloud Platform (GCP).
If you already have a development environment setup, see Python and Google Cloud Platform to get an overview of how to run Python apps on GCP.
Objectives
- Install the lastest versions of Python 2 and 3
- Install and use virtualenv (anaconda?)
- Install an editor (optional)
- Install the Google Cloud SDK (optional)
- Install the Google Cloud Client Library for Python (optional)
- Install other useful tools
Installing Python
Mac OS X (using homebrew)
$ xcode-select --install
$ brew install python python3
**Windows**
Download the installers for the latest versions of both Python 3 and Python 2 from the [Python website](https://www.python.org/downloads/windows/)
**Linux**
python package
sudo apt update sudo apt install python python-dev python3 python3-dev
pip
wget https://bootstrap.pypa.io/get-pip.py sudo python get-pip.py
##### Installing and using virtualenv(Anaconda)
##### Install an Editor
##### Install the Google Cloud SDK
- `gcloud`{% math %}\colon{% endmath %} access Google Compute Engine
- `gsutil`{% math %}\colon{% endmath %} access Google Cloud Storage
- `bq`{% math %}\colon{% endmath %} access Google BigQuery
##### Install Google Cloud Client Library for Python
The Google Cloud Client Library for Python is the idiomatic way for Python developers to integrate with Google Cloud Platform services, like Cloud Datastore and Cloud Storage. You can install the package for an individual API, like Cloud Storage for example{% math %}\colon{% endmath %}
pip install --upgrade google-cloud-storage ```