The `WaveToBlobService` class is responsible for converting audio data (in `Blob` format) to a WAV file. It supports encoding in both 16-bit PCM and 32-bit float formats and includes functionality for audio resampling.
npm install @eduvidu/nodeThe WaveToBlobService class is responsible for converting audio data (in Blob format) to a WAV file. It supports encoding in both 16-bit PCM and 32-bit float formats and includes functionality for audio resampling.
- Converts audio Blob data to WAV format.
- Supports both 16-bit PCM and 32-bit float encoding.
- Handles audio resampling when needed.
- Provides helper functions for encoding audio data and managing WAV file headers.
To use this service, import it into your project and call the relevant methods.
``typescript
import { waveToBlobService } from './path/to/WaveToBlobService';
async function convertBlobToWav(blob: Blob) {
const wavBlob = await waveToBlobService.getWaveBlob(blob, true);
console.log(wavBlob);
}
`
The BlobCombinator class combines multiple audio Blob objects into a single audio file. It uses the crunker library to concatenate and optionally download the combined audio. Additionally, it handles audio resampling to ensure a consistent sample rate of 44.1 kHz for all input audio buffers.
- Combines multiple audio Blob objects into a single audio Blob.crunker
- Supports resampling of audio buffers to ensure consistency in sample rate (default is 44.1 kHz).
- Optionally downloads the resulting audio file.
- Uses the library for audio manipulation.
First, install crunker in your project:
`bash``
npm install crunker