Audio Classification
Transformers
Safetensors
smad_crnn
feature-extraction
audio
music
speech
custom-code
custom_code
Instructions to use duclvQ/smad with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use duclvQ/smad with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("audio-classification", model="duclvQ/smad", trust_remote_code=True)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("duclvQ/smad", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
File size: 1,317 Bytes
64ef8a3 b472389 64ef8a3 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | ---
library_name: transformers
pipeline_tag: audio-classification
tags:
- audio
- music
- speech
- custom-code
license: mit
---
# SMAD CRNN
SMAD is an audio classification model for identifying speech, music, singing,
and non-vocal content in short audio segments. It is designed for lightweight
audio analysis workflows where fast, practical content categorization is
needed.
## Load by model id
```python
import torch
from transformers import AutoFeatureExtractor, AutoModelForAudioClassification
model_id = "duclvQ/smad"
feature_extractor = AutoFeatureExtractor.from_pretrained(
model_id,
trust_remote_code=True,
)
model = AutoModelForAudioClassification.from_pretrained(
model_id,
trust_remote_code=True,
).eval()
# `audio` must be mono float32 audio sampled at 16 kHz. For longer files, run
# this over 4-second windows.
inputs = feature_extractor(audio, sampling_rate=16000, return_tensors="pt")
with torch.no_grad():
logits = model(**inputs).logits
probs = torch.softmax(logits / model.config.temperature, dim=-1)
label_id = int(probs.argmax(-1)[0])
label = model.config.id2label[label_id]
confidence = float(probs[0, label_id])
```
For arbitrary file paths, load/resample with `librosa`:
```python
import librosa
audio, _ = librosa.load("clip.mp3", sr=16000, mono=True)
```
|