Skip to content
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

Speech Partial Veneer #2421

Closed
wants to merge 30 commits into from
Closed
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
ab565ea
Vision Partial Veneer for NodeJS
May 10, 2017
070807e
Fix to the single-feature methods.
May 10, 2017
553bcd1
Vision semi-GAPIC.
May 11, 2017
83611e1
Add GAPIC tests.
May 11, 2017
2c00c70
Minor updates (mostly lint fixes).
May 12, 2017
6d5684e
Fix (and exclude) linting as appropriate, change to power-assert.
May 12, 2017
41ed049
Node 4 does not support array destructuring.
May 12, 2017
e5ffcf3
Add filename support.
May 15, 2017
981e861
Merge branch 'master' into vision-semi-gapic
lukesneeringer Jun 8, 2017
53e087a
Support ES6 in snippet tests.
Jun 8, 2017
bbaf415
Merge branch 'vision-semi-gapic' of github.com:lukesneeringer/google-…
Jun 8, 2017
04aca35
Shift to async readFile.
Jun 8, 2017
7207adf
Nuke the manual layer from space.
Jun 8, 2017
c699d90
Update lint.
Jun 8, 2017
2459348
Move to .nycrc file.
Jun 8, 2017
667f6a4
Helpers now at full coverage.
Jun 8, 2017
6f3caf6
Update system tests.
Jun 8, 2017
da27074
Merge branch 'public-master' into vision-semi-gapic
Jun 9, 2017
5dfd111
Play with Vision example a bit.
Jun 9, 2017
cb1f005
WIP
Jun 9, 2017
3e79c34
Fix the last unit test.
Jun 12, 2017
48e47e2
Add support for stream pipe
swcloud Jun 29, 2017
3da9fd6
sync with auto-gen
swcloud Jun 30, 2017
231614c
Merge branch 'master' into speech-semi-gapic
lukesneeringer Jul 14, 2017
608c06d
Lint fix.
lukesneeringer Jul 14, 2017
33c30aa
Fix a straggling comment.
lukesneeringer Jul 14, 2017
ff0c6ec
speech|vision: mark private methods and such & add doc blocks to help…
stephenplusplus Jul 14, 2017
d853a8d
remove speech from system tests until they have them
stephenplusplus Jul 14, 2017
7adecc2
Fix unit test.
lukesneeringer Jul 14, 2017
b95453c
Merge branch 'speech-semi-gapic' of github.com:lukesneeringer/google-…
lukesneeringer Jul 14, 2017
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
**/*.log
**/node_modules
coverage
.coverage
.nyc_output
docs/json
Expand Down
2 changes: 1 addition & 1 deletion .jshintignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
**/system-test/*/**/*

This comment was marked as spam.

**/test/*/**/*
**/node_modules/
**/coverage
**/coverage/
**/gapic*.js
26 changes: 26 additions & 0 deletions .nycrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"report-dir": "./.coverage",
"exclude": [
"src/*{/*,/**/*}.js",
"src/v*/*.js",
"test/**/*.js"
],
"watermarks": {
"branches": [
95,
100
],
"functions": [
95,
100
],
"lines": [
95,
100
],
"statements": [
95,
100
]
}
}
34 changes: 6 additions & 28 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"extend": "^3.0.0",
"glob": "^5.0.9",
"globby": "^3.0.1",
"intelli-espower-loader": "^1.0.1",

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

"is": "^3.1.0",
"jscs": "^2.1.1",
"jshint": "^2.9.1",
Expand All @@ -25,9 +26,11 @@
"multiline": "^1.0.2",
"nyc": "^10.3.0",
"package-json": "^2.4.0",
"power-assert": "^1.4.2",

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

"propprop": "^0.3.1",
"semver": "^5.3.0",
"shelljs": "^0.7.3",
"sinon": "^2.2.0",

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

"string-format-obj": "^1.0.0",
"string-includes": "^2.0.0",
"through2": "^2.0.0"
Expand All @@ -41,37 +44,12 @@
"remove-ghpages": "node ./scripts/docs/remove.js",
"lint": "jshint scripts/ packages/ system-test/ test/ && jscs packages/ system-test/ test/",
"test": "npm run unit-test && npm run docs && npm run snippet-test",
"unit-test": "mocha --timeout 5000 --bail packages/*/test/*.js",
"unit-test": "mocha --timeout 5000 --bail --require intelli-espower-loader packages/*/test/*.js",
"snippet-test": "mocha --timeout 5000 --bail test/docs.js",
"system-test": "mocha packages/*/system-test/*.js --no-timeouts --bail",
"cover": "nyc --reporter=lcov --reporter=html mocha --no-timeouts packages/*/test/*.js && nyc report",
"system-test": "mocha packages/*/system-test/*.js --require intelli-espower-loader --no-timeouts --bail",
"cover": "nyc --reporter=lcov --reporter=html mocha --require intelli-espower-loader --no-timeouts packages/*/test/*.js && nyc report",
"coveralls": "npm run cover && nyc report --reporter=text-lcov | coveralls"
},
"nyc": {
"report-dir": "./.coverage",
"exclude": [
"packages/*/src/*{/*,/**/*}.js",
"packages/*/test/**/*.js"
],
"watermarks": {
"branches": [
95,
100
],
"functions": [
95,
100
],
"lines": [
95,
100
],
"statements": [
95,
100
]
}
},
"license": "Apache-2.0",
"engines": {
"node": ">=4.0.0"
Expand Down
144 changes: 49 additions & 95 deletions packages/speech/README.md
Original file line number Diff line number Diff line change
@@ -1,105 +1,59 @@
# @google-cloud/speech ([Alpha][versioning])
> Cloud Speech Client Library for Node.js
# Node.js Client for Google Cloud Speech API ([Beta](https://github.com/GoogleCloudPlatform/google-cloud-node#versioning))

*Looking for more Google APIs than just Speech? You might want to check out [`google-cloud`][google-cloud].*
[Google Cloud Speech API][Product Documentation]: Google Cloud Speech API.
- [Client Library Documentation][]
- [Product Documentation][]

- [API Documentation][gcloud-speech-docs]
- [Official Documentation][cloud-speech-docs]
## Quick Start
In order to use this library, you first need to go through the following steps:

1. [Select or create a Cloud Platform project.](https://console.cloud.google.com/project)
2. [Enable the Google Cloud Speech API.](https://console.cloud.google.com/apis/api/speech)
3. [Setup Authentication.](https://googlecloudplatform.github.io/google-cloud-node/#/docs/google-cloud/master/guides/authentication)

```sh
$ npm install --save @google-cloud/speech
### Installation
```
```js
var speech = require('@google-cloud/speech')({
projectId: 'grape-spaceship-123',
keyFilename: '/path/to/keyfile.json'
});

// Detect the speech in an audio file.
speech.recognize('./audio.raw', {
encoding: 'LINEAR16',
sampleRateHertz: 16000
}, function(err, transcript) {
// transcript = 'how old is the Brooklyn Bridge'
});

// Detect the speech in an audio file stream.
fs.createReadStream('./audio.raw')
.on('error', console.error)
.pipe(speech.createRecognizeStream({
config: {
encoding: 'LINEAR16',
sampleRateHertz: 16000
},
singleUtterance: false,
interimResults: false
}))
.on('error', console.error)
.on('data', function(data) {
// data.results = "how old is the Brooklyn Bridge"
});

// Promises are also supported by omitting callbacks.
speech.recognize('./audio.raw', {
encoding: 'LINEAR16',
sampleRateHertz: 16000
}).then(function(data) {
var transcript = data[0];
});

// It's also possible to integrate with third-party Promise libraries.
var speech = require('@google-cloud/speech')({
promise: require('bluebird')
});
```


## Authentication

It's incredibly easy to get authenticated and start using Google's APIs. You can set your credentials on a global basis as well as on a per-API basis. See each individual API section below to see how you can auth on a per-API-basis. This is useful if you want to use different accounts for different Cloud services.

### On Google Cloud Platform

If you are running this client on Google Cloud Platform, we handle authentication for you with no configuration. You just need to make sure that when you [set up the GCE instance][gce-how-to], you add the correct scopes for the APIs you want to access.

``` js
var speech = require('@google-cloud/speech')();
// ...you're good to go!
$ npm install --save @google-cloud/speech
```

### Elsewhere

If you are not running this client on Google Cloud Platform, you need a Google Developers service account. To create a service account:

1. Visit the [Google Developers Console][dev-console].
2. Create a new project or click on an existing project.
3. Navigate to **APIs & auth** > **APIs section** and turn on the following APIs (you may need to enable billing in order to use these services):
* Google Cloud Speech API
4. Navigate to **APIs & auth** > **Credentials** and then:
* If you want to use a new service account key, click on **Create credentials** and select **Service account key**. After the account key is created, you will be prompted to download the JSON key file that the library uses to authenticate your requests.
* If you want to generate a new service account key for an existing service account, click on **Generate new JSON key** and download the JSON key file.

``` js
var projectId = process.env.GCLOUD_PROJECT; // E.g. 'grape-spaceship-123'

var speech = require('@google-cloud/speech')({
projectId: projectId,

// The path to your key file:
keyFilename: '/path/to/keyfile.json'

// Or the contents of the key file:
credentials: require('./path/to/keyfile.json')
});

// ...you're good to go!
### Preview
#### SpeechClient
```js
var speech = require('@google-cloud/speech');

var client = speech({
// optional auth parameters.
});

var languageCode = 'en-US';
var sampleRateHertz = 44100;
var encoding = speech.v1.types.RecognitionConfig.AudioEncoding.FLAC;
var config = {
languageCode : languageCode,
sampleRateHertz : sampleRateHertz,
encoding : encoding
};
var uri = 'gs://gapic-toolkit/hello.flac';
var audio = {
uri : uri
};
var request = {
config: config,
audio: audio
};
client.recognize(request).then(function(responses) {
var response = responses[0];
// doThingsWith(response)
})
.catch(function(err) {
console.error(err);
});
```

### Next Steps
- Read the [Client Library Documentation][] for Google Cloud Speech API to see other available methods on the client.
- Read the [Google Cloud Speech API Product documentation][Product Documentation] to learn more about the product and see How-to Guides.
- View this [repository's main README](https://github.com/GoogleCloudPlatform/google-cloud-node/blob/master/README.md) to see the full list of Cloud APIs that we cover.

[versioning]: https://github.com/GoogleCloudPlatform/google-cloud-node#versioning
[google-cloud]: https://github.com/GoogleCloudPlatform/google-cloud-node/
[gce-how-to]: https://cloud.google.com/compute/docs/authentication#using
[dev-console]: https://console.developers.google.com/project
[gcloud-speech-docs]: https://googlecloudplatform.github.io/google-cloud-node/#/docs/speech
[cloud-speech-docs]: https://cloud.google.com/speech
[Client Library Documentation]: https://googlecloudplatform.github.io/google-cloud-node/#/docs/speech
[Product Documentation]: https://cloud.google.com/speech
37 changes: 14 additions & 23 deletions packages/speech/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"repository": "GoogleCloudPlatform/google-cloud-node",
"name": "@google-cloud/speech",
"version": "0.9.4",
"version": "0.10.0",

This comment was marked as spam.

This comment was marked as spam.

"author": "Google Inc.",
"description": "Cloud Speech Client Library for Node.js",
"contributors": [
Expand Down Expand Up @@ -37,10 +38,8 @@
"files": [
"src",
"AUTHORS",
"CONTRIBUTORS",
"COPYING"
],
"repository": "googlecloudplatform/google-cloud-node",
"keywords": [
"google apis client",
"google api client",
Expand All @@ -51,36 +50,28 @@
"google cloud",
"cloud",
"google speech",
"speech"
"speech",
"Google Cloud Speech API"
],
"dependencies": {
"@google-cloud/common": "^0.13.0",
"@google-cloud/common-grpc": "^0.3.0",
"events-intercept": "^2.0.0",
"extend": "^3.0.0",
"google-gax": "^0.13.0",
"google-proto-files": "^0.12.0",
"is": "^3.1.0",
"propprop": "^0.3.1",
"google-gax": "^0.13.2",
"extend": "^3.0.0",
"pumpify": "^1.3.5",
"request": "^2.74.0",
"stream-events": "^1.0.1",
"string-format-obj": "^1.1.0",
"through2": "^2.0.1"
"through2": "^2.0.3"
},
"devDependencies": {
"@google-cloud/storage": "*",
"async": "^2.0.1",
"methmeth": "^1.1.0",
"mocha": "^3.0.2",
"proxyquire": "^1.7.10",
"tmp": "^0.0.31",
"uuid": "^3.0.1"
"intelli-espower-loader": "^1.0.1",

This comment was marked as spam.

This comment was marked as spam.

"mocha": "^3.2.0",
"nyc": "^10.3.0",
"power-assert": "^1.4.2",
"sinon": "^2.2.0"
},
"scripts": {
"publish-module": "node ../../scripts/publish.js speech",
"test": "mocha test/*.js",
"system-test": "mocha system-test/*.js --no-timeouts --bail"
"smoke-test": "mocha smoke-test/*.js --timeout 5000",

This comment was marked as spam.

"test": "mocha test/*.js"
},
"license": "Apache-2.0",
"engines": {
Expand Down
50 changes: 50 additions & 0 deletions packages/speech/smoke-test/speech_smoke_test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Copyright 2017, Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
'use strict';

describe('SpeechSmokeTest', function() {

it('successfully makes a call to the service', function(done) {

This comment was marked as spam.

This comment was marked as spam.

var speech = require('../src');

var client = speech.v1({
// optional auth parameters.
});

var languageCode = 'en-US';
var sampleRateHertz = 44100;
var encoding = speech.v1.types.RecognitionConfig.AudioEncoding.FLAC;
var config = {
languageCode : languageCode,

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

sampleRateHertz : sampleRateHertz,
encoding : encoding
};
var uri = 'gs://gapic-toolkit/hello.flac';
var audio = {
uri : uri
};
var request = {
config: config,
audio: audio
};
client.recognize(request).then(function(responses) {
var response = responses[0];
console.log(response);

This comment was marked as spam.

})
.then(done)
.catch(done);
});
});
Loading