wav-tag
v1.0.0
Published
WAV metadata tagging library written in pure JavaScript
Downloads
9
Maintainers
Readme
wav-tag is an open sourced JavaScript library used to view and edit the metadata of WAV media files.
You can explore the examples directory to show how to use the library.
Features
- Read and write WAV metadata
- Easy to use
Installation
You can download the ready-to-use script at
GitHub releases or you can
build your own by cloning this repository using git
then build it.
git clone https://github.com/eidoriantan/wav-tag
cd ./wav-tag
npm install
npm run build
You can also install this package by using npm
:
npm install --save wav-tag@latest
If you are using browser, you can just install the library through a CDN:
<script src="https://cdn.jsdelivr.net/npm/wav-tag@latest/dist/wav-tag.min.js">
Usage
For browsers:
<input type="file" id="input-file" accept="audio/wav">
<script>
const inputFile = document.getElementById('input-file')
inputFile.onchange = function () {
const reader = new FileReader()
reader.onload = function () {
const buffer = this.result
const wavtag = new WAVTag(buffer)
wavtag.read()
// Handle error if there's any
if (wavtag.error !== '') throw new Error(wavtag.error)
else console.log(wavtag.metadata)
}
if (this.files.length > 0) {
reader.readAsArrayBuffer(this.files[0])
}
}
</script>
For Node.js:
const WAVTag = require('wav-tag')
const fs = require('fs')
const buffer = fs.readFileSync('/path/to/audio.wav')
const wavtag = new WAVTag(buffer)
wavtag.read()
// Handle error if there's any
if (wavtag.error !== '') throw new Error(wavtag.error)
else console.log(wavtag.tags)
Support
If you had found a bug or any unexpected behavior, you can submit an issue through GitHub issues.