Karachay-Shazam ResNet-18
Caucasian music recognition by sound
2 min readupdated
A new specialized AI model has been trained from scratch to find Karachay-Balkarian folk and pop music in noisy recordings. The model creates compact vector embeddings (vector representations of data) of audio fragments using the SimCLR method (unsupervised contrastive learning). The system then matches the audio against a track database via FAISS vector search (a library for fast nearest neighbor search). The solution is optimized for low-end servers and mobile devices.
Key features
- ResNet-18 architecture (a convolutional neural network for processing spectrograms)
- NT-Xent contrastive learning method for noise robustness
- Lightweight ONNX format with a size of about 44 MB
- CPU execution with minimal memory requirements
What you can do
- Build a Telegram bot for finding tracks from stories and videos
- Integrate music recognition into a local mobile app
- Index custom audio archives and recordings from weddings and events
Example
import numpy as np
import librosa
import onnxruntime as ort
import faiss
import pandas as pd
session = ort.InferenceSession("karachay_shazam.onnx", providers=["CPUExecutionProvider"])
index = faiss.read_index("songs_index.faiss")
db = pd.read_csv("songs_db.csv")
wav, _ = librosa.load("sample.wav", sr=16000, mono=True, duration=3.0)
mel = librosa.feature.melspectrogram(y=wav, sr=16000, n_fft=1024, hop_length=256, n_mels=64)
log_mel = np.log(mel + 1e-6).astype(np.float32)
spec = log_mel[np.newaxis, np.newaxis, :, :188]
emb = session.run(["emb"], {"spec": spec})[0]
D, I = index.search(emb, k=1)
match = db.iloc[int(I[0][0])]
print(f"Найдено: {match['artist']} - {match['title']}")Read more
Details• Sample rate: 16,000 Hz (Mono)
• Input tensor: (Batch, 1, 64, 188) Log-Mel spectrogram
• Includes a ready-to-use FAISS index and metadata table
• Requirements: 1 GB of RAM or more, runs on CPU










Comments