<commit_before>"use strict";

var Readable = require("stream").Readable;

// node-speaker
//   Output raw PCM audio data to the speakers
//   https://github.com/TooTallNate/node-speaker
//   npm install speaker
var Speaker = require("speaker");

// node v0.8.x compat
// readable-stream
//   https://github.com/isaacs/readable-stream
//   npm install readable-stream
if (!Readable) {
    Readable = require("readable-stream/readable");
}

function TimbreNodePlayer(sys) {
    
    this.maxSamplerate     = 48000;
    this.defaultSamplerate = 44100;
    this.env = "node";
    this.node = null;
    
    this.play = function() {
        this.node = new Readable();
        this.node._read = function(n, fn) {
            var inL = sys.strmL, inR = sys.strmR;
            var buf = new Buffer(n);
            
            var i, j = 0;
            var imax = inL.length;
            
            n = (n >> 2) / sys.streamsize;
            while (n--) {
                sys.process();
                for (i = 0; i < imax; ++i) {
                    buf.writeInt16LE((inL[i] * 32760)|0, j);
                    j += 2;
                    buf.writeInt16LE((inR[i] * 32760)|0, j);
                    j += 2;
                }
            }
            
            fn(null, buf);
        };
        this.node.pipe(new Speaker({sampleRate:sys.samplerate}));
    };
    
    this.pause = function() {
        process.nextTick(this.node.emit.bind(this.node, "end"));
    };
}


module.exports = require("./timbre.dev").bind(TimbreNodePlayer);

var fs   = require("fs");
var lame = (function() {
    try { return require("lame"); } catch (e) {}
})();
var ogg = (function() {
    try { return require("ogg"); } catch (e) {}
})();
var vorbis = (function() {
    try { return require("vorbis"); } catch (e) {}
})();

var Decoder = timbre.modules.Decoder;

Decoder.getBinaryWithPath = function(path, callback) {
    fs.readFile(path, function(err, data) {
        if (!err) {
            callback(new Uint8Array(data));<commit_msg>update for readable-stream api<commit_after>"use strict";

var Readable = require("stream").Readable;

// node-speaker
//   Output raw PCM audio data to the speakers
//   https://github.com/TooTallNate/node-speaker
//   npm install speaker
var Speaker = require("speaker");

// node v0.8.x compat
// readable-stream
//   https://github.com/isaacs/readable-stream
//   npm install readable-stream
if (!Readable) {
    Readable = require("readable-stream/readable");
}

function TimbreNodePlayer(sys) {
    
    this.maxSamplerate     = 48000;
    this.defaultSamplerate = 44100;
    this.env = "node";
    this.node = null;
    
    this.play = function() {
        this.node = new Readable();
        this.node._read = function(n, fn) {
            var inL = sys.strmL, inR = sys.strmR;
            var buf = new Buffer(n);
            
            var i, j = 0;
            var imax = inL.length;
            
            n = (n >> 2) / sys.streamsize;
            while (n--) {
                sys.process();
                for (i = 0; i < imax; ++i) {
                    buf.writeInt16LE((inL[i] * 32760)|0, j);
                    j += 2;
                    buf.writeInt16LE((inR[i] * 32760)|0, j);
                    j += 2;
                }
            }

            if (fn) {
                fn(null, buf);
            } else {
                this.push(buf);
            }
        };
        this.node.pipe(new Speaker({sampleRate:sys.samplerate}));
    };
    
    this.pause = function() {
        process.nextTick(this.node.emit.bind(this.node, "end"));
    };
}


module.exports = require("./timbre.dev").bind(TimbreNodePlayer);

var fs   = require("fs");
var lame = (function() {
    try { return require("lame"); } catch (e) {}
})();
var ogg = (function() {
    try { return require("ogg"); } catch (e) {}
})();
var vorbis = (function() {
    try { return require("vorbis"); } catch (e) {}
})();

var Decoder = timbre.modules.Decoder;

Decoder.getBinaryWithPath = function(path, callback) {
    fs.readFile(path, function(err, data) {
        if (!err) {
            callback(new Uint8Array(data));
{'fraction_non_alphanumeric': 0.15780570323827936, 'fraction_numerical': 0.016433059449009184, 'mean_word_length': 1.8466299862448419, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2680121', 'n_tokens_mistral': 1399, 'n_tokens_neox': 1320, 'n_words': 286}