Skip to content

Latest commit

 

History

History
 
 

README.md

Speech Samples.

These samples demonstrate how to call the Google Cloud Speech API using C++.

These samples will only build and run on Linux.

Build and Run

  1. Create a project in the Google Cloud Platform Console. If you haven't already created a project, create one now. Projects enable you to manage all Google Cloud Platform resources for your app, including deployment, access control, billing, and services.

    1. Open the Cloud Platform Console.
    2. In the drop-down menu at the top, select Create a project.
    3. Click Show advanced options. Under App Engine location, select a United States location.
    4. Give your project a name.
    5. Make a note of the project ID, which might be different from the project name. The project ID is used in commands and in configurations.
  2. Enable billing for your project. If you haven't already enabled billing for your project, enable billing now. Enabling billing allows the application to consume billable resources such as Speech API calls. See Cloud Platform Console Help for more information about billing settings.

  3. Enable APIs for your project. Click here to visit Cloud Platform Console and enable the Speech API.

  4. Download service account credentials. These samples use service accounts for authentication.

    1. Visit the Cloud Console, and navigate to: API Manager > Credentials > Create credentials > Service account key
    2. Under Service account, select New service account.
    3. Under Service account name, enter a service account name of your choosing. For example, transcriber.
    4. Under Role, select Project > Owner.
    5. Under Key type, leave JSON selected.
    6. Click Create to create a new service account, and download the json credentials file.
    7. Set the GOOGLE_APPLICATION_CREDENTIALS environment variable to point to your downloaded service account credentials:
      export GOOGLE_APPLICATION_CREDENTIALS=/path/to/your/credentials-key.json
      

    See the Cloud Platform Auth Guide for more information.

  5. [Optional] Use Docker You can use Docker to create an image with required dependencies and run the sample.

    1. Follow the instructions here
  6. Install gRPC.

    1. Visit the gRPC github repo and follow the instructions to install gRPC.
    2. Then, follow the instructions in the Pre-requisites section to install protoc.
    3. The examples in this directory have been tested with gRPC 1.4.1 if they do not work for you please include the gRPC version you used in any bug reports.
  7. Generate googleapis gRPC source code.

    1. Visit the googleapis github repo and follow the instructions to Generate gRPC Source Code.
      export LANGUAGE=cpp
      git clone https://github.com/googleapis/googleapis.git
      cd googleapis
      make all
      
    2. Set the environment variable GOOGLEAPIS_GENS_PATH to the path where you generated the gRPC source code. For example:
      export GOOGLEAPIS_GENS_PATH=$HOME/gitrepos/googleapis/gens
      
  8. Download or clone this repo with

    git clone https://github.com/GoogleCloudPlatform/cpp-docs-samples
  9. Run the tests:

    cd cpp-docs-samples/speech/api
    make run_tests