Skip to content

Instantly share code, notes, and snippets.

@savelee
Created April 8, 2020 12:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save savelee/c8f5646ed3cf63ea397cc92f11ab052b to your computer and use it in GitHub Desktop.
Save savelee/c8f5646ed3cf63ea397cc92f11ab052b to your computer and use it in GitHub Desktop.
Speech to Text - Streaming
// 1)
async function transcribeAudioStream(audio, cb) {
// 2)
const recognizeStream = speechClient.streamingRecognize(request)
// 3)
.on('data', function(data){
console.log(data);
cb(data);
})
// 4)
.on('error', (e) => {
console.log(e);
})
.on('end', () => {
console.log('on end');
});
// 5)
audio.pipe(recognizeStream);
audio.on('end', function() { });
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment