audio-type

Detect the audio type of a Buffer/Uint8Array

MIT 15 个版本
安装
npm install audio-type
yarn add audio-type
pnpm add audio-type
bun add audio-type
README

audio-type test stable npm license

Detect the audio type of a ArrayBuffer/Uint8Array

Install

$ npm i audio-type

Usage

Node.js
import readChunk from 'read-chunk'; // npm install read-chunk
import audioType from 'audio-type';
var buffer = readChunk.sync('meow.wav', 0, 64);

audioType(buffer);
//=> wav
Browser
import audioType from './audio-type.js'

var xhr = new XMLHttpRequest();
xhr.open('GET', 'meow.flac');
xhr.responseType = 'arraybuffer';

xhr.onload = function () {
	audioType(this.response);
	//=> flac
};

xhr.send();

API

audioType(buffer)

Returns: 'wav', 'aiff', 'mp3', 'aac', 'flac', 'm4a', 'opus', 'oga', 'qoa', 'mid', 'caf', 'wma', 'amr', 'webm'

buffer

Type: buffer (Node.js), arrayBuffer, uint8array

It only needs the first 64 bytes.

License

MIT •

版本列表
2.4.1 2026-04-07
2.4.0 2026-03-14
2.2.1 2023-03-03
2.2.0 2023-03-03
2.1.1 2023-03-03
2.1.0 2023-03-03
2.0.0 2023-03-02
1.0.2 2016-04-23
1.0.0 2015-01-13
0.3.0 2014-11-22
0.1.4 2014-05-08
0.1.3 2014-05-01
0.1.2 2014-04-30
0.1.1 2014-04-29
0.1.0 2014-04-27