Inference via the xmdd package; drop unused tokens.txt
Browse files- README.md +14 -12
- config.yaml +0 -1
- tokens.txt +0 -188
README.md
CHANGED
|
@@ -38,31 +38,33 @@ the learner actually produced. Aligning it to the canonical phones gives detecti
|
|
| 38 |
|
| 39 |
| File | Content |
|
| 40 |
|---|---|
|
| 41 |
-
| `model.safetensors` | Weights (bf16; keys `asr.*` = Qwen3-ASR
|
| 42 |
| `config.yaml` | Inference config (prompt layout, language prefixes, model settings) |
|
| 43 |
| `processor/` | Qwen3-ASR processor and tokenizer, including the added prompt boundary tokens |
|
| 44 |
| `phone_vocabulary.txt` | The 242-phone training vocabulary (zh tonal phones + CMU 39 phones), in index order |
|
| 45 |
-
| `tokens.txt` | Base phone token table |
|
| 46 |
| `arabic_phone_symbols.txt` | Phone symbols used for constrained decoding on Arabic (QuranMB) |
|
| 47 |
|
| 48 |
## Usage
|
| 49 |
|
| 50 |
-
|
| 51 |
-
which reads this folder directly. The base `Qwen/Qwen3-ASR-1.7B-hf` is downloaded for the architecture
|
| 52 |
-
and then overwritten by these weights.
|
| 53 |
|
| 54 |
```bash
|
| 55 |
hf download walston/X-MDD --local-dir pretrained/X-MDD
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
--config $M/config.yaml --checkpoint $M/model.safetensors \
|
| 59 |
-
--languages en --split test --manifest my_en_test.jsonl \
|
| 60 |
-
--shots 4 --demo-source test --skip-loss \
|
| 61 |
--output results/en.json --predictions results/en.pred.jsonl
|
| 62 |
```
|
| 63 |
|
| 64 |
-
|
| 65 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
|
| 67 |
Input manifest rows (JSONL) look like:
|
| 68 |
|
|
|
|
| 38 |
|
| 39 |
| File | Content |
|
| 40 |
|---|---|
|
| 41 |
+
| `model.safetensors` | Weights (bf16; keys `asr.*` = Qwen3-ASR; `ctc_head.*` = an unused CTC head, ignored at inference) |
|
| 42 |
| `config.yaml` | Inference config (prompt layout, language prefixes, model settings) |
|
| 43 |
| `processor/` | Qwen3-ASR processor and tokenizer, including the added prompt boundary tokens |
|
| 44 |
| `phone_vocabulary.txt` | The 242-phone training vocabulary (zh tonal phones + CMU 39 phones), in index order |
|
|
|
|
| 45 |
| `arabic_phone_symbols.txt` | Phone symbols used for constrained decoding on Arabic (QuranMB) |
|
| 46 |
|
| 47 |
## Usage
|
| 48 |
|
| 49 |
+
Install the [X-MDD code](https://github.com/oshindow/whisper_pinyin) (`xmdd` package), then:
|
|
|
|
|
|
|
| 50 |
|
| 51 |
```bash
|
| 52 |
hf download walston/X-MDD --local-dir pretrained/X-MDD
|
| 53 |
+
python -m xmdd.infer --model-dir pretrained/X-MDD --language en \
|
| 54 |
+
--manifest my_en_test.jsonl --shots 4 \
|
|
|
|
|
|
|
|
|
|
| 55 |
--output results/en.json --predictions results/en.pred.jsonl
|
| 56 |
```
|
| 57 |
|
| 58 |
+
```python
|
| 59 |
+
from xmdd import XMDD, load_manifest, select_demos
|
| 60 |
+
model = XMDD.from_pretrained("pretrained/X-MDD")
|
| 61 |
+
queries = load_manifest("my_en_test.jsonl", "en", model.cfg)
|
| 62 |
+
print(model.predict(queries[0], select_demos(queries[0], queries, shots=4)))
|
| 63 |
+
```
|
| 64 |
+
|
| 65 |
+
For Arabic or another unseen language add `--raw-phones --constrain-phones <phones.txt>` (and
|
| 66 |
+
`--language-name` for a language other than zh/en/ar). The base `Qwen/Qwen3-ASR-1.7B-hf` is downloaded for
|
| 67 |
+
the architecture and then overwritten by these weights.
|
| 68 |
|
| 69 |
Input manifest rows (JSONL) look like:
|
| 70 |
|
config.yaml
CHANGED
|
@@ -25,7 +25,6 @@ data:
|
|
| 25 |
audio_field: l2_wav
|
| 26 |
actual_phone_field: actual_phones
|
| 27 |
canonical_phone_field: canonical_phones
|
| 28 |
-
token_table_path: tokens.txt
|
| 29 |
sample_rate: 16000
|
| 30 |
remove_phones:
|
| 31 |
- sil
|
|
|
|
| 25 |
audio_field: l2_wav
|
| 26 |
actual_phone_field: actual_phones
|
| 27 |
canonical_phone_field: canonical_phones
|
|
|
|
| 28 |
sample_rate: 16000
|
| 29 |
remove_phones:
|
| 30 |
- sil
|
tokens.txt
DELETED
|
@@ -1,188 +0,0 @@
|
|
| 1 |
-
<blk> 0
|
| 2 |
-
<sos/eos> 1
|
| 3 |
-
<unk> 2
|
| 4 |
-
a1 3
|
| 5 |
-
a2 4
|
| 6 |
-
a3 5
|
| 7 |
-
a4 6
|
| 8 |
-
a5 7
|
| 9 |
-
aa 8
|
| 10 |
-
ai1 9
|
| 11 |
-
ai2 10
|
| 12 |
-
ai3 11
|
| 13 |
-
ai4 12
|
| 14 |
-
ai5 13
|
| 15 |
-
an1 14
|
| 16 |
-
an2 15
|
| 17 |
-
an3 16
|
| 18 |
-
an4 17
|
| 19 |
-
ang1 18
|
| 20 |
-
ang2 19
|
| 21 |
-
ang3 20
|
| 22 |
-
ang4 21
|
| 23 |
-
ao1 22
|
| 24 |
-
ao2 23
|
| 25 |
-
ao3 24
|
| 26 |
-
ao4 25
|
| 27 |
-
b 26
|
| 28 |
-
c 27
|
| 29 |
-
ch 28
|
| 30 |
-
d 29
|
| 31 |
-
e1 30
|
| 32 |
-
e2 31
|
| 33 |
-
e3 32
|
| 34 |
-
e4 33
|
| 35 |
-
e5 34
|
| 36 |
-
ee 35
|
| 37 |
-
ei1 36
|
| 38 |
-
ei2 37
|
| 39 |
-
ei3 38
|
| 40 |
-
ei4 39
|
| 41 |
-
ei5 40
|
| 42 |
-
en1 41
|
| 43 |
-
en2 42
|
| 44 |
-
en3 43
|
| 45 |
-
en4 44
|
| 46 |
-
en5 45
|
| 47 |
-
eng1 46
|
| 48 |
-
eng2 47
|
| 49 |
-
eng3 48
|
| 50 |
-
eng4 49
|
| 51 |
-
er2 50
|
| 52 |
-
er3 51
|
| 53 |
-
er4 52
|
| 54 |
-
er5 53
|
| 55 |
-
f 54
|
| 56 |
-
g 55
|
| 57 |
-
h 56
|
| 58 |
-
i1 57
|
| 59 |
-
i2 58
|
| 60 |
-
i3 59
|
| 61 |
-
i4 60
|
| 62 |
-
i5 61
|
| 63 |
-
ia1 62
|
| 64 |
-
ia2 63
|
| 65 |
-
ia3 64
|
| 66 |
-
ia4 65
|
| 67 |
-
ia5 66
|
| 68 |
-
ian1 67
|
| 69 |
-
ian2 68
|
| 70 |
-
ian3 69
|
| 71 |
-
ian4 70
|
| 72 |
-
ian5 71
|
| 73 |
-
iang1 72
|
| 74 |
-
iang2 73
|
| 75 |
-
iang3 74
|
| 76 |
-
iang4 75
|
| 77 |
-
iang5 76
|
| 78 |
-
iao1 77
|
| 79 |
-
iao2 78
|
| 80 |
-
iao3 79
|
| 81 |
-
iao4 80
|
| 82 |
-
ie1 81
|
| 83 |
-
ie2 82
|
| 84 |
-
ie3 83
|
| 85 |
-
ie4 84
|
| 86 |
-
ie5 85
|
| 87 |
-
ii 86
|
| 88 |
-
in1 87
|
| 89 |
-
in2 88
|
| 90 |
-
in3 89
|
| 91 |
-
in4 90
|
| 92 |
-
ing1 91
|
| 93 |
-
ing2 92
|
| 94 |
-
ing3 93
|
| 95 |
-
ing4 94
|
| 96 |
-
iong1 95
|
| 97 |
-
iong2 96
|
| 98 |
-
iong3 97
|
| 99 |
-
iong4 98
|
| 100 |
-
iu1 99
|
| 101 |
-
iu2 100
|
| 102 |
-
iu3 101
|
| 103 |
-
iu4 102
|
| 104 |
-
iu5 103
|
| 105 |
-
iz4 104
|
| 106 |
-
j 105
|
| 107 |
-
k 106
|
| 108 |
-
l 107
|
| 109 |
-
m 108
|
| 110 |
-
n 109
|
| 111 |
-
o1 110
|
| 112 |
-
o2 111
|
| 113 |
-
o3 112
|
| 114 |
-
o4 113
|
| 115 |
-
o5 114
|
| 116 |
-
ong1 115
|
| 117 |
-
ong2 116
|
| 118 |
-
ong3 117
|
| 119 |
-
ong4 118
|
| 120 |
-
oo 119
|
| 121 |
-
ou1 120
|
| 122 |
-
ou2 121
|
| 123 |
-
ou3 122
|
| 124 |
-
ou4 123
|
| 125 |
-
ou5 124
|
| 126 |
-
p 125
|
| 127 |
-
q 126
|
| 128 |
-
r 127
|
| 129 |
-
s 128
|
| 130 |
-
sh 129
|
| 131 |
-
t 130
|
| 132 |
-
u1 131
|
| 133 |
-
u2 132
|
| 134 |
-
u3 133
|
| 135 |
-
u4 134
|
| 136 |
-
u5 135
|
| 137 |
-
ua1 136
|
| 138 |
-
ua2 137
|
| 139 |
-
ua3 138
|
| 140 |
-
ua4 139
|
| 141 |
-
ua5 140
|
| 142 |
-
uai1 141
|
| 143 |
-
uai2 142
|
| 144 |
-
uai3 143
|
| 145 |
-
uai4 144
|
| 146 |
-
uan1 145
|
| 147 |
-
uan2 146
|
| 148 |
-
uan3 147
|
| 149 |
-
uan4 148
|
| 150 |
-
uang1 149
|
| 151 |
-
uang2 150
|
| 152 |
-
uang3 151
|
| 153 |
-
uang4 152
|
| 154 |
-
ueng1 153
|
| 155 |
-
ui1 154
|
| 156 |
-
ui2 155
|
| 157 |
-
ui3 156
|
| 158 |
-
ui4 157
|
| 159 |
-
un1 158
|
| 160 |
-
un2 159
|
| 161 |
-
un3 160
|
| 162 |
-
un4 161
|
| 163 |
-
uo1 162
|
| 164 |
-
uo2 163
|
| 165 |
-
uo3 164
|
| 166 |
-
uo4 165
|
| 167 |
-
uo5 166
|
| 168 |
-
uu 167
|
| 169 |
-
v1 168
|
| 170 |
-
v2 169
|
| 171 |
-
v3 170
|
| 172 |
-
v4 171
|
| 173 |
-
van1 172
|
| 174 |
-
van2 173
|
| 175 |
-
van3 174
|
| 176 |
-
van4 175
|
| 177 |
-
ve1 176
|
| 178 |
-
ve2 177
|
| 179 |
-
ve3 178
|
| 180 |
-
ve4 179
|
| 181 |
-
vn1 180
|
| 182 |
-
vn2 181
|
| 183 |
-
vn3 182
|
| 184 |
-
vn4 183
|
| 185 |
-
vv 184
|
| 186 |
-
x 185
|
| 187 |
-
z 186
|
| 188 |
-
zh 187
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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