Using Client Libraries

  1. Prerequisite
    1. 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
    2. 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 macOS export GOOGLE_APPLICATION_CREDENTIALS = "[PATH]"
    3. Install and initialize the Cloud SDK
  2. Install client library :\colon pip install --upgrade google-cloud-speech
  3. Make an audio transcription request:\colon Run example[1]
  4. Clean up:\colon 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:\colon

  1. 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
    
  2. Download one of the following
    • Linux 64-bit(x86_64)
    • Linux 32-bit(x86)
  3. 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.

  4. 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:\colon ./google-cloud-sdk/install.sh

  5. Run cloud init to initialize the SDK:\colon ./google-cloud-sdk/bin/gcloud init

  6. Optional. Install additional components using component manager. [Default:\colon gcloud, bq, gsutil, and core.

Install the Client Library

  1. Before installing the library, make sure you've prepared your environment for Python development.

  2. 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 ```

[0] https://cloud.google.com/speech-to-text/docs/quickstart-client-libraries#client-libraries-install-python)

[1] https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/speech/cloud-client/quickstart.py

results matching ""

    No results matching ""