This is not quite the answer, but I can not leave comments at the moment> <
I had a similar problem with an application created using js audio api, and a fairly easy fix led to a decrease in sound quality and a change in format.
In your case, I could think about setting the sampling rate and sampling rate as low as possible without affecting the listener (for example, 44.1 kHz and 16-bit depth).
You can also try changing the format, wav, theoretically, it should work well not on processor intensity, but there are other uncompressed formats (e.g. .aiff)
You can try using several pi cores:
https://nodejs.org/api/cluster.html
Although this can be a little tricky if you are performing an audio stream in parallel with other unrelated processes, you can try moving the audio to a separate processor.
You might be trying to use node with more RAM, although in your case, I doubt that I can.
The biggest problem, however, may be in the code, unfortunately, I have no experience with the modules you use, and as such can give real advice on this (therefore, why I said that this is not an answer worthy: p )
source share