Skip to content

feat: add text and audio directory search - #80

Merged
zhenghaoz merged 2 commits into
mainfrom
feat/search-audio
Nov 9, 2026
Merged

zhenghaoz merged 2 commits into
mainfrom
feat/search-audio

Conversation

@zhangzhenghao

@zhangzhenghao zhangzhenghao commented Nov 9, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Add clap search DIRECTORY -m MODEL (--text TEXT | --audio FILE) for recursive audio retrieval.
  • Rank WAV/MP3/FLAC files (case-insensitive extensions) by cosine similarity and emit a JSON array of {path, score}, highest first, with deterministic path tie-breaking.
  • Support -k/--top-k (default 10), -t/--threads, and --device; load the model once and retain only the best k scores rather than corpus embeddings.
  • Skip undecodable candidates with stderr warnings; reject empty/unsearchable directories and propagate model/inference failures. Do not follow directory symlinks.

Usage

clap search ./audio -m model.gguf --text "a dog barking" --top-k 5
clap search ./audio -m model.gguf --audio query.wav --top-k 5

Text search requires a model with text/audio embeddings in a shared space. Audio-only models can be used with --audio. Each invocation scans and encodes the directory; no persistent index or embedding cache is introduced. README is unchanged.

Verification

  • Removed the newly added search CLI test and its CTest registration at user request; existing tests are unchanged.
  • Rebuilt the Linux static configuration after removal: 35/35 existing CTest tests passed.
  • The search implementation is unchanged from the previously reviewed commit, whose cross-platform CI passed. CI for the new head is tracked separately.
  • git diff --check passes.

@zhenghaoz
zhenghaoz merged commit a5749db into main Nov 9, 2026
9 checks passed
@zhenghaoz
zhenghaoz deleted the feat/search-audio branch November 9, 2026 11:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants