Skip to content

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 whisper automatic detection

altic-devddf733ca31d6
diff --git a/Sources/Fluid/Persistence/SettingsStore.swift b/Sources/Fluid/Persistence/SettingsStore.swift
index f61d28f6..09fc30be 100644
--- a/Sources/Fluid/Persistence/SettingsStore.swift
+++ b/Sources/Fluid/Persistence/SettingsStore.swift
@@ -5741,15 +5741,10 @@ extension SettingsStore {
}
/// The language Whisper should transcribe, or `nil` to detect it from each recording.
- /// Existing installs inherit the language chosen during onboarding until the user
- /// explicitly selects Automatic or another language.
+ /// Existing installs keep automatic detection until the user selects a language.
var selectedWhisperLanguageCode: String? {
get {
- if let stored = self.defaults.string(forKey: Keys.selectedWhisperLanguageCode) {
- guard stored != Self.automaticWhisperLanguageCode else { return nil }
- return VoiceEngineLanguageCatalog.whisperLanguage(forCode: stored) == nil ? nil : stored
- }
- return VoiceEngineLanguageCatalog.whisperLanguageCode(for: self.onboardingSelectedLanguageID)
+ Self.whisperLanguageCode(fromStoredValue: self.defaults.string(forKey: Keys.selectedWhisperLanguageCode))
}
set {
objectWillChange.send()
@@ -5757,6 +5752,11 @@ extension SettingsStore {
}
}
+ static func whisperLanguageCode(fromStoredValue value: String?) -> String? {
+ guard let value, value != self.automaticWhisperLanguageCode else { return nil }
+ return VoiceEngineLanguageCatalog.whisperLanguage(forCode: value) == nil ? nil : value
+ }
+
static func whisperLanguageBackupValue(for languageCode: String?) -> String {
languageCode ?? self.automaticWhisperLanguageCode
}
diff --git a/Tests/FluidDictationIntegrationTests/WhisperLanguageSelectionTests.swift b/Tests/FluidDictationIntegrationTests/WhisperLanguageSelectionTests.swift
index 2ed30922..73c11477 100644
--- a/Tests/FluidDictationIntegrationTests/WhisperLanguageSelectionTests.swift
+++ b/Tests/FluidDictationIntegrationTests/WhisperLanguageSelectionTests.swift
@@ -20,6 +20,13 @@ final class WhisperLanguageSelectionTests: XCTestCase {
XCTAssertNil(WhisperProvider.runOptions(languageCode: nil).language)
}
+ func testStoredWhisperLanguageSelectionResolution() {
+ XCTAssertNil(SettingsStore.whisperLanguageCode(fromStoredValue: nil))
+ XCTAssertNil(SettingsStore.whisperLanguageCode(fromStoredValue: "auto"))
+ XCTAssertEqual(SettingsStore.whisperLanguageCode(fromStoredValue: "hu"), "hu")
+ XCTAssertNil(SettingsStore.whisperLanguageCode(fromStoredValue: "unsupported"))
+ }
+
func testAutomaticWhisperLanguageRoundTripsThroughBackupValue() {
let backupValue = SettingsStore.whisperLanguageBackupValue(for: nil)