How to use the microphone-stream.toRaw function in microphone-stream

To help you get started, we’ve selected a few microphone-stream examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aws-samples / amazon-transcribe-websocket-static / lib / main.js View on Github external
function convertAudioToBinaryMessage(audioChunk) {
    let raw = mic.toRaw(audioChunk);

    if (raw == null)
        return;

    // downsample and convert the raw audio bytes to PCM
    let downsampledBuffer = audioUtils.downsampleBuffer(raw, sampleRate);
    let pcmEncodedBuffer = audioUtils.pcmEncode(downsampledBuffer);

    // add the right JSON headers and structure to the message
    let audioEventMessage = getAudioEventMessage(Buffer.from(pcmEncodedBuffer));

    //convert the JSON object + headers into a binary event stream message
    let binary = eventStreamMarshaller.marshall(audioEventMessage);

    return binary;
}
github kneekey23 / ByteConf / ml-javascript / src / components / Transcribe.js View on Github external
startMic.on('data', (chunk) => {
          var raw = mic.toRaw(chunk);
          if (raw == null) {
            return;
          }

        buffer = buffer.concat(...raw)
        this.setState({audioBuffer: buffer})
      });

microphone-stream

A stream of raw audio data from the microphone for use in browsers with getUserMedia

MIT
Latest version published 3 years ago

Package Health Score

48 / 100
Full package analysis

Popular microphone-stream functions