Created
April 8, 2020 12:30
-
-
Save savelee/c8f5646ed3cf63ea397cc92f11ab052b to your computer and use it in GitHub Desktop.
Speech to Text - Streaming
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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