simonweniger commited on
Commit
eb23192
·
verified ·
1 Parent(s): c5dd26f

Add model card

Browse files
Files changed (1) hide show
  1. README.md +89 -0
README.md ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: other
3
+ license_name: funasr-model-license
4
+ license_link: https://github.com/modelscope/FunASR/blob/main/MODEL_LICENSE
5
+ base_model: emotion2vec/emotion2vec_plus_base
6
+ library_name: coreml
7
+ pipeline_tag: audio-classification
8
+ tags:
9
+ - emotion-recognition
10
+ - speech-emotion-recognition
11
+ - emotion2vec
12
+ - coreml
13
+ - ios
14
+ - macos
15
+ ---
16
+
17
+ # emotion2vec+ base for Core ML
18
+
19
+ [emotion2vec+ base](https://huggingface.co/emotion2vec/emotion2vec_plus_base) by
20
+ Ziyang Ma et al. ([emotion2vec](https://github.com/ddlBoJack/emotion2vec)),
21
+ converted to Core ML for on-device speech emotion recognition on iOS 18+ and
22
+ macOS 15+.
23
+
24
+ It hears a voice and gives a probability for each of nine classes: angry,
25
+ disgusted, fearful, happy, neutral, other, sad, surprised, unknown. A 3 s clip
26
+ takes about 25 ms on an Apple-silicon GPU.
27
+
28
+ ## Files
29
+
30
+ | Folder | Weights | Size | Compared with the PyTorch original |
31
+ |---|---|---|---|
32
+ | `Emotion2Vec8bit.mlmodelc` | 8-bit, per channel | 89 MB | same top label on every test clip; probabilities within ~0.05 on quiet audio |
33
+ | `Emotion2Vec.mlmodelc` | 16-bit, 32-bit feature extractor | 186 MB | probabilities within 0.013 |
34
+
35
+ Both are compiled Core ML ML Programs, ready for `MLModel(contentsOf:)`.
36
+
37
+ ## Input and output
38
+
39
+ - **`audio`** (input): Float32 `[1, N]`, 16 kHz mono samples in [-1, 1], with N
40
+ from 8,000 to 160,000 (0.5–10 s). Pass audio at its true length and don't
41
+ pad it: the model has no padding mask, so added silence changes the result.
42
+ Split longer audio into chunks of 10 s or less.
43
+ - **`probs`** (output): Float32 `[1, 9]`, softmax probabilities in the order
44
+ angry, disgusted, fearful, happy, neutral, other, sad, surprised, unknown.
45
+ - **`logits`** (output): the same scores before the softmax.
46
+
47
+ The waveform normalisation, frame averaging and classification head are part of
48
+ the model, so plain 16 kHz samples are all it needs.
49
+
50
+ Run it on CPU and GPU (`.cpuAndGPU`). The Neural Engine is no faster for this
51
+ model, and loading it there costs a one-time compile of about 20 s.
52
+
53
+ Silence isn't neutral to this model: pure silence comes back as "surprised".
54
+ Skip quiet windows (below about −42 dBFS) instead of classifying them.
55
+
56
+ ## Use from Swift
57
+
58
+ Emotion2VecKit, our Swift package for these files (to be published), downloads
59
+ them, checks each against its SHA-256, and wraps the model:
60
+
61
+ ```swift
62
+ let model = try await Emotion2Vec.load()
63
+ let result = try await model.classify(fileAt: url)
64
+ print(result.top, result.confidence) // happy 0.82
65
+ ```
66
+
67
+ It also resamples any audio format, handles long recordings, and has a live
68
+ stream for microphone input.
69
+
70
+ ## Conversion
71
+
72
+ Converted from the original checkpoint with coremltools 9.0 and torch 2.7.0,
73
+ then checked against FunASR's own output on speech, quiet speech, silence,
74
+ noise and very short clips.
75
+
76
+ ## Licence and credit
77
+
78
+ These weights are a conversion of emotion2vec+ base and keep its licence, the
79
+ [FunASR Model Open Source License Agreement](https://github.com/modelscope/FunASR/blob/main/MODEL_LICENSE).
80
+ Please credit the original work:
81
+
82
+ ```bibtex
83
+ @article{ma2023emotion2vec,
84
+ title={emotion2vec: Self-Supervised Pre-Training for Speech Emotion Representation},
85
+ author={Ma, Ziyang and Zheng, Zhisheng and Ye, Jiaxin and Li, Jinchao and Gao, Zhifu and Zhang, Shiliang and Chen, Xie},
86
+ journal={arXiv preprint arXiv:2312.15185},
87
+ year={2023}
88
+ }
89
+ ```