Asterisk -> AudioSocket -> Slin to Wav chunk

I’m trying to set up an LLM (Large Language Model) integration with Asterisk. For this, I’m using AudioSocket to get bidirectional audio from the call. The AudioSocket is working fine.

To help with understanding, my setup has two main modules:

  1. AudioSocket – handles real-time audio from the call.
  2. LLM – processes the audio using an AI model, which only accepts audio in WAV format.

I’m using a TCP port to send audio data to the LLM. Since Asterisk provides audio in SLIN (raw PCM) format, I need to convert the SLIN stream to WAV format so the AI model can process it.

The issue I’m facing is:

I’m not able to save the WAV file or stream it properly on the LLM model side.

:wrench: What I need:

I’m looking for suggestions on how to:

  • Convert SLIN stream to WAV in real-time.
  • Send the WAV audio over TCP to the LLM.
  • Properly receive and handle that WAV data on the LLM side.

Here’s the AudioSocket I’m using for reference:
AudioSocket Example on GitHub

Just a note that .WAV is not a streaming format. It is a file format that consists of a bunch of chunks. Each chunk has a header and a length. You can’t compute the length until you have the whole chunk. The whole set of audio samples is held in a single chunk, so you cannot send/receive partial chunks of samples.

This isn’t possible, as you don’t know the size of the media, which is, I believe, part of the metadata, at the front of a .wav file, until you’ve reached the end of the media.

Yes, you’re right — we don’t have the complete audio length during streaming. However, I’m able to stream live audio from my Mac and receive it on the TCP port (LLM module), and it’s working. Since the audio is live, there’s no fixed length, which is expected in this case.

What format is the LLM module expecting on that TCP port?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.