title: write to a wav file while streaming node js
body: <p>Is there a way to force .pipe on a stream to write to a file every certain time/size?</p>
  
  <p>Basically, I am using socket io stream, from a browser I am sending a buffer with audio and I send with emit:</p>
  
  <p><strong>Browser</strong></p>
  
  <pre><code>        c.onaudioprocess = function(o) 
          {
          var input = o.inputBuffer.getChannelData(0);
  
              stream1.write( new ss.Buffer( convertFloat32ToInt16( input ) ));
  
          }
  </code></pre>
  
  <p><strong>Server (nodejs)</strong></p>
  
  <pre><code>var fileWriter = new wav.FileWriter('/tmp/demo.wav', {
      channels: 1,
      sampleRate: 44100,
      bitDepth: 16
  });
  
  ss(socket).on('client-stream-request', function(stream)
  {
      stream.pipe(fileWriter);
  }
  </code></pre>
  
  <p>The problem I have is that the file demo.wav will be only wrote when I finish the stream, so when I stop the microphone. But I would like it to write always, as I will be doing speech recognition using google, any ideas? If I call the speech recognition from google using pipe, the chuncks are too small and google is not able to recognize it.</p>