Skip to content

Instantly share code, notes, and snippets.

@savelee
Created April 8, 2020 11:56
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/ed39c217b8346a2eb67cff4b41fd3560 to your computer and use it in GitHub Desktop.
Save savelee/ed39c217b8346a2eb67cff4b41fd3560 to your computer and use it in GitHub Desktop.
Server - streaming to Dialogflow
//1
io.on('connect', (client) => {
//2
client.on('message', async function(data) {
const dataURL = data.audio.dataURL.split(',').pop();
let fileBuffer = Buffer.from(dataURL, 'base64');
//3 ...
});
// 4
ss(client).on('stream', function(stream, data) {
const filename = path.basename(data.name);
stream.pipe(fs.createWriteStream(filename));
//5 ...
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment