← Back to models

clap-htsat-unfused

embedderAudio
v1.0.00 B
antfly inference pull Xenova/clap-htsat-unfused
By XenovaHuggingFaceCreated: 9/13/2026

About CLAP#

CLAP (Contrastive Language-Audio Pre-training) is a multimodal model developed by LAION-AI that learns audio concepts from natural language supervision. It creates a joint embedding space where both text and audio can be represented as vectors, enabling powerful cross-modal search and retrieval.

This model uses the HTSAT-unfused architecture (Hierarchical Token-Semantic Audio Transformer without feature fusion).

Capabilities#

  • Text Embeddings: Convert text descriptions into vectors
  • Audio Embeddings: Convert audio clips into vectors in the same space as text
  • Cross-Modal Retrieval: Search audio with text queries, or text with audio
  • Zero-Shot Classification: Classify sounds into categories without training

Use Cases#

Use CaseDescription
Audio SearchFind audio clips using natural language queries like "a dog barking in the rain"
Music DiscoverySearch music libraries by describing mood, instruments, or genre
Sound ClassificationCategorize environmental sounds, speech, or music without labeled data
Audio RAGBuild retrieval-augmented generation systems with audio content

Antfly Inference API Usage#

Text Embedding#

Generate embeddings for text descriptions:

curl -X POST "http://localhost:8080/ai/v1/embed" \
-H "Content-Type: application/json" \
-d '{
"model": "clap-htsat-unfused",
"input": [
  {"type": "text", "text": "a dog barking loudly"},
  {"type": "text", "text": "jazz piano playing softly"}
]
}'

Audio Embedding (Remote URL)#

Generate embeddings for audio from URLs:

curl -X POST "http://localhost:8080/ai/v1/embed" \
-H "Content-Type: application/json" \
-d '{
"model": "clap-htsat-unfused",
"input": [
  {"type": "audio_url", "audio_url": {"url": "https://example.com/dog-bark.wav"}}
]
}'

Audio Embedding (Base64)#

Generate embeddings for audio using base64 data URIs:

import requests
import base64

# Read and encode an audio file
with open("dog-bark.wav", "rb") as f:
  audio_data = base64.b64encode(f.read()).decode()

response = requests.post(
  "http://localhost:8080/ai/v1/embed",
  json={
      "model": "clap-htsat-unfused",
      "input": [
          {"type": "audio_url", "audio_url": {"url": f"data:audio/wav;base64,{audio_data}"}}
      ]
  }
)

embeddings = response.json()["embeddings"]

Mixed Text and Audio#

Embed both text and audio in a single request - useful for building cross-modal search indexes:

import requests

response = requests.post(
  "http://localhost:8080/ai/v1/embed",
  json={
      "model": "clap-htsat-unfused",
      "input": [
          {"type": "text", "text": "a dog barking loudly"},
          {"type": "audio_url", "audio_url": {"url": "https://example.com/dog-bark.wav"}},
          {"type": "text", "text": "birds chirping at dawn"},
          {"type": "audio_url", "audio_url": {"url": "https://example.com/birds.wav"}}
      ]
  }
)

# Returns 4 embeddings in the same order as input
embeddings = response.json()["embeddings"]

Supported Audio Formats#

CLAP in Antfly Inference supports multiple ways to provide audio:

FormatExampleDescription
HTTP/HTTPShttps://example.com/audio.wavRemote audio from the web
Data URIdata:audio/wav;base64,...Base64-encoded audio
Local filefile:///path/to/audio.wavLocal filesystem paths
S3s3://endpoint/bucket/keyAudio stored in S3-compatible storage

Supported audio codecs: WAV, MP3, FLAC, OGG.

Limitations#

Based on the LAION CLAP paper:

  • Audio duration: Optimized for clips up to ~10 seconds; longer audio is truncated
  • Language bias: Primarily trained on English text descriptions
  • Training data bias: Skewed toward common environmental sounds and music; may underperform on niche or domain-specific audio
  • Fine-grained audio: May struggle with subtle distinctions between similar sounds (e.g., different engine types)
  • Speech content: Captures acoustic properties of speech rather than linguistic content

Antfly Configuration#

To use CLAP as the default embedder in your Antfly configuration:

embedder:
  provider: antfly
  model: clap-htsat-unfused

For tables that store audio content:

tables:
  audio:
    indexes:
      embedding:
        type: embedding
        embedder:
          provider: antfly
          model: clap-htsat-unfused
        fields:
          - audio_url
          - description

Versions

TagStatus
latestAvailable
v1.0.0Latest

Usage

Pull the model

antfly inference pull Xenova/clap-htsat-unfused

Start Antfly Inference

# With Antfly standalone (Antfly Inference enabled by default)
antfly standalone

# Or run Antfly Inference on its own
antfly inference

Use in configuration

# config.yaml
embedder:
  provider: antfly
  model: Xenova/clap-htsat-unfused