Views
No views yet
anger, disgust, enthusiasm, fear, happiness, neutral, sadness.jonatasgrosman/wav2vec2-large-xlsr-53-russian (WavLM/wav2vec2 fine-tuned for Russian ASR) paired with the text encoder cointegrated/rubert-tiny2; the model reads the waveform and a transcript together. Trained on Aniemore/resd.wav2vec2-bert-tiny2-s-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.7217 | 0.7286 | 0.7228 |
| Dusha podcast test | 12079 | 0.2594 | 0.2267 | 0.1361 |
| CAMEO test | 5187 | 0.2723 | 0.3108 | 0.2589 |
| RESD test, transcript blanked | 280 | 0.5515 | 0.5607 | 0.5064 |
1import torch, librosa
2from transformers import AutoConfig, AutoTokenizer, AutoModel
3
4repo = "Aniemore/wav2vec2-bert-tiny2-s-emotion-russian-resd"
5cfg = AutoConfig.from_pretrained(repo, trust_remote_code=True)
6model = AutoModel.from_pretrained(repo, trust_remote_code=True).eval()
7tok = AutoTokenizer.from_pretrained(repo)
8
9# Resample to 16 kHz. RESD ships at 44.1 kHz, and 44.1 kHz audio
10# labelled as 16 kHz is stretched 2.8x in time — the model answers,
11# it just answers about other audio.
12wav, _ = librosa.load("clip.wav", sr=16000, mono=True)
13wav = torch.tensor((wav - wav.mean()) / (wav.std() + 1e-7))[None]
14t = tok("расшифровка реплики", return_tensors="pt")
15with torch.no_grad():
16 logits = model(input_ids=t['input_ids'], input_values=wav,
17 text_attention_mask=t['attention_mask'],
18 audio_attention_mask=torch.ones_like(wav).long()).logits
19
20probs = logits.softmax(-1)[0]
21print({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}