|
|
|
@ -49,6 +49,9 @@ public final class TextProcessor { |
|
|
|
// 3. Number Formatting |
|
|
|
result = applyNumberFormatting(result, format: SonioxSettings.shared.numberFormat) |
|
|
|
|
|
|
|
// 3.5. Sanitize foreign hallucinations & word loops |
|
|
|
result = SonioxLiveSession.sanitizeText(result) |
|
|
|
|
|
|
|
// 4. Text Normalization |
|
|
|
if SonioxSettings.shared.normalizeText { |
|
|
|
result = normalizeText(result) |
|
|
|
@ -120,6 +123,14 @@ public final class TextProcessor { |
|
|
|
private func applyDomainVocabulary(_ text: String) -> String { |
|
|
|
var t = text |
|
|
|
let terms: [(String, String)] = [ |
|
|
|
("این اپ پرچس", "In-App Purchase"), |
|
|
|
("این اپ پرشرز", "In-App Purchase"), |
|
|
|
("اپ پرشرز", "In-App Purchases"), |
|
|
|
("اپل کانکت", "App Store Connect"), |
|
|
|
("اپ استور کانکت", "App Store Connect"), |
|
|
|
("حجزی مرچنت", "Hajzee Merchant"), |
|
|
|
("حجزی یوزر", "Hajzee User"), |
|
|
|
("حجزی", "Hajzee"), |
|
|
|
("نیوهورایزن", "NewHorizon"), |
|
|
|
("نیو هورایزن", "NewHorizon"), |
|
|
|
("نیوهوریزن", "NewHorizon"), |
|
|
|
@ -247,6 +258,18 @@ public final class TextProcessor { |
|
|
|
for p in [".", "،", "؛", "؟", "!"] { |
|
|
|
t = t.replacingOccurrences(of: p, with: p + " ") |
|
|
|
} |
|
|
|
// Common ASR stutter & merged word fixes |
|
|
|
let speechFixes: [(String, String)] = [ |
|
|
|
(" ماا ", " ما "), |
|
|
|
(" اینپیگیری ", " این پیگیری "), |
|
|
|
(" میکنکنیم ", " میکنیم "), |
|
|
|
(" سر سمانش ", " سر و سامانش "), |
|
|
|
(" دست و پا گیرلی ", " دست و پا گیر ولی ") |
|
|
|
] |
|
|
|
for (bad, good) in speechFixes { |
|
|
|
t = t.replacingOccurrences(of: bad, with: good) |
|
|
|
} |
|
|
|
|
|
|
|
// Fix spaces inside parentheses / quotes |
|
|
|
t = t.replacingOccurrences(of: "( ", with: "(") |
|
|
|
t = t.replacingOccurrences(of: "« ", with: "«") |
|
|
|
|