diff --git a/VoiceInk/Services/AudioFileTranscriptionManager.swift b/VoiceInk/Services/AudioFileTranscriptionManager.swift index 1bfaaff..aa17b3d 100644 --- a/VoiceInk/Services/AudioFileTranscriptionManager.swift +++ b/VoiceInk/Services/AudioFileTranscriptionManager.swift @@ -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, diff --git a/VoiceInk/Services/AudioFileTranscriptionService.swift b/VoiceInk/Services/AudioFileTranscriptionService.swift index ff04ae9..5a3de26 100644 --- a/VoiceInk/Services/AudioFileTranscriptionService.swift +++ b/VoiceInk/Services/AudioFileTranscriptionService.swift @@ -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) diff --git a/VoiceInk/Views/Dictionary/WordReplacementView.swift b/VoiceInk/Views/Dictionary/WordReplacementView.swift index 9d93330..ef603b4 100644 --- a/VoiceInk/Views/Dictionary/WordReplacementView.swift +++ b/VoiceInk/Views/Dictionary/WordReplacementView.swift @@ -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) } } diff --git a/VoiceInk/Whisper/WhisperState.swift b/VoiceInk/Whisper/WhisperState.swift index 60fc61f..c43ed95 100644 --- a/VoiceInk/Whisper/WhisperState.swift +++ b/VoiceInk/Whisper/WhisperState.swift @@ -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