nodejs-docs-samples-speech

0.0.1 • Public • Published
Google Cloud Platform logo

Google Cloud Speech API Node.js Samples

Build

The Cloud Speech API enables easy integration of Google speech recognition technologies into developer applications. Send audio and receive a text transcription from the Cloud Speech API service.

Table of Contents

Setup

  1. Read Prerequisites and How to run a sample first.

  2. Install dependencies:

    With npm:

    npm install
    

    With yarn:

    yarn install
    

Samples

Speech Recognition

View the documentation or the source code.

Usage: node recognize.js --help

Commands:
  sync <filename>           Detects speech in a local audio file.
  sync-gcs <gcsUri>         Detects speech in an audio file located in a Google Cloud Storage bucket.
  sync-words <filename>     Detects speech in a local audio file with word time offset.
  async <filename>          Creates a job to detect speech in a local audio file, and waits for the job to complete.
  async-gcs <gcsUri>        Creates a job to detect speech in an audio file located in a Google Cloud Storage bucket,
                            and waits for the job to complete.
  async-gcs-words <gcsUri>  Creates a job to detect speech  with word time offset in an audio file located in a Google
                            Cloud Storage bucket, and waits for the job to complete.
  stream <filename>         Detects speech in a local audio file by streaming it to the Speech API.
  listen                    Detects speech in a microphone input stream. This command requires that you have SoX
                            installed and available in your $PATH. See
                            https://www.npmjs.com/package/node-record-lpcm16#dependencies

Options:
  --help                 Show help                                                                             [boolean]
  --encoding, -e                                                                          [string] [default: "LINEAR16"]
  --sampleRateHertz, -r                                                                        [number] [default: 16000]
  --languageCode, -l                                                                         [string] [default: "en-US"]

Examples:
  node recognize.js sync ./resources/audio.raw -e LINEAR16 -r 16000
  node recognize.js async-gcs gs://gcs-test-data/vr.flac -e FLAC -r 16000
  node recognize.js stream ./resources/audio.raw  -e LINEAR16 -r 16000
  node recognize.js listen

For more information, see https://cloud.google.com/speech/docs

Running the tests

  1. Set the GCLOUD_PROJECT and GOOGLE_APPLICATION_CREDENTIALS environment variables.

  2. Run the tests:

    With npm:

    npm test
    

    With yarn:

    yarn test
    

Readme

Keywords

none

Package Sidebar

Install

npm i nodejs-docs-samples-speech

Weekly Downloads

0

Version

0.0.1

License

Apache-2.0

Last publish

Collaborators

  • suth86