Skip to content

Commit bf72d47

Browse files
CallistoCFAce Nassri
authored andcommitted
Code Samples for new v1p1beta1 features (#118)
* MicrophoneStreamTest, and basic .ava tests- * Just cosmetic, removed some notes, added note about Event style for test. * removed .test, cleaned up yaaarghs * Cleaned up test within MicStream.js, .ava tests forthcoming * Pruned down to core streaming function, yaargs rebuilt, .ava upcoming * newest .ava test, just makes sure yaargs loads, comments addressed * Added Readme * BetaFeatures for Test, fixed from yesterday * Updated Readme * Updated Readme, fixed old paths used in testing * Updated Readme again * Updated Yaargs Examples to fit readme * Fixed Diarization bug * Speech Fixes * fixing eslint settings to merge * eslint again * testing lint quick fix * more ESlint shennanigans * cleaned up region tags * Removed audiochannelGCS * Removed Comments, also multiChannel GCS * Removed Comments, GCS MultiChannel * Removed multi Audio Channel * Added mono-channel multi Language file to sample * removed old console.log * fixed todos and filename -> fileName * removed docstrings * removed enableWordTimeOffsets in WordLvlConfidence * rebuild * fixed space * fixed package.lock for node8 circleCI * Attempted fix for circleCI node 8 * attempted mime-types fix * possible mime/CLI fix * Merged Latest package chore stuff, for circleCI * all outstanding comments, except eslint issue * confidence test fix * fixed eslinting in betaFeatures.js * eslint again * Fixed MultiChannel transcribe * multiChannelGCS test * Updated readme * updated readme, scaffolding * readme again
1 parent 4d04cb3 commit bf72d47

File tree

12 files changed

+643
-0
lines changed

12 files changed

+643
-0
lines changed

speech/betaFeatures.js

Lines changed: 528 additions & 0 deletions
Large diffs are not rendered by default.

speech/package-lock.json

100644100755
File mode changed.

speech/package.json

100644100755
File mode changed.

speech/resources/ManualTest.wav

152 KB
Binary file not shown.

speech/resources/brooklyn.flac

32.7 KB
Binary file not shown.

speech/resources/commercial_mono.wav

100644100755
File mode changed.
6.01 MB
Binary file not shown.

speech/resources/multi.wav

444 KB
Binary file not shown.
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
// /**
2+
// * Copyright 2016, Google, LLC.
3+
// * Licensed under the Apache License, Version 2.0 (the "License");
4+
// * you may not use this file except in compliance with the License.
5+
// * You may obtain a copy of the License at
6+
// *
7+
// * http://www.apache.org/licenses/LICENSE-2.0
8+
// *
9+
// * Unless required by applicable law or agreed to in writing, software
10+
// * distributed under the License is distributed on an "AS IS" BASIS,
11+
// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// * See the License for the specific language governing permissions and
13+
// * limitations under the License.
14+
// */
15+
16+
/* eslint-disable */
17+
18+
'use strict';
19+
20+
const path = require(`path`);
21+
const test = require(`ava`);
22+
23+
const {runAsync} = require(`@google-cloud/nodejs-repo-tools`);
24+
25+
const cmd = `node betaFeatures.js`;
26+
const cwd = path.join(__dirname, `..`);
27+
28+
29+
//audio file paths
30+
const monoFileName = `commercial_mono.wav`;
31+
const monoFilePath = path.join(
32+
__dirname,
33+
`../resources/${monoFileName}`
34+
);
35+
36+
const stereoFileName = `commercial_stereo.wav`;
37+
const stereoFilePath = path.join(
38+
__dirname,
39+
`../resources/${stereoFileName}`
40+
);
41+
const multiLanguageFileName = `multi.wav`;
42+
const multiLanguageFile = path.join(
43+
__dirname,
44+
`../resources/${multiLanguageFileName}`
45+
);
46+
47+
const gnomef = `Google_Gnome.wav`;
48+
const gnome = path.join(__dirname, `../resources/${gnomef}`);
49+
50+
const Brooklyn = 'brooklyn.flac';
51+
const BrooklynFilePath = path.join(
52+
__dirname,
53+
`../resources/${Brooklyn}`
54+
);
55+
56+
const monoUri = `gs://cloud-samples-tests/speech/commercial_mono.wav`;
57+
const multiUri = `gs://nodejs-docs-samples/multi_mono.wav`;
58+
const brooklynUri = `gs://cloud-samples-tests/speech/brooklyn.flac`;
59+
const stereoUri = `gs://cloud-samples-tests/speech/commercial_stereo.wav`;
60+
61+
test(`should run speech diarization on a local file`, async t => {
62+
const output = await runAsync(`${cmd} Diarization -f ${monoFilePath}`, cwd);
63+
t.true(
64+
output.includes(`speakerTag: 1`) && output.includes(`speakerTag: 2`)
65+
);
66+
});
67+
68+
test(`should run speech diarization on a GCS file`, async t => {
69+
const output = await runAsync(`${cmd} DiarizationGCS -u ${monoUri}`, cwd);
70+
t.true(
71+
output.includes(`speakerTag: 1`) && output.includes(`speakerTag: 2`)
72+
);
73+
});
74+
75+
test(`should run multi channel transcription on a local file`, async t => {
76+
const output = await runAsync(`${cmd} multiChannelTranscribe -f ${stereoFilePath}`, cwd);
77+
t.true(output.includes(`Channel Tag: 2`));
78+
});
79+
80+
test(`should run multi channel transcription on GCS file`, async t => {
81+
const output = await runAsync(`${cmd} multiChannelTranscribeGCS -u ${stereoUri}`, cwd);
82+
t.true(output.includes(`Channel Tag: 2`));
83+
});
84+
85+
test(`should transcribe multi-language on a local file`, async t => {
86+
const output = await runAsync(`${cmd} multiLanguageTranscribe -f ${multiLanguageFile}`, cwd);
87+
t.true(output.includes(`Transcription: how are you doing estoy bien e tu`));
88+
});
89+
90+
test(`should transcribe multi-language on a GCS bucket`, async t => {
91+
const output = await runAsync(`${cmd} multiLanguageTranscribeGCS -u ${multiUri}`, cwd);
92+
t.true(output.includes(`Transcription: how are you doing estoy bien e tu`));
93+
});
94+
95+
test(`should run word Level Confience on a local file`, async t => {
96+
const output = await runAsync(`${cmd} wordLevelConfidence -f ${BrooklynFilePath}`);
97+
t.true(
98+
output.includes(`Transcription: how old is the Brooklyn Bridge`) &&
99+
output.includes(`Confidence: \d\.\d`)
100+
);
101+
});
102+
103+
test(`should run word level confidence on a GCS bucket`, async t => {
104+
const output = await runAsync(`${cmd} wordLevelConfidenceGCS -u ${brooklynUri}`, cwd);
105+
t.true(
106+
output.includes(`Transcription: how old is the Brooklyn Bridge`) &&
107+
output.includes(`Confidence: \d\.\d`)
108+
);
109+
});

speech/system-test/quickstart.test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
* limitations under the License.
1414
*/
1515

16+
/* eslint-disable */
17+
1618
'use strict';
1719

1820
const path = require(`path`);

0 commit comments

Comments
 (0)