New Tool Radar

Local AI

How to Identify Sounds in an Audio Clip with LocalAI Audio Classification

Install the ced-base-f16 sound model in LocalAI, send an audio clip to the /v1/audio/classification endpoint, and read back scored AudioSet labels such as Dog bark and Glass breaking.

Schematic diagram with three steps: install the ced-base-f16 model, send an audio clip to the /v1/audio/classification endpoint with top_k 10, then read the labels Baby cry, infant cry at score 0.87 and Crying, sobbing at 0.41, noting scores do not sum to 1.

Sound-event classification (audio tagging) answers the question “what am I hearing?” — given an audio clip, it returns a list of scored AudioSet labels (for example Baby cry, infant cry, Glass breaking, Dog bark, Alarm). This is not transcription: no words come back, only what sounds are in the clip and how strongly each one scored. LocalAI exposes it through the /v1/audio/classification endpoint, modelled after /v1/audio/transcriptions, so any HTTP client works and there is no Python dependency on the consumer side.

Install a sound-classification model

First install a classification model from the gallery. The docs’ example uses ced-base-f16:

local-ai run ced-base-f16

The reference backend is ced.cpp (CED, a 527-class AudioSet tagger), a small ViT over a log-mel spectrogram ported to ggml with full PyTorch parity. Apache-2.0 weights are redistributable as GGUF. parakeet.cpp can also load a CED model (through third_party/ced.cpp) and serve /v1/audio/classification from the same backend used for ASR and diarization: install parakeet-cpp-ced-tiny or parakeet-cpp-ced-base from the gallery, or point parameters.model at a CED GGUF under backend: parakeet-cpp. The bundle entries parakeet-cpp-bundle-small and parakeet-cpp-bundle-standard also serve this endpoint: they hold CED-Small next to the transcription, VAD and diarization models (sound_component:ced).

Send the clip to the classification endpoint

Send the file as a multipart upload with the model name:

curl http://localhost:8080/v1/audio/classification \
  -H "Content-Type: multipart/form-data" \
  -F file="@/path/to/clip.wav" \
  -F model="ced-base-f16" \
  -F top_k=10

The request fields are: file (required, audio in any format ffmpeg accepts), model (required, name of the sound-classification-capable model, for example ced-base-f16), top_k (number of top tags to return; 0 means the backend default), and threshold (drop tags scoring below this value). The same request works unchanged against a parakeet-cpp CED model, for example with this model file:

name: parakeet-ced-tiny
backend: parakeet-cpp
parameters:
  model: ced-tiny-q8_0.gguf
known_usecases:
  - sound_classification

Then send the same curl with -F model="parakeet-ced-tiny". Note that parakeet.cpp scores the clip in 10 s windows and averages each class’s score across the windows before sorting and applying top_k/threshold — CED’s own method for clips longer than one window.

Read the scored labels

The reply carries a detections list. The docs’ example reply, for the model ced-base-f16, is:

{
  "model": "ced-base-f16",
  "detections": [
    {"index": 23, "label": "Baby cry, infant cry", "score": 0.87},
    {"index": 22, "label": "Crying, sobbing", "score": 0.41}
  ]
}

Detections are returned in score-descending order, so the first entry is the strongest match. Scores are per-class probabilities (multi-label, independent), so they do not sum to 1: a clip can score highly for several labels at once, and adding the scores up is not a check that anything is wrong.

Try it: four checks from install to labelled sounds

Check What you should see If you do not see it
Model installed ced-base-f16 installed with local-ai run ced-base-f16 Check the gallery install finished and LocalAI is running
Request sent A reply from /v1/audio/classification with no error Check the file path after @, the model name, and that LocalAI is running on localhost:8080
Top label A detections list in score-descending order; the docs’ example reply has Baby cry, infant cry at 0.87 first and Crying, sobbing at 0.41 second If the list is empty, check threshold is not dropping every tag and top_k is not 0 with a backend default of none
Scores read right Each detection has an index, a label, and a score; the scores do not sum to 1 Do not add the scores up expecting 1 — they are per-class probabilities, multi-label and independent

Expected result. We checked the LocalAI sound classification docs page, which gives sound-event classification as the answer to “what am I hearing?” with a list of scored AudioSet labels such as Baby cry, infant cry, Glass breaking, Dog bark, and Alarm, the /v1/audio/classification endpoint modelled after /v1/audio/transcriptions, the reference backend ced.cpp as a 527-class AudioSet tagger and a small ViT over a log-mel spectrogram ported to ggml with full PyTorch parity with Apache-2.0 weights redistributable as GGUF, parakeet.cpp loading a CED model through third_party/ced.cpp and serving the endpoint from the same backend used for ASR and diarization with 10 s windows averaged before sorting and applying top_k/threshold, the gallery installs parakeet-cpp-ced-tiny and parakeet-cpp-ced-base and the parakeet-ced-tiny YAML with backend parakeet-cpp, model ced-tiny-q8_0.gguf, and known_usecases sound_classification, the bundle entries parakeet-cpp-bundle-small and parakeet-cpp-bundle-standard with sound_component:ced, any HTTP client working with no Python dependency on the consumer side, the request fields file, model, top_k with 0 as the backend default, and threshold, the curl command for clip.wav with model ced-base-f16 and top_k=10, and the example reply with model ced-base-f16, Baby cry, infant cry at 0.87 and Crying, sobbing at 0.41, detections in score-descending order, and scores as per-class probabilities that do not sum to 1. We did not install LocalAI, download any model, or classify any audio on this machine.

Limits

This guide covers identifying sounds in a clip only. It does not transcribe speech — for words, use /v1/audio/transcriptions — and it does not say who spoke when — that is /v1/audio/diarization. A parakeet-cpp ASR model can also point sound_model at a CED GGUF to add timed sound events to a diarization call with include_sounds=true, but that is sound events inside a diarization reply, not this endpoint. The labels come from the 527 AudioSet classes the CED model knows, so a sound outside that set has no label to match. Scores are independent per-class probabilities, so they are not shares of a whole and do not sum to 1. We did not run any of this ourselves.

Sources

See all