GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — python-docs-samples/speech/api at master · MMMdata/python-docs-samples

Expand file tree

/

api

/
Copy path

Directory actions

More options

More options

Directory actions

More options

More options

Latest commit

 

History

History
History
 
 
/

api

/
Copy path

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
resources
resources
 
 
README.md
README.md
 
 
requirements-speech_rest.txt
requirements-speech_rest.txt
 
 
requirements-speech_streaming.txt
requirements-speech_streaming.txt
 
 
speech-discovery_google_rest_v1.json
speech-discovery_google_rest_v1.json
 
 
speech_rest.py
speech_rest.py
 
 
speech_rest_test.py
speech_rest_test.py
 
 
speech_streaming.py
speech_streaming.py
 
 
speech_streaming_test.py
speech_streaming_test.py
 
 

README.md

Outline

Google Cloud Speech API Samples

These examples demo accessing the Google Cloud Speech API in streaming mode (via its gRPC API) and in non-streaming mode (via its REST API).

Prerequisites

Enable the Speech API

If you have not already done so, enable the Google Cloud Speech API for your project. You must be whitelisted to do this.

Set Up to Authenticate With Your Project's Credentials

The example uses a service account for OAuth2 authentication. So next, set up to authenticate with the Speech API using your project's service account credentials.

Visit the Cloud Console, and navigate to: API Manager > Credentials > Create credentials > Service account key > New service account. Create a new service account, and download the json credentials file.

Then, set the GOOGLE_APPLICATION_CREDENTIALS environment variable to point to your downloaded service account credentials before running this example:

export GOOGLE_APPLICATION_CREDENTIALS=/path/to/your/credentials-key.json

If you do not do this, the REST api will return a 403. The streaming sample will just sort of hang silently.

See the Cloud Platform Auth Guide for more information.

Install the dependencies

  • If you're running the speech_rest.py sample:

    $ pip install requirements-speech_rest.txt
  • If you're running the speech_streaming.py sample:

    $ pip install requirements-speech_streaming.txt

Run the example

  • To run the speech_rest.py sample:

    $ python speech_rest.py resources/audio.raw

    You should see a response with the transcription result.

  • To run the speech_streaming.py sample:

    $ python speech_streaming.py

    The sample will run in a continuous loop, printing the data and metadata it receives from the Speech API, which includes alternative transcriptions of what it hears, and a confidence score. Say "exit" to exit the loop.

    Note that the speech_streaming.py sample does not yet support python 3, as the upstream grpcio library's support is not yet complete.

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.