|
| 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 | +}); |
0 commit comments