Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Organize speech samples into grpc vs REST #502

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 7, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions speech/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Google Cloud Speech API Samples

These samples show how to use the [Google Cloud Speech API][speech-api]
to transcribe audio files, as well as live audio from your computer's
microphone.

* [`api-client/`](api-client) contains samples that use the [Google API Client
Library for Python][rest-client] to make REST calls to the API.
* [`grpc/`](grpc) contains samples that use the more-efficient (though sometimes
more complex) [GRPC][grpc] API. The GRPC API also allows streaming requests.

[speech-api]: http://cloud.google.com/speech
[rest-client]: https://developers.google.com/api-client-library/python/
[grpc]: http://grpc.io
85 changes: 85 additions & 0 deletions speech/api-client/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# Google Cloud Speech REST API Samples

These samples show how to use the [Google Cloud Speech API](http://cloud.google.com/speech)
to transcribe audio files, using the REST-based [Google API Client Library for
Python](https://developers.google.com/api-client-library/python/).

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

## Prerequisites

### Enable the Speech API

If you have not already done so, [enable the Google Cloud Speech
API][console-speech] for your project.

[console-speech]: https://console.cloud.google.com/apis/api/speech.googleapis.com/overview?project=_

### Authentication

These samples use service accounts for authentication.

* Visit the [Cloud Console][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][auth-guide] for more information.

[cloud-console]: https://console.cloud.google.com
[auth-guide]: https://cloud.google.com/docs/authentication#developer_workflow

### Setup

* Clone this repo

```sh
git clone https://github.com/GoogleCloudPlatform/python-docs-samples.git
cd python-docs-samples/speech/api-client
```

* Create a [virtualenv][virtualenv]. This isolates the python dependencies
you're about to install, to minimize conflicts with any existing libraries you
might already have.

```sh
virtualenv env
source env/bin/activate
```

* Install the dependencies

```sh
pip install -r requirements.txt
```

[pip]: https://pip.pypa.io/en/stable/installing/
[virtualenv]: https://virtualenv.pypa.io/en/stable/installation/

## Run the sample

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

```sh
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
```
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import re

from speech_async_rest import main
from transcribe_async import main


def test_main(resource, capsys):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import re

from speech_rest import main
from transcribe import main


def test_main(resource, capsys):
Expand Down
133 changes: 0 additions & 133 deletions speech/api/README.md

This file was deleted.

Binary file removed speech/api/resources/audio.flac
Binary file not shown.
35 changes: 0 additions & 35 deletions speech/api/speech_async_grpc_test.py

This file was deleted.

34 changes: 0 additions & 34 deletions speech/api/speech_grpc_test.py

This file was deleted.

Loading