Fastest and only macOS Dictation app with on-device STT and custom trained AI enhancement model. Windows, iOS testflight! Android, Linux waitlist open! A local Wispr Flow alternative. Follow https://x.com/fluidvoiceapp for more
Preserve automatic language in settings backups
Wallner Ádám547f939d5d69
diff --git a/Sources/Fluid/Persistence/SettingsStore.swift b/Sources/Fluid/Persistence/SettingsStore.swiftindex ac94d521..12e7c8f8 100644--- a/Sources/Fluid/Persistence/SettingsStore.swift+++ b/Sources/Fluid/Persistence/SettingsStore.swift@@ -14,6 +14,7 @@ final class SettingsStore: ObservableObject {static let microphonePriorityMigrationVersion = 4static let shared = SettingsStore()+ private static let automaticWhisperLanguageCode = "auto"static let transcriptionPreviewCharLimitRange: ClosedRange<Int> = 50...800static let transcriptionPreviewCharLimitStep = 50static let defaultTranscriptionPreviewCharLimit = 150@@ -3202,7 +3203,7 @@ final class SettingsStore: ObservableObject {privateAIBackendPreference: self.privateAIBackendPreference,privateAIContextTokenLimit: self.privateAIContextTokenLimit,selectedSpeechModel: self.selectedSpeechModel,- selectedWhisperLanguageCode: self.selectedWhisperLanguageCode,+ selectedWhisperLanguageCode: Self.whisperLanguageBackupValue(for: self.selectedWhisperLanguageCode),selectedCohereLanguage: self.selectedCohereLanguage,selectedNemotronLanguage: self.selectedNemotronLanguage,selectedAppleSpeechLocaleIdentifier: self.selectedAppleSpeechLocaleIdentifier,@@ -3326,7 +3327,7 @@ final class SettingsStore: ObservableObject {}self.selectedSpeechModel = payload.selectedSpeechModelif let selectedWhisperLanguageCode = payload.selectedWhisperLanguageCode {- self.selectedWhisperLanguageCode = selectedWhisperLanguageCode+ self.selectedWhisperLanguageCode = Self.whisperLanguageCode(fromBackupValue: selectedWhisperLanguageCode)}self.selectedCohereLanguage = payload.selectedCohereLanguageif let selectedNemotronLanguage = payload.selectedNemotronLanguage {@@ -5745,17 +5746,25 @@ extension SettingsStore {var selectedWhisperLanguageCode: String? {get {if let stored = self.defaults.string(forKey: Keys.selectedWhisperLanguageCode) {- guard stored != "auto" else { return nil }+ guard stored != Self.automaticWhisperLanguageCode else { return nil }return VoiceEngineLanguageCatalog.whisperLanguage(forCode: stored) == nil ? nil : stored}return VoiceEngineLanguageCatalog.whisperLanguageCode(for: self.onboardingSelectedLanguageID)}set {objectWillChange.send()- self.defaults.set(newValue ?? "auto", forKey: Keys.selectedWhisperLanguageCode)+ self.defaults.set(newValue ?? Self.automaticWhisperLanguageCode, forKey: Keys.selectedWhisperLanguageCode)}}+ static func whisperLanguageBackupValue(for languageCode: String?) -> String {+ languageCode ?? self.automaticWhisperLanguageCode+ }++ static func whisperLanguageCode(fromBackupValue value: String) -> String? {+ value == self.automaticWhisperLanguageCode ? nil : value+ }+var selectedCohereLanguage: CohereLanguage {get {if let rawValue = self.defaults.string(forKey: Keys.selectedCohereLanguage),diff --git a/Tests/FluidDictationIntegrationTests/WhisperLanguageSelectionTests.swift b/Tests/FluidDictationIntegrationTests/WhisperLanguageSelectionTests.swiftindex d9ac75cd..2ed30922 100644--- a/Tests/FluidDictationIntegrationTests/WhisperLanguageSelectionTests.swift+++ b/Tests/FluidDictationIntegrationTests/WhisperLanguageSelectionTests.swift@@ -20,6 +20,20 @@ final class WhisperLanguageSelectionTests: XCTestCase {XCTAssertNil(WhisperProvider.runOptions(languageCode: nil).language)}+ func testAutomaticWhisperLanguageRoundTripsThroughBackupValue() {+ let backupValue = SettingsStore.whisperLanguageBackupValue(for: nil)++ XCTAssertEqual(backupValue, "auto")+ XCTAssertNil(SettingsStore.whisperLanguageCode(fromBackupValue: backupValue))+ }++ func testForcedWhisperLanguageRoundTripsThroughBackupValue() {+ let backupValue = SettingsStore.whisperLanguageBackupValue(for: "hu")++ XCTAssertEqual(backupValue, "hu")+ XCTAssertEqual(SettingsStore.whisperLanguageCode(fromBackupValue: backupValue), "hu")+ }+func testWhisperLanguageCodesAreUnique() {let languageCodes = VoiceEngineLanguageCatalog.whisperLanguages.compactMap {VoiceEngineLanguageCatalog.whisperLanguageCode(for: $0.id)