-
-
Notifications
You must be signed in to change notification settings - Fork 79
How to properly concat WAV blobs? #7
Comments
@dontfireme oops, sorry. I missed your issue (had a really hard time). Don’t worry to ping maintainer in future issues. Issues without an answer is a shame for open source community (shame on me 😅). There is no easy way since But, in another hand, it is not so complicated. In Audio Recorder Polyfill every “blob” is a full WAV file. So there is two ways:
|
Here is a solution for Node.js (backend):
I think the simplest way for browser JS is to create multiple The best solution is to add OGG encoder. OGG file doesn’t need a file length in header, as result we can generate blobs and go cool |
If you have to concat WAV blobs in browser you can decode each blob to audio buffer with decodeAudioData method. Then concat buffers, see this audio-buffer-utils |
Where to find this OGG encoder? |
@anrikun we do not have built-in yet. You can try to use MP3 encoder (but I am not sure that you can simply concat files). |
You can slice the first 44 bytes from the discrete WAV file then concatenate the raw PCM into a single file. In brief see https://github.com/guest271314/audioInputToWav, https://github.com/guest271314/AudioWorkletStream/blob/master/audioWorklet.js#L19. |
To play the audio at an
To create a discrete WAV file
|
I often receive this error "Uncaught (in promise) RangeError: byte length of Uint16Array should be a multiple of 2 |
Safari throws this error: Unhandled Promise Rejection: RangeError: ArrayBuffer length minus the byteOffset is not a multiple of the element size |
Using what code? |
Thé code provided to CONVERT a blob in a WAV.
|
Try the code in this comment #7 (comment). This is what I use to encode to WAV https://github.com/guest271314/WebCodecsOpusRecorder/blob/6b661559806751f21f5ea57bffa0e77076a37286/WebCodecsOpusRecorder.js#L256-L341. |
Thanks... but I don't think it's the easiest thing to replace the code with
other code :-)
It seems that this line of code is the problem:
const uint16 = new Uint16Array(
await new Blob(
await Promise.all(
audiochunks.map((file) => file.slice(44).arrayBuffer())
)
).arrayBuffer()
);
Sometimes (not always) I get this error: "byte length of Uint16Array should be a multiple of 2 "
|
Sure it is. However, if you decide to modify the code in this repository then you'll need to make sure the resulting There are a few ways to do that. It looks like from the code multiple WAV files are created then the header is removed before merging the channel data to a single WAV. I don't think you need to created multiple WAV files up front. One way to achieve the requirement is to fill an |
I know, that there is a problem with WAV, due to:
But do you have any idea how to properly concat WAV blobs? I'm following docs:
then somewhere:
and the duration of the recorded audio is everytime 1sec. Is it possible to solve this problem somehow?
The text was updated successfully, but these errors were encountered: