Skip to content

Commit

Permalink
Repository Migration (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukesneeringer authored and Ace Nassri committed Nov 17, 2022
1 parent 6f80e1d commit 8dd5823
Show file tree
Hide file tree
Showing 7 changed files with 295 additions and 258 deletions.
3 changes: 3 additions & 0 deletions speech/.eslintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
rules:
no-console: off
38 changes: 10 additions & 28 deletions speech/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,42 +4,24 @@
"private": true,
"license": "Apache-2.0",
"author": "Google Inc.",
"repository": {
"type": "git",
"url": "https://github.com/GoogleCloudPlatform/nodejs-docs-samples.git"
},
"repository": "googleapis/nodejs-speech",
"engines": {
"node": ">=4.3.2"
"node": ">=4.0.0"
},
"scripts": {
"lint": "samples lint",
"pretest": "npm run lint",
"test": "samples test run --cmd ava -- -T 20s --verbose system-test/*.test.js"
"test": "repo-tools test run --cmd ava -- -T 20s --verbose system-test/*.test.js"
},
"dependencies": {
"@google-cloud/speech": "0.10.2",
"@google-cloud/storage": "1.2.1",
"@google-cloud/speech": "0.10.3",
"@google-cloud/storage": "1.4.0",
"node-record-lpcm16": "0.3.0",
"yargs": "8.0.2"
"yargs": "10.0.3"
},
"devDependencies": {
"@google-cloud/nodejs-repo-tools": "1.4.17",
"ava": "0.21.0",
"@google-cloud/nodejs-repo-tools": "2.1.1",
"ava": "0.23.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"
}
]
"sinon": "4.1.1",
"uuid": "3.1.0"
}
}
26 changes: 14 additions & 12 deletions speech/quickstart.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@

// [START speech_quickstart]
// Imports the Google Cloud client library
const Speech = require('@google-cloud/speech');
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
// Creates a client
const client = new speech.SpeechClient({
projectId: projectId,
});

// The name of the audio file to transcribe
Expand All @@ -37,27 +37,29 @@ const audioBytes = file.toString('base64');

// The audio file's encoding, sample rate in hertz, and BCP-47 language code
const audio = {
content: audioBytes
content: audioBytes,
};
const config = {
encoding: 'LINEAR16',
sampleRateHertz: 16000,
languageCode: 'en-US'
languageCode: 'en-US',
};
const request = {
audio: audio,
config: config
config: config,
};

// Detects speech in the audio file
speechClient.recognize(request)
.then((data) => {
client
.recognize(request)
.then(data => {
const response = data[0];
const transcription = response.results.map(result =>
result.alternatives[0].transcript).join('\n');
const transcription = response.results
.map(result => result.alternatives[0].transcript)
.join('\n');
console.log(`Transcription: ${transcription}`);
})
.catch((err) => {
.catch(err => {
console.error('ERROR:', err);
});
// [END speech_quickstart]
Loading

0 comments on commit 8dd5823

Please sign in to comment.