Skip to content

Commit

Permalink
fix(deps): drop dependency on through2 (#388)
Browse files Browse the repository at this point in the history
  • Loading branch information
JustinBeckwith authored Jul 22, 2019
1 parent cd680c9 commit d0205bb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
16 changes: 10 additions & 6 deletions dialogflow/detect.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@
const util = require('util');
const fs = require('fs');
const {struct} = require('pb-util');
const pump = require('pump');
const through2 = require('through2');
const {Transform, pipeline} = require('stream');

const pump = util.promisify(pipeline);

function detectTextIntent(projectId, sessionId, queries, languageCode) {
// [START dialogflow_detect_intent_text]
Expand Down Expand Up @@ -164,7 +165,7 @@ async function detectAudioIntent(
// [END dialogflow_detect_intent_audio]
}

function streamingDetectIntent(
async function streamingDetectIntent(
projectId,
sessionId,
filename,
Expand Down Expand Up @@ -227,11 +228,14 @@ function streamingDetectIntent(

// Stream an audio file from disk to the Conversation API, e.g.
// "./resources/audio.raw"
pump(
await pump(
fs.createReadStream(filename),
// Format the audio stream into the request format.
through2.obj((obj, _, next) => {
next(null, {inputAudio: obj});
new Transform({
objectMode: true,
transform: (obj, _, next) => {
next(null, {inputAudio: obj});
},
}),
detectStream
);
Expand Down
4 changes: 1 addition & 3 deletions dialogflow/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,14 @@
"resources"
],
"engines": {
"node": ">=8.0.0"
"node": ">=10.0.0"
},
"scripts": {
"test": "mocha system-test --timeout=600000"
},
"dependencies": {
"dialogflow": "^0.10.2",
"pb-util": "^0.1.0",
"pump": "^3.0.0",
"through2": "^3.0.0",
"uuid": "^3.3.2",
"yargs": "^13.0.0"
},
Expand Down

0 comments on commit d0205bb

Please sign in to comment.