Skip to content

Instantly share code, notes, and snippets.

@kbridbur
Created August 16, 2019 02:26
Show Gist options
  • Save kbridbur/4bde930a5ad1a48f5da63e6c2534e1b4 to your computer and use it in GitHub Desktop.
Save kbridbur/4bde930a5ad1a48f5da63e6c2534e1b4 to your computer and use it in GitHub Desktop.
Rev.ai Node Streaming Example
const revai = require('revai-node-sdk');
const fs = require('fs');
var client = new revai.RevAiStreamingClient(YOUR-ACCESS-TOKEN, YOUR-AUDIO-CONFIG);
client.on('close', (code, reason) => { console.log(`Connection closed, ${code}: ${reason}`); });
client.on('httpResponse', code => { console.log(`Streaming client received http response with code: ${code}`); });
client.on('connectFailed', error => { console.log(`Connection failed with error: ${error}`); });
client.on('connect', connectionMessage => { console.log(`Connected with message: ${connectionMessage}`); });
var stream = client.start();
stream.on('data', data => { console.log(data); });
stream.on('end', function () { console.log("End of Stream"); });
var file = fs.createReadStream("./resources/example.raw");
file.on('end', () => { client.end(); });
file.pipe(stream);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment