Commit ac6218d
refactor: split SherpaOnnxManager and extract magic numbers (P0-2, P1-4)
Split SherpaOnnxManager.swift (803 lines, 5 responsibilities) into focused components:
- ModelPathResolver: resolves local model paths and checks existence
- ModelDownloader: handles downloading from ModelScope/GitHub with fallback
- ModelExtractionService: handles tar.bz2 extraction
- SherpaOnnxManager: thin orchestrator delegating to the above
Extract magic numbers as named constants in:
- ChineseSpellingCorrector: logit/softmax thresholds, correction ratio limit
- DualEngineASR: flush silence sample count
- QwenASRRecognizer: chunk_sec, rollback, max_new_tokens, segment_sec
- ASREngine: flush silence sample count
- SherpaOnnxOnlineRecognizer: sample rate, feature dim, endpoint detection rules
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>1 parent 209cb26 commit ac6218d
10 files changed
Lines changed: 868 additions & 638 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
88 | 88 | | |
89 | 89 | | |
90 | 90 | | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
91 | 100 | | |
92 | 101 | | |
93 | 102 | | |
| |||
127 | 136 | | |
128 | 137 | | |
129 | 138 | | |
130 | | - | |
| 139 | + | |
131 | 140 | | |
132 | 141 | | |
133 | 142 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
11 | 31 | | |
12 | 32 | | |
13 | 33 | | |
| |||
79 | 99 | | |
80 | 100 | | |
81 | 101 | | |
82 | | - | |
| 102 | + | |
83 | 103 | | |
84 | 104 | | |
85 | 105 | | |
| |||
131 | 151 | | |
132 | 152 | | |
133 | 153 | | |
134 | | - | |
| 154 | + | |
135 | 155 | | |
136 | 156 | | |
137 | 157 | | |
| |||
265 | 285 | | |
266 | 286 | | |
267 | 287 | | |
268 | | - | |
| 288 | + | |
269 | 289 | | |
270 | 290 | | |
271 | 291 | | |
| |||
305 | 325 | | |
306 | 326 | | |
307 | 327 | | |
308 | | - | |
309 | | - | |
| 328 | + | |
| 329 | + | |
310 | 330 | | |
311 | | - | |
| 331 | + | |
312 | 332 | | |
313 | 333 | | |
314 | 334 | | |
315 | 335 | | |
316 | 336 | | |
317 | 337 | | |
318 | | - | |
| 338 | + | |
319 | 339 | | |
320 | 340 | | |
321 | 341 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
20 | 26 | | |
21 | 27 | | |
22 | 28 | | |
| |||
63 | 69 | | |
64 | 70 | | |
65 | 71 | | |
66 | | - | |
| 72 | + | |
67 | 73 | | |
68 | 74 | | |
69 | 75 | | |
| |||
0 commit comments