README.md (2732B)
1 # Janitor 2 3 An audio classification tool that labels audio files into three categories: **speech**, **music**, and **noise**. 4 5 ## Overview 6 7 Janitor uses the [Audio Spectrogram Transformer (AST)](https://github.com/YuanGongND/ast) model pretrained on AudioSet to classify audio content. It consists of two components: 8 9 - **Service**: A GPU-accelerated inference server that runs the AST model with batched processing 10 - **CLI**: A client that extracts mel-filterbank features from audio files and sends them to the service for classification 11 12 ## Architecture 13 14 ``` 15 ┌─────────────────┐ safetensors ┌─────────────────┐ 16 │ CLI Client │ ─────────────────► │ Inference │ 17 │ │ │ Service │ 18 │ - Audio decode │ HTTP POST │ │ 19 │ - Resample │ ◄───────────────── │ - AST Model │ 20 │ - Fbank extract│ JSON label │ - Batching │ 21 └─────────────────┘ └─────────────────┘ 22 ``` 23 24 ## Features 25 26 - Classify individual files or entire directories recursively 27 - Copy or move files to separate directories based on classification 28 - Concurrent file processing with configurable parallelism 29 - GPU acceleration with CUDA support 30 - Batched inference for improved throughput 31 32 ## Quick Start 33 34 ### 1. Build and run the service 35 36 ```bash 37 cd service 38 39 # Build the model (requires conda) 40 ./build_model.sh 41 42 # Run on CPU 43 cargo build --release 44 45 # Or with CUDA support 46 TORCH_CUDA_VERSION=cu121 cargo build --release 47 48 # Start the service 49 cargo run --release 50 ``` 51 52 ### 2. Run the CLI 53 54 ```bash 55 cd cli 56 cargo build --release 57 58 # Classify a single file 59 cargo run --release -- audio.mp3 60 61 # Classify a directory 62 cargo run --release -- /path/to/audio/ 63 64 # Move files to separate directories by label 65 cargo run --release -- move /path/to/audio/ \ 66 --speech-dir ./speech \ 67 --music-dir ./music \ 68 --noise-dir ./noise 69 ``` 70 71 ## Components 72 73 | Component | Description | 74 | ------------ | ----------------------------------------------------------- | 75 | `cli/` | Command-line client for audio processing and classification | 76 | `service/` | Inference server running the AST model | 77 | `cli/fbank/` | Rust bindings to kaldi-native-fbank for feature extraction | 78 79 ## Requirements 80 81 - Rust 1.70+ 82 - Conda (for building the model) 83 - CUDA 11.8 or 12.1 (optional, for GPU acceleration) 84 85 ## License 86 87 [GPL-3.0](LICENSE)