Commit 23a6ceb
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 acc4bc8 commit 23a6ceb
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 | | |
| |||
242 | 262 | | |
243 | 263 | | |
244 | 264 | | |
245 | | - | |
246 | | - | |
| 265 | + | |
| 266 | + | |
247 | 267 | | |
248 | | - | |
| 268 | + | |
249 | 269 | | |
250 | 270 | | |
251 | 271 | | |
252 | 272 | | |
253 | 273 | | |
254 | 274 | | |
255 | | - | |
| 275 | + | |
256 | 276 | | |
257 | 277 | | |
258 | 278 | | |
| |||
267 | 287 | | |
268 | 288 | | |
269 | 289 | | |
270 | | - | |
| 290 | + | |
271 | 291 | | |
272 | 292 | | |
273 | 293 | | |
| |||
| 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