Created
August 16, 2019 02:26
-
-
Save kbridbur/4bde930a5ad1a48f5da63e6c2534e1b4 to your computer and use it in GitHub Desktop.
Rev.ai Node Streaming Example
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
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