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
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
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:
import librosa
audio, _ = librosa.load("clip.mp3", sr=16000, mono=True)
- Downloads last month
- -