Audio Classification
Transformers
English
audio
audio-captioning
audio-tagging
audioset
whisper
speech-captioning
music-captioning
sound-effect-captioning
laion
ast
audio-spectrogram-transformer
Instructions to use laion/whisper-captioning-ensemble with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use laion/whisper-captioning-ensemble with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("audio-classification", model="laion/whisper-captioning-ensemble")# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("laion/whisper-captioning-ensemble", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Upload download_models.py with huggingface_hub
Browse files- download_models.py +98 -0
download_models.py
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Download all model assets needed by the whisper-ensemble pipeline.
|
| 2 |
+
|
| 3 |
+
Run once before using ``pipeline.py``::
|
| 4 |
+
|
| 5 |
+
python download_models.py
|
| 6 |
+
|
| 7 |
+
This will populate the local ``./models`` directory with:
|
| 8 |
+
|
| 9 |
+
* ``models/ast-finetuned-audioset/`` (MIT AST router, BSD-3)
|
| 10 |
+
* ``models/sound-effect-captioning-whisper/`` (laion HF repo snapshot)
|
| 11 |
+
* ``models/music-whisper/`` (laion HF repo snapshot)
|
| 12 |
+
* ``models/voice-tagging-whisper/`` (laion HF repo snapshot)
|
| 13 |
+
* ``models/BUD-E-Whisper_V1.2/`` (laion HF repo snapshot)
|
| 14 |
+
* ``models/whisper-small-processor/`` (openai/whisper-small processor only)
|
| 15 |
+
|
| 16 |
+
The total download is ~5.8 GB. Subsequent runs are no-ops (they skip
|
| 17 |
+
repos that are already mirrored on disk).
|
| 18 |
+
"""
|
| 19 |
+
|
| 20 |
+
from __future__ import annotations
|
| 21 |
+
|
| 22 |
+
import os
|
| 23 |
+
import sys
|
| 24 |
+
from pathlib import Path
|
| 25 |
+
|
| 26 |
+
ROOT = Path(__file__).resolve().parent
|
| 27 |
+
MODELS_DIR = ROOT / "models"
|
| 28 |
+
MODELS_DIR.mkdir(parents=True, exist_ok=True)
|
| 29 |
+
|
| 30 |
+
# ----------------------------------------------------------------------
|
| 31 |
+
# Hugging Face repos to mirror locally
|
| 32 |
+
# ----------------------------------------------------------------------
|
| 33 |
+
HF_REPOS = {
|
| 34 |
+
# AudioSet router: Audio Spectrogram Transformer fine-tuned on AS-2M
|
| 35 |
+
# (BSD-3-clause, ~0.459 mAP). The model config ships id2label for all
|
| 36 |
+
# 527 AudioSet classes, so no extra label CSV is needed.
|
| 37 |
+
"ast-finetuned-audioset": "MIT/ast-finetuned-audioset-10-10-0.4593",
|
| 38 |
+
# Routed Whisper-Small captioners
|
| 39 |
+
"sound-effect-captioning-whisper": "laion/sound-effect-captioning-whisper",
|
| 40 |
+
"music-whisper": "laion/music-whisper",
|
| 41 |
+
"voice-tagging-whisper": "laion/voice-tagging-whisper",
|
| 42 |
+
"BUD-E-Whisper_V1.2": "laion/BUD-E-Whisper_V1.2",
|
| 43 |
+
# Whisper-Small processor (feature extractor + tokenizer fallback,
|
| 44 |
+
# used by sound-effect / voice-tagging which don't ship one).
|
| 45 |
+
"whisper-small-processor": "openai/whisper-small",
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
def download_hf_repos() -> None:
|
| 50 |
+
"""Snapshot all Hugging Face repos used by the pipeline locally."""
|
| 51 |
+
try:
|
| 52 |
+
from huggingface_hub import snapshot_download
|
| 53 |
+
except ImportError as e:
|
| 54 |
+
raise SystemExit(
|
| 55 |
+
"huggingface_hub is required. Install with:\n"
|
| 56 |
+
" pip install -r requirements.txt"
|
| 57 |
+
) from e
|
| 58 |
+
|
| 59 |
+
for local_name, repo_id in HF_REPOS.items():
|
| 60 |
+
local_dir = MODELS_DIR / local_name
|
| 61 |
+
if (local_dir / "config.json").exists():
|
| 62 |
+
print(f"[skip] {repo_id} already mirrored at {local_dir}")
|
| 63 |
+
continue
|
| 64 |
+
print(f"[hf] {repo_id} -> {local_dir}")
|
| 65 |
+
snapshot_download(
|
| 66 |
+
repo_id=repo_id,
|
| 67 |
+
local_dir=str(local_dir),
|
| 68 |
+
local_dir_use_symlinks=False,
|
| 69 |
+
allow_patterns=[
|
| 70 |
+
"*.json",
|
| 71 |
+
"*.txt",
|
| 72 |
+
"*.safetensors",
|
| 73 |
+
"*.bin",
|
| 74 |
+
"*.model",
|
| 75 |
+
"*.tiktoken",
|
| 76 |
+
"tokenizer*",
|
| 77 |
+
"vocab*",
|
| 78 |
+
"merges*",
|
| 79 |
+
"preprocessor*",
|
| 80 |
+
"generation_config*",
|
| 81 |
+
"special_tokens*",
|
| 82 |
+
"added_tokens*",
|
| 83 |
+
"normalizer*",
|
| 84 |
+
],
|
| 85 |
+
)
|
| 86 |
+
|
| 87 |
+
|
| 88 |
+
def main() -> None:
|
| 89 |
+
print("=" * 72)
|
| 90 |
+
print("whisper-ensemble: downloading model assets")
|
| 91 |
+
print("=" * 72)
|
| 92 |
+
download_hf_repos()
|
| 93 |
+
print("\nAll downloads complete.")
|
| 94 |
+
print(f"Models directory: {MODELS_DIR}")
|
| 95 |
+
|
| 96 |
+
|
| 97 |
+
if __name__ == "__main__":
|
| 98 |
+
main()
|