Skip to content

Commit 72d0af0

Browse files
jmdobrycallmehiphop
authored andcommitted
speech: initial support (#1407)
0 parents  commit 72d0af0

File tree

8 files changed

+2380
-0
lines changed

8 files changed

+2380
-0
lines changed
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
# @google-cloud/speech
2+
> Google Cloud Speech Client Library for Node.js
3+
4+
> **This is a Beta release of Google Cloud Speech.** This feature is not covered by any SLA or deprecation policy and may be subject to backward-incompatible changes.
5+
6+
*Looking for more Google APIs than just Speech? You might want to check out [`google-cloud`][google-cloud].*
7+
8+
- [API Documentation][gcloud-speech-docs]
9+
- [Official Documentation][cloud-speech-docs]
10+
11+
12+
```sh
13+
$ npm install --save @google-cloud/speech
14+
```
15+
```js
16+
var speech = require('@google-cloud/speech')({
17+
projectId: 'grape-spaceship-123',
18+
keyFilename: '/path/to/keyfile.json'
19+
});
20+
21+
// Detect the speech in an audio file.
22+
speechClient.recognize('./audio.raw', {
23+
encoding: 'LINEAR16',
24+
sampleRate: 16000
25+
}, function(err, transcript) {
26+
// transcript = 'how old is the Brooklyn Bridge'
27+
});
28+
29+
// Detect the speech in an audio file stream.
30+
fs.createReadStream('./audio.raw')
31+
.on('error', console.error)
32+
.pipe(speech.createRecognizeStream({
33+
config: {
34+
encoding: 'LINEAR16',
35+
sampleRate: 16000
36+
},
37+
singleUtterance: false,
38+
interimResults: false
39+
}))
40+
.on('error', console.error)
41+
.on('data', function(data) {
42+
// The first "data" event emitted might look like:
43+
// data = {
44+
// endpointerType: Speech.endpointerTypes.START_OF_SPEECH,
45+
// ...
46+
// }
47+
//
48+
// A later "data" event emitted might look like:
49+
// data = {
50+
// endpointerType: Speech.endpointerTypes.END_OF_AUDIO,
51+
// ...
52+
// }
53+
//
54+
// A final "data" event emitted might look like:
55+
// data = {
56+
// endpointerType: Speech.endpointerTypes.END_OF_AUDIO,
57+
// results: "how old is the Brooklyn Bridge",
58+
// ...
59+
// }
60+
});
61+
```
62+
63+
64+
## Authentication
65+
66+
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 Google Cloud services.
67+
68+
### On Google Compute Engine
69+
70+
If you are running this client on Google Compute Engine, 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.
71+
72+
``` js
73+
// Authenticating on a global basis.
74+
var projectId = process.env.GCLOUD_PROJECT; // E.g. 'grape-spaceship-123'
75+
76+
var speech = require('@google-cloud/speech')({
77+
projectId: projectId
78+
});
79+
80+
// ...you're good to go!
81+
```
82+
83+
### Elsewhere
84+
85+
If you are not running this client on Google Compute Engine, you need a Google Developers service account. To create a service account:
86+
87+
1. Visit the [Google Developers Console][dev-console].
88+
2. Create a new project or click on an existing project.
89+
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):
90+
* Google Cloud Speech API
91+
4. Navigate to **APIs & auth** > **Credentials** and then:
92+
* If you want to use a new service account, click on **Create new Client ID** and select **Service account**. After the account is created, you will be prompted to download the JSON key file that the library uses to authenticate your requests.
93+
* If you want to generate a new key for an existing service account, click on **Generate new JSON key** and download the JSON key file.
94+
95+
``` js
96+
var projectId = process.env.GCLOUD_PROJECT; // E.g. 'grape-spaceship-123'
97+
98+
var speech = require('@google-cloud/speech')({
99+
projectId: projectId,
100+
101+
// The path to your key file:
102+
keyFilename: '/path/to/keyfile.json'
103+
104+
// Or the contents of the key file:
105+
credentials: require('./path/to/keyfile.json')
106+
});
107+
108+
// ...you're good to go!
109+
```
110+
111+
112+
[google-cloud]: https://github.com/GoogleCloudPlatform/google-cloud-node/
113+
[gce-how-to]: https://cloud.google.com/compute/docs/authentication#using
114+
[dev-console]: https://console.developers.google.com/project
115+
[gcloud-speech-docs]: https://googlecloudplatform.github.io/google-cloud-node/#/docs/speech
116+
[cloud-speech-docs]: https://cloud.google.com/speech
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
{
2+
"name": "@google-cloud/speech",
3+
"version": "0.1.0",
4+
"author": "Google Inc.",
5+
"description": "Google Cloud Speech Client Library for Node.js",
6+
"contributors": [
7+
{
8+
"name": "Burcu Dogan",
9+
"email": "[email protected]"
10+
},
11+
{
12+
"name": "Jason Dobry",
13+
"email": "[email protected]"
14+
},
15+
{
16+
"name": "Johan Euphrosine",
17+
"email": "[email protected]"
18+
},
19+
{
20+
"name": "Patrick Costello",
21+
"email": "[email protected]"
22+
},
23+
{
24+
"name": "Ryan Seys",
25+
"email": "[email protected]"
26+
},
27+
{
28+
"name": "Silvano Luciani",
29+
"email": "[email protected]"
30+
},
31+
{
32+
"name": "Stephen Sawchuk",
33+
"email": "[email protected]"
34+
}
35+
],
36+
"main": "./src/index.js",
37+
"files": [
38+
"./src/*",
39+
"AUTHORS",
40+
"CONTRIBUTORS",
41+
"COPYING"
42+
],
43+
"repository": "googlecloudplatform/google-cloud-node",
44+
"keywords": [
45+
"google apis client",
46+
"google api client",
47+
"google apis",
48+
"google api",
49+
"google",
50+
"google cloud platform",
51+
"google cloud",
52+
"cloud",
53+
"google speech",
54+
"speech"
55+
],
56+
"dependencies": {
57+
"@google-cloud/common": "^0.5.0",
58+
"events-intercept": "^2.0.0",
59+
"extend": "^3.0.0",
60+
"google-proto-files": "^0.7.0",
61+
"is": "^3.1.0",
62+
"modelo": "^4.2.0",
63+
"propprop": "^0.3.1",
64+
"pumpify": "^1.3.5",
65+
"request": "^2.74.0",
66+
"stream-events": "^1.0.1",
67+
"string-format-obj": "^1.1.0",
68+
"through2": "^2.0.1"
69+
},
70+
"devDependencies": {
71+
"@google-cloud/storage": "*",
72+
"async": "^2.0.1",
73+
"methmeth": "^1.1.0",
74+
"mocha": "^3.0.2",
75+
"node-uuid": "^1.4.7",
76+
"proxyquire": "^1.7.10",
77+
"sinon": "^1.17.5",
78+
"tmp": "0.0.28"
79+
},
80+
"scripts": {
81+
"publish-module": "node ../../scripts/publish.js speech",
82+
"test": "mocha test/*.js",
83+
"system-test": "mocha system-test/*.js --no-timeouts --bail"
84+
},
85+
"license": "Apache-2.0",
86+
"engines": {
87+
"node": ">=0.12.0"
88+
}
89+
}

0 commit comments

Comments
 (0)