NSFW audio classifier
An audio encoder with two heads, for filtering audio datasets. It takes a clip of up to 30 seconds and returns two scores between 0 and 1:
nsfw: explicit sexual audio.gore: violence, such as gunfire with people screaming or people being hurt.
A score of 0.5 or more means the clip is flagged.
import torch, torchaudio
from transformers import AutoModel
model = AutoModel.from_pretrained("gijs/nsfw-audio-classifier", trust_remote_code=True).eval()
waveform, sampling_rate = torchaudio.load("clip.wav")
model.predict([waveform], sampling_rate=sampling_rate) # [{"nsfw": 0.98, "gore": 0.01}]
Needs transformers, timm and torchaudio. model(input_values=..., sampling_rate=...) returns the scores as tensors,
together with the audio embeddings. The audio encoder is the audio tower of laion/clap2-large-audioxl-s1B.
Evaluation
On a held-out evaluation set labelled by listening, the nsfw head is about 95 % accurate at a threshold of 0.1. The
default threshold of 0.5 is stricter: it raised no false alarm on that set and found about half of the explicit clips.
The gore head has not been evaluated on a held-out set.
Intended use
Only for filtering data: finding audio that should not be in a dataset. Not for any other use.
The model makes mistakes in both directions. It misses clips it should flag and flags clips that are harmless. If removing this kind of audio really matters, do not rely on this model alone: add a second check, such as a person listening to what it flags and to a sample of what it lets through.