Views
No views yet
anger, disgust, enthusiasm, fear, happiness, neutral, sadness.jonatasgrosman/wav2vec2-large-xlsr-53-russian on Aniemore/resd.wav2vec2-emotion-russian-resd-quantized — INT8, FP8 and INT4, up to 5.8x smaller on disk at the same score| Test set | n | UA | WA | macro-F1 |
|---|---|---|---|---|
| RESD test | 280 | 0.7088 | 0.7107 | 0.7079 |
| Dusha podcast test | 12079 | 0.3759 | 0.1721 | 0.1260 |
| CAMEO test | 5187 | 0.2544 | 0.2707 | 0.2446 |
1import torch, librosa
2from transformers import AutoModelForAudioClassification, AutoFeatureExtractor
3
4repo = "Aniemore/wav2vec2-emotion-russian-resd"
5model = AutoModelForAudioClassification.from_pretrained(repo).eval()
6fe = AutoFeatureExtractor.from_pretrained(repo)
7
8# Resample to 16 kHz. RESD ships at 44.1 kHz, and 44.1 kHz audio
9# labelled as 16 kHz is stretched 2.8x in time — the model answers,
10# it just answers about other audio.
11wav, _ = librosa.load("clip.wav", sr=16000, mono=True)
12x = fe(wav, sampling_rate=16000, return_tensors="pt", padding=True)
13with torch.no_grad():
14 logits = model(**x).logits
15
16probs = logits.softmax(-1)[0]
17print({model.config.id2label[i]: round(p.item(), 3) for i, p in enumerate(probs)})1# torchaudio
2import torchaudio
3wav, sr = torchaudio.load("clip.wav")
4wav = torchaudio.functional.resample(wav, sr, 16000).mean(0).numpy()
5
6# torchcodec, the newer decoder
7from torchcodec.decoders import AudioDecoder
8wav = AudioDecoder("clip.wav", sample_rate=16000).get_all_samples().data.mean(0).numpy()
9
10# straight from the dataset — `datasets` resamples on the column, so
11# the mixed 16/44.1 kHz in RESD is handled for you
12from datasets import load_dataset, Audio
13ds = load_dataset("Aniemore/resd", split="test")
14ds = ds.cast_column("speech", Audio(sampling_rate=16000))
15wav = ds[0]["speech"]["array"]1@misc{aniemore,
2 author = {Lubenets, Ilya and Davidchuk, Nikita and Amentes, Aleksandr},
3 title = {Aniemore: an open library for emotion recognition in Russian speech},
4 url = {https://github.com/Aniemore/Aniemore},
5 year = {2023}
6}