UNPKG

audio-slicer

Version:

A Node.js module to split audio files into segments. This module accepts audio data buffers as input and returns an array of Buffers representing the sliced audio segments.

18 lines (16 loc) 533 B
const { audioToSlice } = require('./index') const { readFile } = require('fs-extra') const run = async () => { try { // Read the audio file as a buffer const audio = await readFile('./audio.mp3') // Specify segment duration in seconds (e.g., 75 seconds) const seconds = 75 // Call the audioToSlice function const buffers = await audioToSlice(audio, seconds) console.log(`Sliced into ${buffers.length} segments.`) } catch (error) { console.error('Error slicing audio:', error.message) } } run()