A TypeScript implementation of the Asterisk AudioSocket protocol with no runtime dependencies. AudioSocket bridges a live call into your own process over a plain TCP socket, which makes it the simplest way to get call audio into an application without touching Asterisk internals.
The library handles the framing, which is a three byte header followed by a payload, and the message types you actually meet: the call UUID, audio, hangup and error.
It also handles the part that catches people out. Asterisk forwards every frame to the channel the moment it arrives and does not buffer for you, so writing a whole sentence at once means the far end keeps a few frames and discards the rest. The playback helper paces one frame per 20 ms against a deadline and re-clamps rather than bursting to catch up.
MIT licensed, published on npm.
Features
- Protocol framing plus paced playback that will not overrun the far end