The isValidAudio
function is used to check whether an audio file is valid or not. It accepts a Buffer as an argument.
You can also pass an options object as a second argument to exclude a specific type.
import { isValidAudio } from 'multiform-validator';
import AudioBuffer from 'audio-buffer';
import AudioBuffer2 from 'audio-buffer2';
const buffer: Buffer = AudioBuffer;
const isValid = isValidAudio(buffer);
console.log(isValid); // true if the audio is valid, false otherwise
const buffer2: Buffer = AudioBuffer2;
const isValid2 = isValidAudio(buffer2, { exclude: ['wav'] });
console.log(isValid2); // true if the audio is valid, false otherwise