Views
No views yet
| Head | Type | Output | Description |
|---|---|---|---|
| Categorical | Softmax | logits → (7) | Neutral, Happy, Sad, Angry, Surprised, Fearful, Disgusted |
| Dimensional | Sigmoid | dims → (3) | Valence [V], Arousal [A], Dominance [D] in [0, 1] |


1from transformers import AutoProcessor, AutoModelForAudioClassification
2import torch, torchaudio
3
4repo = "MERaLiON/MERaLiON-SER-v1"
5device = "cuda" if torch.cuda.is_available() else "cpu"
6
7processor = AutoProcessor.from_pretrained(repo)
8model = AutoModelForAudioClassification.from_pretrained(repo, trust_remote_code=True).to(device)
9model.eval()
10
11# ------- Single wav exmple --------------
12wav, sr = torchaudio.load("sample.wav")
13if wav.shape[0] > 1: wav = wav.mean(dim=0, keepdim=True)
14wav = torchaudio.transforms.Resample(sr, 16000)(wav)
15
16inputs = processor(wav.squeeze().numpy(), sampling_rate=16000, return_tensors="pt", return_attention_mask=True)
17with torch.inference_mode():
18 out = model(**{k:v.to(device) for k,v in inputs.items() if k in ("input_features","attention_mask")})
19logits, dims = out["logits"], out["dims"]
20
21emo_idx = torch.argmax(logits, dim=1).item()
22emo_map = ["Neutral","Happy","Sad","Angry","Fearful","Disgusted","Surprised"]
23print("Predicted Emotion:", emo_map[emo_idx])
24print("Valance/Arousal/Dominance:", dims.squeeze().tolist())
25
26# -------- Batch inference example using above loaded wav file--------
27wav = wav.squeeze().numpy() # tensor of size (41642,) --> (samples,)
28wavs = [wav,wav,wav] # example list of wav (tensor) for batch, here batch size =3
29
30batch_inputs = processor(
31 wavs, # list of 1D numpy arrays
32 sampling_rate=16000,
33 return_tensors="pt",
34 padding="max_length",
35 return_attention_mask=True,
36)
37with torch.inference_mode():
38 out = model(**{k: v.to(device) for k, v in batch_inputs.items() if k in ("input_features","attention_mask")})
39
40logits, dims = out["logits"], out["dims"] # logits: (B, 7), dims: (B, 3) where B is batch size
41emo_ids = torch.argmax(logits, dim=1).tolist()
42
43for i in range(len(wavs)):
44 eid = emo_ids[i]
45 vad = dims.tolist()[i]
46 print(f"Batch Index {i} -> {emo_map[eid]} | VAD={vad}")1from transformers import AutoProcessor, AutoModelForAudioClassification
2import torch, soundfile as sf, torchaudio
3
4repo = "MERaLiON/MERaLiON-SER-v1"
5processor = AutoProcessor.from_pretrained(repo)
6model = AutoModelForAudioClassification.from_pretrained(repo, trust_remote_code=True).cpu().eval()
7
8wav, sr = sf.read("sample.wav")
9if wav.ndim > 1: wav = wav.mean(axis=1)
10if sr != 16000:
11 wav = torchaudio.functional.resample(torch.tensor(wav).unsqueeze(0), sr, 16000).squeeze(0).numpy()
12
13inputs = processor(wav, sampling_rate=16000, return_tensors="pt")
14with torch.inference_mode():
15 out = model(**inputs)
16logits, dims = out["logits"], out["dims"]
17emo_idx = torch.argmax(logits, dim=1).item()
18emo_map = ["Neutral","Happy","Sad","Angry","Fearful","Disgusted","Surprised"]
19print("Predicted Emotion:", emo_map[emo_idx])
20print("Valance/Arousal/Dominance:", dims.squeeze().tolist())1@article{serv1,
2 title={MERaLiON-SER: Robust Speech Emotion Recognition Model for English and SEA Languages},
3 author={MERaLiON Team}, journal={http://arxiv.org/abs/2511.04914},
4 year={2025}
5}
6@inproceedings{wang2025benchmarking,
7 title={Benchmarking Contextual and Paralinguistic Reasoning in Speech-LLMs: A Case Study with In-the-Wild Data},
8 author={Wang, Qiongqiong and Sailor, Hardik Bhupendra and Liu, Tianchi and Zhang, Wenyu and Huzaifah, Muhammad and Lertcheva, Nattadaporn and Sun, Shuo and Chen, Nancy F and Wu, Jinyang and Aw, AiTi},
9 booktitle={Findings of EMNLP 2025},
10 year={2025}
11}
12@inproceedings{cpqa_interspeech,
13 title={Contextual Paralinguistic Data Creation for Multi-Modal Speech-LLM: Data Condensation and Spoken {QA} Generation},
14 author={Wang, Qiongqiong and Sailor, Hardik B and Liu, Tianchi and Aw, Ai Ti},
15 booktitle={Proc. Interspeech},
16 year={2025},
17}
18
19@inproceedings{cpqa_asru,
20 title={Incorporating Contextual Paralinguistic
21Understanding in Large Speech-Language Models},
22 author={
23 Wang, Qiongqiong and Sailor, Hardik B and Wong, Jeremy H. M. and Liu, Tianchi and Sun, Shuo and Zhang, Wenyu and Huzaifah, Muhammad and Chen, Nancy and Aw, Ai Ti},
24 booktitle={Proc. IEEE Automatic Speech Recognition and Understanding Workshop (ASRU)},
25 year={2025},
26}