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-client at master · eminge/python-docs-samples

Expand file tree

/

api-client

/
Copy path

Directory actions

More options

More options

Directory actions

More options

More options

Latest commit

 

History

History
History
 
 
/

api-client

/
Copy path

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
resources
resources
 
 
README.md
README.md
 
 
requirements.txt
requirements.txt
 
 
transcribe.py
transcribe.py
 
 
transcribe_async.py
transcribe_async.py
 
 
transcribe_async_test.py
transcribe_async_test.py
 
 
transcribe_test.py
transcribe_test.py
 
 

README.md

Outline

Google Cloud Speech REST API Samples

These samples show how to use the Google Cloud Speech API to transcribe audio files, using the REST-based Google API Client Library for Python.

For samples that use the more-efficient GRPC-based client library (including a streaming sample that transcribes audio streamed from your microphone), see ../grpc/.

Prerequisites

Enable the Speech API

If you have not already done so, enable the Google Cloud Speech API for your project.

Authentication

These samples use service accounts for authentication.

  • 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.

  • 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
    

    If you do not do this, the REST api will return a 403.

See the Cloud Platform Auth Guide for more information.

Setup

  • Clone this repo

    git clone https://github.com/GoogleCloudPlatform/python-docs-samples.git
    cd python-docs-samples/speech/api-client
  • Create a virtualenv. This isolates the python dependencies you're about to install, to minimize conflicts with any existing libraries you might already have.

    virtualenv env
    source env/bin/activate
  • Install the dependencies

    pip install -r requirements.txt

Run the sample

Each of the samples takes the audio file to transcribe as the first argument. For example:

python transcribe.py resources/audio.raw

You should see a response with the transcription result.

Deactivate virtualenv

When you're done running the sample, you can exit your virtualenv:

deactivate
You are visitor 01402520 — 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.