A wav
file is a file with an audio header, then slices of pcm
audio. To create a wav file from PCM, you need to add a wav header with the correct sample rate
Created
May 27, 2018 12:31
-
-
Save mheap/48dacc2517cb4b6ce95597c5369b9a93 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// npm install waveheader | |
const fs = require("fs"); | |
const header = require("waveheader"); | |
const filename = 'file.wav'; | |
fs.writeFileSync(filename, header(0, {sampleRate: "16000"}); // 16000 khz | |
fs.appendFileSync(filename, fs.readFileSync('audio.pcm')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment