Upload mbfa-thai (thai_fleurs8h_mt01a_e8_val_loss=2.523.ckpt)
Browse files- README.md +85 -0
- ckpt/thai_fleurs8h_mt01a_e8_val_loss=2.523.ckpt +3 -0
- config.json +172 -0
- model.safetensors +3 -0
README.md
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: agpl-3.0
|
| 3 |
+
library_name: pytorch
|
| 4 |
+
language:
|
| 5 |
+
- th
|
| 6 |
+
datasets:
|
| 7 |
+
- google/fleurs
|
| 8 |
+
tags:
|
| 9 |
+
- forced-alignment
|
| 10 |
+
- phoneme-recognition
|
| 11 |
+
- phoneme-segmentation
|
| 12 |
+
- speech
|
| 13 |
+
- multilingual
|
| 14 |
+
---
|
| 15 |
+
|
| 16 |
+
# mbfa-thai (p4mbfa · thai_khmer)
|
| 17 |
+
|
| 18 |
+
A context-free CNN phoneme encoder and forced aligner (p4mbfa, the successor of CUPE / p3cupe),
|
| 19 |
+
for the **thai_khmer** language group of [standard_g2p](https://github.com/tabahi/CharsiuG2P). Each 5 ms frame is classified
|
| 20 |
+
from at most 120 ms of audio (38.9 ms receptive field), so the model cannot learn any language's
|
| 21 |
+
phonotactics. Phone boundaries come from a segmental Viterbi decoder over the known phone
|
| 22 |
+
sequence, refined to sub-frame precision at the crossing of neighbouring posteriors.
|
| 23 |
+
|
| 24 |
+
| head | labels | size |
|
| 25 |
+
|---|---|---|
|
| 26 |
+
| `ph` | local tokens of `thai_khmer` (incl. `<blank> SIL noise <unk>`) | 38 |
|
| 27 |
+
| `phg` | gold phoneme groups, shared by every language group | 15 |
|
| 28 |
+
| `tone` | tone values, shared by every language group; trained on this group's tone layer | 22 |
|
| 29 |
+
|
| 30 |
+
Languages (the FLEURS languages it was trained on): th. standard_g2p maps every member of the group
|
| 31 |
+
onto the same tokens, so other members may align too, untested.
|
| 32 |
+
|
| 33 |
+
## Training
|
| 34 |
+
|
| 35 |
+
**Data:** FLEURS thai_khmer without Khmer (exclude_langs [km]): Thai only, all 7.8 h, training noise_level 0.02.
|
| 36 |
+
**Checkpoint:** experiment `mt01a`, epoch 8, selected on FLEURS val_loss (best of 20 epochs; final epoch 2.565).
|
| 37 |
+
Trunk and phg_head from latin ma02a (final epoch), ph_head and tone_head trained fresh. Khmer is in the thai_khmer label space but was not trained (standard_g2p folds 19.8% of its tokens to <unk>).
|
| 38 |
+
|
| 39 |
+
| metric | value |
|
| 40 |
+
|---|---|
|
| 41 |
+
| `val_loss` | 2.5226 |
|
| 42 |
+
| `val_frame_acc` | 0.4881 |
|
| 43 |
+
| `val_frame_acc_groups` | 0.5973 |
|
| 44 |
+
| `val_peak_ce_tone` | 0.863 |
|
| 45 |
+
|
| 46 |
+
`val_*` are on held-out FLEURS clips but are scored against the model's own alignments (there are no boundary labels outside English), so they measure self-consistency, not boundary accuracy.
|
| 47 |
+
|
| 48 |
+
Labels are standard_g2p dictionary pronunciations (gold inventory `9438371ed6dd`),
|
| 49 |
+
not phonetic transcriptions of what was said.
|
| 50 |
+
|
| 51 |
+
## Usage
|
| 52 |
+
|
| 53 |
+
The code is in [https://github.com/tabahi/bfa_models](https://github.com/tabahi/bfa_models) (`p4mbfa/`); clone it and run from its root.
|
| 54 |
+
|
| 55 |
+
```python
|
| 56 |
+
from p4mbfa.inference import MbfaAligner
|
| 57 |
+
|
| 58 |
+
aligner = MbfaAligner.from_pretrained("Tabahi/mbfa-thai")
|
| 59 |
+
wav = aligner.load_audio("clip.wav") # mono, 16000 Hz
|
| 60 |
+
phones = ["SIL", "h", "ɛ", "l", "o", "SIL"] # this group's tokens (config.json labels.tokens)
|
| 61 |
+
for seg in aligner.align(wav, phones):
|
| 62 |
+
print(seg["token"], seg["start_ms"], seg["end_ms"])
|
| 63 |
+
```
|
| 64 |
+
|
| 65 |
+
`aligner.encode(wav)` returns the per-frame log posteriors of all three heads.
|
| 66 |
+
Text -> tokens is standard_g2p's job (`goldG2P.phonemize_sentence` then
|
| 67 |
+
`lang_group_inventory.to_local`); `config.json` lists the token strings. `from_pretrained`
|
| 68 |
+
downloads only `config.json` and `model.safetensors`.
|
| 69 |
+
|
| 70 |
+
## Fine-tuning
|
| 71 |
+
|
| 72 |
+
`ckpt/thai_fleurs8h_mt01a_e8_val_loss=2.523.ckpt` is the training checkpoint (PyTorch Lightning, weights only, a pickle: load
|
| 73 |
+
it only if you trust this repo). Download it, then point a p4mbfa yaml at it to continue
|
| 74 |
+
training, or to train a new language group on its trunk and shared `phg` head:
|
| 75 |
+
|
| 76 |
+
```bash
|
| 77 |
+
hf download Tabahi/mbfa-thai "ckpt/thai_fleurs8h_mt01a_e8_val_loss=2.523.ckpt" --local-dir tmp/hf/mbfa-thai
|
| 78 |
+
```
|
| 79 |
+
|
| 80 |
+
```yaml
|
| 81 |
+
ckpt_path: "tmp/hf/mbfa-thai/ckpt/thai_fleurs8h_mt01a_e8_val_loss=2.523.ckpt"
|
| 82 |
+
reset_fine_heads: true # new lang_group: rebuild ph_head / tone_head; false = same group
|
| 83 |
+
```
|
|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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"format": "p4mbfa",
|
| 3 |
+
"format_version": 1,
|
| 4 |
+
"model_config": {
|
| 5 |
+
"input_wav_length": 1920,
|
| 6 |
+
"cnn_channels": 192,
|
| 7 |
+
"embed_dim": 512,
|
| 8 |
+
"context_kernels": [
|
| 9 |
+
5,
|
| 10 |
+
3
|
| 11 |
+
],
|
| 12 |
+
"cnn_dropout": 0.2,
|
| 13 |
+
"head_dropout": 0.3,
|
| 14 |
+
"noise_level": 0.02,
|
| 15 |
+
"frame_blocks": 4,
|
| 16 |
+
"ffn_mult": 4,
|
| 17 |
+
"attn_radius": 0,
|
| 18 |
+
"attn_heads": 8,
|
| 19 |
+
"block_dropout": 0.3,
|
| 20 |
+
"n_phg": 15,
|
| 21 |
+
"lang_group": "thai_khmer",
|
| 22 |
+
"n_tokens": 38,
|
| 23 |
+
"n_tones": 22
|
| 24 |
+
},
|
| 25 |
+
"geometry": {
|
| 26 |
+
"sample_rate": 16000,
|
| 27 |
+
"window_size_ms": 120,
|
| 28 |
+
"window_stride_ms": 80
|
| 29 |
+
},
|
| 30 |
+
"decoder": {
|
| 31 |
+
"min_phone_frames": 6,
|
| 32 |
+
"soft_phone_frames": 10,
|
| 33 |
+
"soft_frame_cost": 1.0,
|
| 34 |
+
"sil_skippable": true,
|
| 35 |
+
"optional_sil": true,
|
| 36 |
+
"class_prior_norm": true,
|
| 37 |
+
"boundary_bonus_weight": 30.0,
|
| 38 |
+
"boundary_contrast_frames": 17,
|
| 39 |
+
"boundary_flux_source": "mel"
|
| 40 |
+
},
|
| 41 |
+
"labels": {
|
| 42 |
+
"lang_group": "thai_khmer",
|
| 43 |
+
"tokens": [
|
| 44 |
+
"<blank>",
|
| 45 |
+
"SIL",
|
| 46 |
+
"noise",
|
| 47 |
+
"<unk>",
|
| 48 |
+
"a",
|
| 49 |
+
"s",
|
| 50 |
+
"i",
|
| 51 |
+
"e",
|
| 52 |
+
"n",
|
| 53 |
+
"t",
|
| 54 |
+
"l",
|
| 55 |
+
"k",
|
| 56 |
+
"o",
|
| 57 |
+
"r",
|
| 58 |
+
"m",
|
| 59 |
+
"d",
|
| 60 |
+
"u",
|
| 61 |
+
"f",
|
| 62 |
+
"j",
|
| 63 |
+
"b",
|
| 64 |
+
"p",
|
| 65 |
+
"ɛ",
|
| 66 |
+
"w",
|
| 67 |
+
"ʔ",
|
| 68 |
+
"ɔ",
|
| 69 |
+
"ŋ",
|
| 70 |
+
"ɯ",
|
| 71 |
+
"h",
|
| 72 |
+
"tʰ",
|
| 73 |
+
"t͡ɕ",
|
| 74 |
+
"kʰ",
|
| 75 |
+
"ɤ",
|
| 76 |
+
"pʰ",
|
| 77 |
+
"k̚",
|
| 78 |
+
"t͡ɕʰ",
|
| 79 |
+
"t̚",
|
| 80 |
+
"p̚",
|
| 81 |
+
"a̯"
|
| 82 |
+
],
|
| 83 |
+
"special_tokens": {
|
| 84 |
+
"<blank>": 0,
|
| 85 |
+
"SIL": 1,
|
| 86 |
+
"noise": 2,
|
| 87 |
+
"<unk>": 3
|
| 88 |
+
},
|
| 89 |
+
"phg_names": [
|
| 90 |
+
"special",
|
| 91 |
+
"vowel_close",
|
| 92 |
+
"vowel_mid",
|
| 93 |
+
"vowel_open",
|
| 94 |
+
"stop_voiceless",
|
| 95 |
+
"stop_voiced",
|
| 96 |
+
"affricate",
|
| 97 |
+
"fricative_vl",
|
| 98 |
+
"fricative_vd",
|
| 99 |
+
"nasal",
|
| 100 |
+
"lateral",
|
| 101 |
+
"rhotic",
|
| 102 |
+
"glide",
|
| 103 |
+
"glottal",
|
| 104 |
+
"other"
|
| 105 |
+
],
|
| 106 |
+
"tone_vocab": [
|
| 107 |
+
"",
|
| 108 |
+
"35",
|
| 109 |
+
"21",
|
| 110 |
+
"33",
|
| 111 |
+
"45",
|
| 112 |
+
"51",
|
| 113 |
+
"32",
|
| 114 |
+
"214",
|
| 115 |
+
"55",
|
| 116 |
+
"24",
|
| 117 |
+
"3",
|
| 118 |
+
"312",
|
| 119 |
+
"5",
|
| 120 |
+
"13",
|
| 121 |
+
"2",
|
| 122 |
+
"212",
|
| 123 |
+
"42",
|
| 124 |
+
"44",
|
| 125 |
+
"53",
|
| 126 |
+
"22",
|
| 127 |
+
"4",
|
| 128 |
+
"114"
|
| 129 |
+
],
|
| 130 |
+
"member_langs": [
|
| 131 |
+
"th",
|
| 132 |
+
"tts"
|
| 133 |
+
],
|
| 134 |
+
"gold_fingerprint": "9438371ed6dd"
|
| 135 |
+
},
|
| 136 |
+
"training": {
|
| 137 |
+
"experiment": "mt01a",
|
| 138 |
+
"note": "first thai_khmer run: trunk + phg_head from latin ma02a, fresh ph_head (38) and tone_head",
|
| 139 |
+
"data_src": "fleurs",
|
| 140 |
+
"train_limit": null,
|
| 141 |
+
"val_limit": null,
|
| 142 |
+
"exclude_langs": [
|
| 143 |
+
"km"
|
| 144 |
+
],
|
| 145 |
+
"duration_max": 20,
|
| 146 |
+
"ckpt_path": "tmp/training/p4mbfa/ma02a/m_ma02a_final_e30.pt",
|
| 147 |
+
"trunk_init_path": null,
|
| 148 |
+
"reset_fine_heads": true,
|
| 149 |
+
"ramp_frames": 1.0,
|
| 150 |
+
"soft_onset_mix": 1.0,
|
| 151 |
+
"noise_level": 0.02,
|
| 152 |
+
"lr": "1e-4",
|
| 153 |
+
"epochs": 20,
|
| 154 |
+
"epoch": 8,
|
| 155 |
+
"global_step": 504,
|
| 156 |
+
"source_checkpoint": "m_mt01a_epoch=8_step=504_val_loss=2.5226.ckpt",
|
| 157 |
+
"selection": {
|
| 158 |
+
"trained_langs": [
|
| 159 |
+
"th"
|
| 160 |
+
],
|
| 161 |
+
"train_data": "FLEURS thai_khmer without Khmer (exclude_langs [km]): Thai only, all 7.8 h, training noise_level 0.02",
|
| 162 |
+
"selected_on": "FLEURS val_loss (best of 20 epochs; final epoch 2.565)",
|
| 163 |
+
"metrics": {
|
| 164 |
+
"val_loss": 2.5226,
|
| 165 |
+
"val_frame_acc": 0.4881,
|
| 166 |
+
"val_frame_acc_groups": 0.5973,
|
| 167 |
+
"val_peak_ce_tone": 0.863
|
| 168 |
+
},
|
| 169 |
+
"note": "Trunk and phg_head from latin ma02a (final epoch), ph_head and tone_head trained fresh. Khmer is in the thai_khmer label space but was not trained (standard_g2p folds 19.8% of its tokens to <unk>)."
|
| 170 |
+
}
|
| 171 |
+
}
|
| 172 |
+
}
|
model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:1bc1177caea282961073310368a4cad50ef07da70eb5b019f7d0d6b7ae75750e
|
| 3 |
+
size 58810452
|