diff --git a/README.md b/README.md
index 90b877e39b9..2efa790df44 100644
--- a/README.md
+++ b/README.md
@@ -324,7 +324,7 @@ recognition technologies into developer applications.
View the [Cloud Speech API Node.js samples][speech_samples].
[speech_docs]: https://cloud.google.com/speech/
-[speech_samples]: speech
+[speech_samples]: https://github.com/googleapis/nodejs-speech/tree/master/samples
#### Google Translate API
diff --git a/circle.yml b/circle.yml
index 3b293b56913..af53a9a804a 100644
--- a/circle.yml
+++ b/circle.yml
@@ -100,8 +100,6 @@ deployment:
- node scripts/build "language/slackbot"
- node scripts/build "prediction"
- node scripts/build "pubsub"
- - node scripts/build "resource"
- - node scripts/build "speech"
- node scripts/build "storage-transfer"
- node scripts/build "trace"
- node scripts/build "vision"
diff --git a/resource/README.md b/resource/README.md
index 488cecc4b26..cb0023c3767 100644
--- a/resource/README.md
+++ b/resource/README.md
@@ -1,68 +1,5 @@
-
+Samples for the [Google Cloud Resource Manager API Node.js Client][client] have moved
+to [github.com/googleapis/nodejs-resource/tree/master/samples/][samples].
-# Google Cloud Resource Manager API Node.js Samples
-
-[![Build](https://storage.googleapis.com/cloud-docs-samples-badges/GoogleCloudPlatform/nodejs-docs-samples/nodejs-docs-samples-resource-manager.svg)]()
-
-Google Cloud Platform provides container resources such as Organizations and Projects, that allow you to group and hierarchically organize other Cloud Platform resources. This hierarchical organization lets you easily manage common aspects of your resources such as access control and configuration settings. The [Cloud Resource Manager API](https://cloud.google.com/resource-manager/docs/) enables you to programmatically manage these container resources.
-
-## Table of Contents
-
-* [Setup](#setup)
-* [Samples](#samples)
- * [Projects](#projects)
-* [Running the tests](#running-the-tests)
-
-## Setup
-
-1. Read [Prerequisites][prereq] and [How to run a sample][run] first.
-1. Install dependencies:
-
- With **npm**:
-
- npm install
-
- With **yarn**:
-
- yarn install
-
-[prereq]: ../README.md#prerequisites
-[run]: ../README.md#how-to-run-a-sample
-
-## Samples
-
-### Projects
-
-View the [documentation][projects_0_docs] or the [source code][projects_0_code].
-
-__Usage:__ `node projects.js --help`
-
-```
-Commands:
- list List all current projects.
-
-Options:
- --help Show help [boolean]
-
-Examples:
- node projects.js list Lists all current projects.
-
-For more information, see https://cloud.google.com/resource-manager/docs
-```
-
-[projects_0_docs]: https://cloud.google.com/resource-manager/docs
-[projects_0_code]: projects.js
-
-## Running the tests
-
-1. Set the **GCLOUD_PROJECT** and **GOOGLE_APPLICATION_CREDENTIALS** environment variables.
-
-1. Run the tests:
-
- With **npm**:
-
- npm test
-
- With **yarn**:
-
- yarn test
+[client]: https://github.com/googleapis/nodejs-resource
+[samples]: https://github.com/googleapis/nodejs-resource/tree/master/samples
diff --git a/resource/package.json b/resource/package.json
deleted file mode 100644
index 58a78fcb055..00000000000
--- a/resource/package.json
+++ /dev/null
@@ -1,43 +0,0 @@
-{
- "name": "nodejs-docs-samples-resource-manager",
- "version": "0.0.1",
- "private": true,
- "license": "Apache-2.0",
- "author": "Google Inc.",
- "repository": {
- "type": "git",
- "url": "https://github.com/GoogleCloudPlatform/nodejs-docs-samples.git"
- },
- "engines": {
- "node": ">=4.3.2"
- },
- "scripts": {
- "lint": "samples lint",
- "pretest": "npm run lint",
- "test": "samples test run --cmd ava -- -T 20s --verbose system-test/*.test.js"
- },
- "dependencies": {
- "@google-cloud/resource": "0.7.3",
- "yargs": "8.0.2"
- },
- "devDependencies": {
- "@google-cloud/nodejs-repo-tools": "1.4.17",
- "ava": "0.21.0",
- "proxyquire": "1.8.0",
- "sinon": "3.2.0"
- },
- "cloud-repo-tools": {
- "requiresKeyFile": true,
- "requiresProjectId": true,
- "product": "resource",
- "samples": [
- {
- "id": "projects",
- "name": "Projects",
- "file": "projects.js",
- "docs_link": "https://cloud.google.com/resource-manager/docs",
- "usage": "node projects.js --help"
- }
- ]
- }
-}
diff --git a/resource/projects.js b/resource/projects.js
deleted file mode 100644
index 440a352205c..00000000000
--- a/resource/projects.js
+++ /dev/null
@@ -1,48 +0,0 @@
-/**
- * Copyright 2017, Google, Inc.
- * 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';
-
-function listProjects () {
- // [START resource_list_projects]
- // Imports the Google Cloud client library
- const Resource = require('@google-cloud/resource');
-
- // Instantiates a client
- const resource = Resource();
-
- // Lists all current projects
- resource.getProjects()
- .then((results) => {
- const projects = results[0];
- console.log('Projects:');
- projects.forEach((project) => console.log(project.id));
- })
- .catch((err) => {
- console.error('ERROR:', err);
- });
- // [END resource_list_projects]
-}
-
-require(`yargs`) // eslint-disable-line
- .demand(1)
- .command(`list`, `List all current projects.`, {}, listProjects)
- .example(`node $0 list`, `Lists all current projects.`)
- .wrap(120)
- .recommendCommands()
- .epilogue(`For more information, see https://cloud.google.com/resource-manager/docs`)
- .help()
- .strict()
- .argv;
diff --git a/resource/quickstart.js b/resource/quickstart.js
deleted file mode 100644
index c8ae933591b..00000000000
--- a/resource/quickstart.js
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
- * Copyright 2017, Google, Inc.
- * 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';
-
-// [START resource_quickstart]
-// Imports the Google Cloud client library
-const Resource = require('@google-cloud/resource');
-
-// Your Google Cloud Platform project ID
-const projectId = 'YOUR_PROJECT_ID';
-
-// Instantiates a client
-const resourceClient = Resource({
- projectId: projectId
-});
-
-// Lists current projects
-resourceClient.getProjects()
- .then((results) => {
- const projects = results[0];
-
- console.log('Projects:');
- projects.forEach((project) => console.log(project.id));
- })
- .catch((err) => {
- console.error('ERROR:', err);
- });
-// [END resource_quickstart]
diff --git a/resource/system-test/projects.test.js b/resource/system-test/projects.test.js
deleted file mode 100644
index 9c98219cf9d..00000000000
--- a/resource/system-test/projects.test.js
+++ /dev/null
@@ -1,31 +0,0 @@
-/**
- * Copyright 2017, Google, Inc.
- * 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';
-
-const path = require(`path`);
-const test = require(`ava`);
-const tools = require(`@google-cloud/nodejs-repo-tools`);
-
-const cwd = path.join(__dirname, `..`);
-const cmd = `node projects.js`;
-
-test.before(tools.checkCredentials);
-
-test(`should list projects`, async (t) => {
- const output = await tools.runAsync(`${cmd} list`, cwd);
- t.true(output.includes(`Projects:`));
- t.true(output.includes(`${process.env.GCLOUD_PROJECT}`));
-});
diff --git a/resource/system-test/quickstart.test.js b/resource/system-test/quickstart.test.js
deleted file mode 100644
index fd71c1f7df3..00000000000
--- a/resource/system-test/quickstart.test.js
+++ /dev/null
@@ -1,55 +0,0 @@
-/**
- * Copyright 2017, Google, Inc.
- * 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';
-
-const proxyquire = require(`proxyquire`).noPreserveCache();
-const resource = proxyquire(`@google-cloud/resource`, {})();
-const sinon = require(`sinon`);
-const test = require(`ava`);
-const tools = require(`@google-cloud/nodejs-repo-tools`);
-
-test.before(tools.stubConsole);
-test.after.always(tools.restoreConsole);
-
-test.cb(`should list projects`, (t) => {
- const resourceMock = {
- getProjects: () => {
- return resource.getProjects()
- .then(([projects]) => {
- t.true(Array.isArray(projects));
-
- setTimeout(() => {
- try {
- t.true(console.log.called);
- t.deepEqual(console.log.firstCall.args, [`Projects:`]);
- projects.forEach((project, i) => {
- t.deepEqual(console.log.getCall(i + 1).args, [project.id]);
- });
- t.end();
- } catch (err) {
- t.end(err);
- }
- }, 200);
-
- return [projects];
- });
- }
- };
-
- proxyquire(`../quickstart`, {
- '@google-cloud/resource': sinon.stub().returns(resourceMock)
- });
-});
diff --git a/speech/README.md b/speech/README.md
index 4390f45b43d..99249b3693d 100644
--- a/speech/README.md
+++ b/speech/README.md
@@ -1,85 +1,5 @@
-
+Samples for the [Google Cloud Speech API Node.js Client][client] have moved
+to [github.com/googleapis/nodejs-speech/tree/master/samples/][samples].
-# Google Cloud Speech API Node.js Samples
-
-[![Build](https://storage.googleapis.com/cloud-docs-samples-badges/GoogleCloudPlatform/nodejs-docs-samples/nodejs-docs-samples-speech.svg)]()
-
-The [Cloud Speech API](https://cloud.google.com/speech/docs) enables easy integration of Google speech recognition technologies into developer applications. Send audio and receive a text transcription from the Cloud Speech API service.
-
-## Table of Contents
-
-* [Setup](#setup)
-* [Samples](#samples)
- * [Speech Recognition](#speech-recognition)
-* [Running the tests](#running-the-tests)
-
-## Setup
-
-1. Read [Prerequisites][prereq] and [How to run a sample][run] first.
-1. Install dependencies:
-
- With **npm**:
-
- npm install
-
- With **yarn**:
-
- yarn install
-
-[prereq]: ../README.md#prerequisites
-[run]: ../README.md#how-to-run-a-sample
-
-## Samples
-
-### Speech Recognition
-
-View the [documentation][recognize_0_docs] or the [source code][recognize_0_code].
-
-__Usage:__ `node recognize.js --help`
-
-```
-Commands:
- sync Detects speech in a local audio file.
- sync-gcs Detects speech in an audio file located in a Google Cloud Storage bucket.
- sync-words Detects speech in a local audio file with word time offset.
- async Creates a job to detect speech in a local audio file, and waits for the job to complete.
- async-gcs Creates a job to detect speech in an audio file located in a Google Cloud Storage bucket,
- and waits for the job to complete.
- async-gcs-words Creates a job to detect speech with word time offset in an audio file located in a Google
- Cloud Storage bucket, and waits for the job to complete.
- stream Detects speech in a local audio file by streaming it to the Speech API.
- listen Detects speech in a microphone input stream. This command requires that you have SoX
- installed and available in your $PATH. See
- https://www.npmjs.com/package/node-record-lpcm16#dependencies
-
-Options:
- --help Show help [boolean]
- --encoding, -e [string] [default: "LINEAR16"]
- --sampleRateHertz, -r [number] [default: 16000]
- --languageCode, -l [string] [default: "en-US"]
-
-Examples:
- node recognize.js sync ./resources/audio.raw -e LINEAR16 -r 16000
- node recognize.js async-gcs gs://gcs-test-data/vr.flac -e FLAC -r 16000
- node recognize.js stream ./resources/audio.raw -e LINEAR16 -r 16000
- node recognize.js listen
-
-For more information, see https://cloud.google.com/speech/docs
-```
-
-[recognize_0_docs]: https://cloud.google.com/speech/docs
-[recognize_0_code]: recognize.js
-
-## Running the tests
-
-1. Set the **GCLOUD_PROJECT** and **GOOGLE_APPLICATION_CREDENTIALS** environment variables.
-
-1. Run the tests:
-
- With **npm**:
-
- npm test
-
- With **yarn**:
-
- yarn test
+[client]: https://github.com/googleapis/nodejs-speech
+[samples]: https://github.com/googleapis/nodejs-speech/tree/master/samples
diff --git a/speech/package.json b/speech/package.json
deleted file mode 100644
index 6449f5ac396..00000000000
--- a/speech/package.json
+++ /dev/null
@@ -1,45 +0,0 @@
-{
- "name": "nodejs-docs-samples-speech",
- "version": "0.0.1",
- "private": true,
- "license": "Apache-2.0",
- "author": "Google Inc.",
- "repository": {
- "type": "git",
- "url": "https://github.com/GoogleCloudPlatform/nodejs-docs-samples.git"
- },
- "engines": {
- "node": ">=4.3.2"
- },
- "scripts": {
- "lint": "samples lint",
- "pretest": "npm run lint",
- "test": "samples test run --cmd ava -- -T 20s --verbose system-test/*.test.js"
- },
- "dependencies": {
- "@google-cloud/speech": "0.10.2",
- "@google-cloud/storage": "1.2.1",
- "node-record-lpcm16": "0.3.0",
- "yargs": "8.0.2"
- },
- "devDependencies": {
- "@google-cloud/nodejs-repo-tools": "1.4.17",
- "ava": "0.21.0",
- "proxyquire": "1.8.0",
- "sinon": "3.2.0"
- },
- "cloud-repo-tools": {
- "requiresKeyFile": true,
- "requiresProjectId": true,
- "product": "speech",
- "samples": [
- {
- "id": "recognize",
- "name": "Speech Recognition",
- "file": "recognize.js",
- "docs_link": "https://cloud.google.com/speech/docs",
- "usage": "node recognize.js --help"
- }
- ]
- }
-}
diff --git a/speech/quickstart.js b/speech/quickstart.js
deleted file mode 100644
index 8652facb5f0..00000000000
--- a/speech/quickstart.js
+++ /dev/null
@@ -1,63 +0,0 @@
-/**
- * Copyright 2017, Google, Inc.
- * 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';
-
-// [START speech_quickstart]
-// Imports the Google Cloud client library
-const Speech = require('@google-cloud/speech');
-const fs = require('fs');
-
-// Your Google Cloud Platform project ID
-const projectId = 'your-project-id';
-
-// Instantiates a client
-const speechClient = Speech({
- projectId: projectId
-});
-
-// The name of the audio file to transcribe
-const fileName = './resources/audio.raw';
-
-// Reads a local audio file and converts it to base64
-const file = fs.readFileSync(fileName);
-const audioBytes = file.toString('base64');
-
-// The audio file's encoding, sample rate in hertz, and BCP-47 language code
-const audio = {
- content: audioBytes
-};
-const config = {
- encoding: 'LINEAR16',
- sampleRateHertz: 16000,
- languageCode: 'en-US'
-};
-const request = {
- audio: audio,
- config: config
-};
-
-// Detects speech in the audio file
-speechClient.recognize(request)
- .then((data) => {
- const response = data[0];
- const transcription = response.results.map(result =>
- result.alternatives[0].transcript).join('\n');
- console.log(`Transcription: ${transcription}`);
- })
- .catch((err) => {
- console.error('ERROR:', err);
- });
-// [END speech_quickstart]
diff --git a/speech/recognize.js b/speech/recognize.js
deleted file mode 100644
index 6b5338f8568..00000000000
--- a/speech/recognize.js
+++ /dev/null
@@ -1,543 +0,0 @@
-/**
- * Copyright 2017, Google, Inc.
- * 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.
- */
-
-/**
- * This application demonstrates how to perform basic recognize operations with
- * with the Google Cloud Speech API.
- *
- * For more information, see the README.md under /speech and the documentation
- * at https://cloud.google.com/speech/docs.
- */
-
-'use strict';
-
-function syncRecognize (filename, encoding, sampleRateHertz, languageCode) {
- // [START speech_sync_recognize]
- // Imports the Google Cloud client library
- const fs = require('fs');
- const Speech = require('@google-cloud/speech');
-
- // Instantiates a client
- const speech = Speech();
-
- // The path to the local file on which to perform speech recognition, e.g. /path/to/audio.raw
- // const filename = '/path/to/audio.raw';
-
- // The encoding of the audio file, e.g. 'LINEAR16'
- // const encoding = 'LINEAR16';
-
- // The sample rate of the audio file in hertz, e.g. 16000
- // const sampleRateHertz = 16000;
-
- // The BCP-47 language code to use, e.g. 'en-US'
- // const languageCode = 'en-US';
-
- const config = {
- encoding: encoding,
- sampleRateHertz: sampleRateHertz,
- languageCode: languageCode
- };
- const audio = {
- content: fs.readFileSync(filename).toString('base64')
- };
-
- const request = {
- config: config,
- audio: audio
- };
-
- // Detects speech in the audio file
- speech.recognize(request)
- .then((data) => {
- const response = data[0];
- const transcription = response.results.map(result =>
- result.alternatives[0].transcript).join('\n');
- console.log(`Transcription: `, transcription);
- })
- .catch((err) => {
- console.error('ERROR:', err);
- });
- // [END speech_sync_recognize]
-}
-
-function syncRecognizeGCS (gcsUri, encoding, sampleRateHertz, languageCode) {
- // [START speech_sync_recognize_gcs]
- // Imports the Google Cloud client library
- const Speech = require('@google-cloud/speech');
-
- // Instantiates a client
- const speech = Speech();
-
- // The Google Cloud Storage URI of the file on which to perform speech recognition, e.g. gs://my-bucket/audio.raw
- // const gcsUri = 'gs://my-bucket/audio.raw';
-
- // The encoding of the audio file, e.g. 'LINEAR16'
- // const encoding = 'LINEAR16';
-
- // The sample rate of the audio file in hertz, e.g. 16000
- // const sampleRateHertz = 16000;
-
- // The BCP-47 language code to use, e.g. 'en-US'
- // const languageCode = 'en-US';
-
- const config = {
- encoding: encoding,
- sampleRateHertz: sampleRateHertz,
- languageCode: languageCode
- };
- const audio = {
- uri: gcsUri
- };
-
- const request = {
- config: config,
- audio: audio
- };
-
- // Detects speech in the audio file
- speech.recognize(request)
- .then((data) => {
- const response = data[0];
- const transcription = response.results.map(result =>
- result.alternatives[0].transcript).join('\n');
- console.log(`Transcription: `, transcription);
- })
- .catch((err) => {
- console.error('ERROR:', err);
- });
- // [END speech_sync_recognize_gcs]
-}
-
-function syncRecognizeWords (filename, encoding, sampleRateHertz, languageCode) {
- // [START speech_sync_recognize_words]
- // Imports the Google Cloud client library
- const fs = require('fs');
- const Speech = require('@google-cloud/speech');
-
- // Instantiates a client
- const speech = Speech();
-
- // The path to the local file on which to perform speech recognition, e.g. /path/to/audio.raw
- // const filename = '/path/to/audio.raw';
-
- // The encoding of the audio file, e.g. 'LINEAR16'
- // const encoding = 'LINEAR16';
-
- // The sample rate of the audio file in hertz, e.g. 16000
- // const sampleRateHertz = 16000;
-
- // The BCP-47 language code to use, e.g. 'en-US'
- // const languageCode = 'en-US';
-
- const config = {
- enableWordTimeOffsets: true,
- encoding: encoding,
- sampleRateHertz: sampleRateHertz,
- languageCode: languageCode
- };
- const audio = {
- content: fs.readFileSync(filename).toString('base64')
- };
-
- const request = {
- config: config,
- audio: audio
- };
-
- // Detects speech in the audio file
- speech.recognize(request)
- .then((data) => {
- const response = data[0];
- response.results.forEach((result) => {
- console.log(`Transcription: `, result.alternatives[0].transcript);
- result.alternatives[0].words.forEach((wordInfo) => {
- // NOTE: If you have a time offset exceeding 2^32 seconds, use the
- // wordInfo.{x}Time.seconds.high to calculate seconds.
- const startSecs = `${wordInfo.startTime.seconds}` + `.` +
- (wordInfo.startTime.nanos / 100000000);
- const endSecs = `${wordInfo.endTime.seconds}` + `.` +
- (wordInfo.endTime.nanos / 100000000);
- console.log(`Word: ${wordInfo.word}`);
- console.log(`\t ${startSecs} secs - ${endSecs} secs`);
- });
- });
- })
- .catch((err) => {
- console.error('ERROR:', err);
- });
- // [END speech_sync_recognize_words]
-}
-
-function asyncRecognize (filename, encoding, sampleRateHertz, languageCode) {
- // [START speech_async_recognize]
- // Imports the Google Cloud client library
- const Speech = require('@google-cloud/speech');
- const fs = require('fs');
-
- // Instantiates a client
- const speech = Speech();
-
- // The path to the local file on which to perform speech recognition, e.g. /path/to/audio.raw
- // const filename = '/path/to/audio.raw';
-
- // The encoding of the audio file, e.g. 'LINEAR16'
- // const encoding = 'LINEAR16';
-
- // The sample rate of the audio file in hertz, e.g. 16000
- // const sampleRateHertz = 16000;
-
- // The BCP-47 language code to use, e.g. 'en-US'
- // const languageCode = 'en-US';
-
- const config = {
- encoding: encoding,
- sampleRateHertz: sampleRateHertz,
- languageCode: languageCode
- };
- const audio = {
- content: fs.readFileSync(filename).toString('base64')
- };
-
- const request = {
- config: config,
- audio: audio
- };
-
- // Detects speech in the audio file. This creates a recognition job that you
- // can wait for now, or get its result later.
- speech.longRunningRecognize(request)
- .then((data) => {
- const response = data[0];
- const operation = response;
- // Get a Promise representation of the final result of the job
- return operation.promise();
- })
- .then((data) => {
- const response = data[0];
- const transcription = response.results.map(result =>
- result.alternatives[0].transcript).join('\n');
- console.log(`Transcription: ${transcription}`);
- })
- .catch((err) => {
- console.error('ERROR:', err);
- });
- // [END speech_async_recognize]
-}
-
-function asyncRecognizeGCS (gcsUri, encoding, sampleRateHertz, languageCode) {
- // [START speech_async_recognize_gcs]
- // Imports the Google Cloud client library
- const Speech = require('@google-cloud/speech');
-
- // Instantiates a client
- const speech = Speech();
-
- // The Google Cloud Storage URI of the file on which to perform speech recognition, e.g. gs://my-bucket/audio.raw
- // const gcsUri = 'gs://my-bucket/audio.raw';
-
- // The encoding of the audio file, e.g. 'LINEAR16'
- // const encoding = 'LINEAR16';
-
- // The sample rate of the audio file in hertz, e.g. 16000
- // const sampleRateHertz = 16000;
-
- // The BCP-47 language code to use, e.g. 'en-US'
- // const languageCode = 'en-US';
-
- const config = {
- encoding: encoding,
- sampleRateHertz: sampleRateHertz,
- languageCode: languageCode
- };
-
- const audio = {
- uri: gcsUri
- };
-
- const request = {
- config: config,
- audio: audio
- };
-
- // Detects speech in the audio file. This creates a recognition job that you
- // can wait for now, or get its result later.
- speech.longRunningRecognize(request)
- .then((data) => {
- const operation = data[0];
- // Get a Promise representation of the final result of the job
- return operation.promise();
- })
- .then((data) => {
- const response = data[0];
- const transcription = response.results.map(result =>
- result.alternatives[0].transcript).join('\n');
- console.log(`Transcription: ${transcription}`);
- })
- .catch((err) => {
- console.error('ERROR:', err);
- });
- // [END speech_async_recognize_gcs]
-}
-
-function asyncRecognizeGCSWords (gcsUri, encoding, sampleRateHertz, languageCode) {
- // [START speech_async_recognize_gcs_words]
- // Imports the Google Cloud client library
- const Speech = require('@google-cloud/speech');
-
- // Instantiates a client
- const speech = Speech();
-
- // The Google Cloud Storage URI of the file on which to perform speech recognition, e.g. gs://my-bucket/audio.raw
- // const gcsUri = 'gs://my-bucket/audio.raw';
-
- // The encoding of the audio file, e.g. 'LINEAR16'
- // const encoding = 'LINEAR16';
-
- // The sample rate of the audio file in hertz, e.g. 16000
- // const sampleRateHertz = 16000;
-
- // The BCP-47 language code to use, e.g. 'en-US'
- // const languageCode = 'en-US';
-
- const config = {
- enableWordTimeOffsets: true,
- encoding: encoding,
- sampleRateHertz: sampleRateHertz,
- languageCode: languageCode
- };
-
- const audio = {
- uri: gcsUri
- };
-
- const request = {
- config: config,
- audio: audio
- };
-
- // Detects speech in the audio file. This creates a recognition job that you
- // can wait for now, or get its result later.
- speech.longRunningRecognize(request)
- .then((data) => {
- const operation = data[0];
- // Get a Promise representation of the final result of the job
- return operation.promise();
- })
- .then((data) => {
- const response = data[0];
- response.results.forEach((result) => {
- console.log(`Transcription: ${result.alternatives[0].transcript}`);
- result.alternatives[0].words.forEach((wordInfo) => {
- // NOTE: If you have a time offset exceeding 2^32 seconds, use the
- // wordInfo.{x}Time.seconds.high to calculate seconds.
- const startSecs = `${wordInfo.startTime.seconds}` + `.` +
- (wordInfo.startTime.nanos / 100000000);
- const endSecs = `${wordInfo.endTime.seconds}` + `.` +
- (wordInfo.endTime.nanos / 100000000);
- console.log(`Word: ${wordInfo.word}`);
- console.log(`\t ${startSecs} secs - ${endSecs} secs`);
- });
- });
- })
- .catch((err) => {
- console.error('ERROR:', err);
- });
- // [END speech_async_recognize_gcs_words]
-}
-
-function streamingRecognize (filename, encoding, sampleRateHertz, languageCode) {
- // [START speech_streaming_recognize]
- const fs = require('fs');
-
- // Imports the Google Cloud client library
- const Speech = require('@google-cloud/speech');
-
- // Instantiates a client
- const speech = Speech();
-
- // The path to the local file on which to perform speech recognition, e.g. /path/to/audio.raw
- // const filename = '/path/to/audio.raw';
-
- // The encoding of the audio file, e.g. 'LINEAR16'
- // const encoding = 'LINEAR16';
-
- // The sample rate of the audio file in hertz, e.g. 16000
- // const sampleRateHertz = 16000;
-
- // The BCP-47 language code to use, e.g. 'en-US'
- // const languageCode = 'en-US';
-
- const request = {
- config: {
- encoding: encoding,
- sampleRateHertz: sampleRateHertz,
- languageCode: languageCode
- },
- interimResults: false // If you want interim results, set this to true
- };
-
- // Stream the audio to the Google Cloud Speech API
- const recognizeStream = speech.streamingRecognize(request)
- .on('error', console.error)
- .on('data', (data) => {
- console.log(
- `Transcription: ${data.results[0].alternatives[0].transcript}`);
- });
-
- // Stream an audio file from disk to the Speech API, e.g. "./resources/audio.raw"
- fs.createReadStream(filename).pipe(recognizeStream);
- // [END speech_streaming_recognize]
-}
-
-function streamingMicRecognize (encoding, sampleRateHertz, languageCode) {
- // [START speech_streaming_mic_recognize]
- const record = require('node-record-lpcm16');
-
- // Imports the Google Cloud client library
- const Speech = require('@google-cloud/speech');
-
- // Instantiates a client
- const speech = Speech();
-
- // The encoding of the audio file, e.g. 'LINEAR16'
- // const encoding = 'LINEAR16';
-
- // The sample rate of the audio file in hertz, e.g. 16000
- // const sampleRateHertz = 16000;
-
- // The BCP-47 language code to use, e.g. 'en-US'
- // const languageCode = 'en-US';
-
- const request = {
- config: {
- encoding: encoding,
- sampleRateHertz: sampleRateHertz,
- languageCode: languageCode
- },
- interimResults: false // If you want interim results, set this to true
- };
-
- // Create a recognize stream
- const recognizeStream = speech.streamingRecognize(request)
- .on('error', console.error)
- .on('data', (data) =>
- process.stdout.write(
- (data.results[0] && data.results[0].alternatives[0])
- ? `Transcription: ${data.results[0].alternatives[0].transcript}\n`
- : `\n\nReached transcription time limit, press Ctrl+C\n`));
-
- // Start recording and send the microphone input to the Speech API
- record
- .start({
- sampleRateHertz: sampleRateHertz,
- threshold: 0,
- // Other options, see https://www.npmjs.com/package/node-record-lpcm16#options
- verbose: false,
- recordProgram: 'rec', // Try also "arecord" or "sox"
- silence: '10.0'
- })
- .on('error', console.error)
- .pipe(recognizeStream);
-
- console.log('Listening, press Ctrl+C to stop.');
- // [END speech_streaming_mic_recognize]
-}
-
-const cli = require(`yargs`)
- .demand(1)
- .command(
- `sync `,
- `Detects speech in a local audio file.`,
- {},
- (opts) => syncRecognize(opts.filename, opts.encoding, opts.sampleRateHertz, opts.languageCode)
- )
- .command(
- `sync-gcs `,
- `Detects speech in an audio file located in a Google Cloud Storage bucket.`,
- {},
- (opts) => syncRecognizeGCS(opts.gcsUri, opts.encoding, opts.sampleRateHertz, opts.languageCode)
- )
- .command(
- `sync-words `,
- `Detects speech in a local audio file with word time offset.`,
- {},
- (opts) => syncRecognizeWords(opts.filename, opts.encoding, opts.sampleRateHertz, opts.languageCode)
- )
- .command(
- `async `,
- `Creates a job to detect speech in a local audio file, and waits for the job to complete.`,
- {},
- (opts) => asyncRecognize(opts.filename, opts.encoding, opts.sampleRateHertz, opts.languageCode)
- )
- .command(
- `async-gcs `,
- `Creates a job to detect speech in an audio file located in a Google Cloud Storage bucket, and waits for the job to complete.`,
- {},
- (opts) => asyncRecognizeGCS(opts.gcsUri, opts.encoding, opts.sampleRateHertz, opts.languageCode)
- )
- .command(
- `async-gcs-words `,
- `Creates a job to detect speech with word time offset in an audio file located in a Google Cloud Storage bucket, and waits for the job to complete.`,
- {},
- (opts) => asyncRecognizeGCSWords(opts.gcsUri, opts.encoding, opts.sampleRateHertz, opts.languageCode)
- )
- .command(
- `stream `,
- `Detects speech in a local audio file by streaming it to the Speech API.`,
- {},
- (opts) => streamingRecognize(opts.filename, opts.encoding, opts.sampleRateHertz, opts.languageCode)
- )
- .command(
- `listen`,
- `Detects speech in a microphone input stream. This command requires that you have SoX installed and available in your $PATH. See https://www.npmjs.com/package/node-record-lpcm16#dependencies`,
- {},
- (opts) => streamingMicRecognize(opts.encoding, opts.sampleRateHertz, opts.languageCode)
- )
- .options({
- encoding: {
- alias: 'e',
- default: 'LINEAR16',
- global: true,
- requiresArg: true,
- type: 'string'
- },
- sampleRateHertz: {
- alias: 'r',
- default: 16000,
- global: true,
- requiresArg: true,
- type: 'number'
- },
- languageCode: {
- alias: 'l',
- default: 'en-US',
- global: true,
- requiresArg: true,
- type: 'string'
- }
- })
- .example(`node $0 sync ./resources/audio.raw -e LINEAR16 -r 16000`)
- .example(`node $0 async-gcs gs://gcs-test-data/vr.flac -e FLAC -r 16000`)
- .example(`node $0 stream ./resources/audio.raw -e LINEAR16 -r 16000`)
- .example(`node $0 listen`)
- .wrap(120)
- .recommendCommands()
- .epilogue(`For more information, see https://cloud.google.com/speech/docs`)
- .help()
- .strict();
-
-if (module === require.main) {
- cli.parse(process.argv.slice(2));
-}
diff --git a/speech/resources/audio.raw b/speech/resources/audio.raw
deleted file mode 100644
index 5ebf79d3c9c..00000000000
Binary files a/speech/resources/audio.raw and /dev/null differ
diff --git a/speech/resources/audio2.raw b/speech/resources/audio2.raw
deleted file mode 100644
index 35413b78817..00000000000
Binary files a/speech/resources/audio2.raw and /dev/null differ
diff --git a/speech/resources/quit.raw b/speech/resources/quit.raw
deleted file mode 100644
index a01dfc45a59..00000000000
Binary files a/speech/resources/quit.raw and /dev/null differ
diff --git a/speech/system-test/quickstart.test.js b/speech/system-test/quickstart.test.js
deleted file mode 100644
index 6a86782a100..00000000000
--- a/speech/system-test/quickstart.test.js
+++ /dev/null
@@ -1,35 +0,0 @@
-/**
- * Copyright 2017, Google, Inc.
- * 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';
-
-const path = require(`path`);
-const test = require(`ava`);
-
-const cmd = `node quickstart.js`;
-const cwd = path.join(__dirname, `..`);
-const text = `how old is the Brooklyn Bridge`;
-
-const {
- runAsync
-} = require(`@google-cloud/nodejs-repo-tools`);
-
-test.before(async () => {
-});
-
-test(`should run quickstart`, async (t) => {
- const output = await runAsync(`${cmd}`, cwd);
- t.true(output.includes(`Transcription: ${text}`));
-});
diff --git a/speech/system-test/recognize.test.js b/speech/system-test/recognize.test.js
deleted file mode 100644
index 7c729d5b53b..00000000000
--- a/speech/system-test/recognize.test.js
+++ /dev/null
@@ -1,82 +0,0 @@
-/**
- * Copyright 2016, Google, Inc.
- * 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';
-
-const path = require(`path`);
-const storage = require(`@google-cloud/storage`)();
-const test = require(`ava`);
-const uuid = require(`uuid`);
-
-const {
- runAsync
-} = require(`@google-cloud/nodejs-repo-tools`);
-
-const bucketName = `nodejs-docs-samples-test-${uuid.v4()}`;
-const cmd = `node recognize.js`;
-const cwd = path.join(__dirname, `..`);
-const filename = `audio.raw`;
-const filepath = path.join(__dirname, `../resources/${filename}`);
-const text = `how old is the Brooklyn Bridge`;
-
-test.before(async () => {
- const [bucket] = await storage.createBucket(bucketName);
- await bucket.upload(filepath);
-});
-
-test.after.always(async () => {
- const bucket = storage.bucket(bucketName);
- await bucket.deleteFiles({ force: true });
- await bucket.deleteFiles({ force: true }); // Try a second time...
- await bucket.delete();
-});
-
-test(`should run sync recognize`, async (t) => {
- const output = await runAsync(`${cmd} sync ${filepath}`, cwd);
- t.true(output.includes(`Transcription: ${text}`));
-});
-
-test(`should run sync recognize on a GCS file`, async (t) => {
- const output = await runAsync(`${cmd} sync-gcs gs://${bucketName}/${filename}`, cwd);
- t.true(output.includes(`Transcription: ${text}`));
-});
-
-test(`should run sync recognize with word time offset`, async (t) => {
- const output = await runAsync(`${cmd} sync-words ${filepath}`, cwd);
- t.true(output.includes(`Transcription: ${text}`));
- t.true(new RegExp(`\\d+\\.\\d+ secs - \\d+\\.\\d+ secs`).test(output));
-});
-
-test(`should run async recognize on a local file`, async (t) => {
- const output = await runAsync(`${cmd} async ${filepath}`, cwd);
- t.true(output.includes(`Transcription: ${text}`));
-});
-
-test(`should run async recognize on a GCS file`, async (t) => {
- const output = await runAsync(`${cmd} async-gcs gs://${bucketName}/${filename}`, cwd);
- t.true(output.includes(`Transcription: ${text}`));
-});
-
-test(`should run async recognize on a GCS file with word time offset`, async (t) => {
- const output = await runAsync(`${cmd} async-gcs-words gs://${bucketName}/${filename}`, cwd);
- t.true(output.includes(`Transcription: ${text}`));
- // Check for word time offsets
- t.true(new RegExp(`\\d+\\.\\d+ secs - \\d+\\.\\d+ secs`).test(output));
-});
-
-test(`should run streaming recognize`, async (t) => {
- const output = await runAsync(`${cmd} stream ${filepath}`, cwd);
- t.true(output.includes(`Transcription: ${text}`));
-});