Remove toggle switch for word replacements

This commit is contained in:
Beingpax 2025-11-07 10:47:25 +05:45
parent dc925e0ebd
commit 5f59b61ee8
4 changed files with 14 additions and 40 deletions

View File

@ -123,10 +123,7 @@ class AudioTranscriptionManager: ObservableObject {
text = WhisperTextFormatter.format(text)
}
// Apply word replacements if enabled
if UserDefaults.standard.bool(forKey: "IsWordReplacementEnabled") {
text = WordReplacementService.shared.applyReplacements(to: text)
}
text = WordReplacementService.shared.applyReplacements(to: text)
// Handle enhancement if enabled
if let enhancementService = whisperState.enhancementService,

View File

@ -73,11 +73,8 @@ class AudioTranscriptionService: ObservableObject {
text = WhisperTextFormatter.format(text)
}
// Apply word replacements if enabled
if UserDefaults.standard.bool(forKey: "IsWordReplacementEnabled") {
text = WordReplacementService.shared.applyReplacements(to: text)
logger.notice("✅ Word replacements applied")
}
text = WordReplacementService.shared.applyReplacements(to: text)
logger.notice("✅ Word replacements applied")
// Get audio duration
let audioAsset = AVURLAsset(url: url)

View File

@ -22,16 +22,9 @@ class WordReplacementManager: ObservableObject {
UserDefaults.standard.set(replacements, forKey: "wordReplacements")
}
}
@Published var isEnabled: Bool {
didSet {
UserDefaults.standard.set(isEnabled, forKey: "IsWordReplacementEnabled")
}
}
init() {
self.replacements = UserDefaults.standard.dictionary(forKey: "wordReplacements") as? [String: String] ?? [:]
self.isEnabled = UserDefaults.standard.bool(forKey: "IsWordReplacementEnabled")
}
func addReplacement(original: String, replacement: String) {
@ -97,26 +90,15 @@ struct WordReplacementView: View {
var body: some View {
VStack(alignment: .leading, spacing: 20) {
// Info Section with Toggle
GroupBox {
HStack {
Label {
Text("Define word replacements to automatically replace specific words or phrases")
.font(.system(size: 12))
.foregroundColor(.secondary)
.fixedSize(horizontal: false, vertical: true)
.frame(alignment: .leading)
} icon: {
Image(systemName: "info.circle.fill")
.foregroundColor(.blue)
}
Spacer()
Toggle("Enable", isOn: $manager.isEnabled)
.toggleStyle(.switch)
.labelsHidden()
.help("Enable automatic word replacement after transcription")
Label {
Text("Define word replacements to automatically replace specific words or phrases")
.font(.system(size: 12))
.foregroundColor(.secondary)
.fixedSize(horizontal: false, vertical: true)
} icon: {
Image(systemName: "info.circle.fill")
.foregroundColor(.blue)
}
}

View File

@ -325,10 +325,8 @@ class WhisperState: NSObject, ObservableObject {
logger.notice("📝 Formatted transcript: \(text, privacy: .public)")
}
if UserDefaults.standard.bool(forKey: "IsWordReplacementEnabled") {
text = WordReplacementService.shared.applyReplacements(to: text)
logger.notice("📝 WordReplacement: \(text, privacy: .public)")
}
text = WordReplacementService.shared.applyReplacements(to: text)
logger.notice("📝 WordReplacement: \(text, privacy: .public)")
let audioAsset = AVURLAsset(url: url)
let actualDuration = (try? CMTimeGetSeconds(await audioAsset.load(.duration))) ?? 0.0