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

Formatting

altic-dev6115f3c232de
diff --git a/Sources/Fluid/Services/ASRService.swift b/Sources/Fluid/Services/ASRService.swift
index 9f8e9283..d72e4953 100644
--- a/Sources/Fluid/Services/ASRService.swift
+++ b/Sources/Fluid/Services/ASRService.swift
@@ -289,10 +289,10 @@ final class ASRService: ObservableObject {
// This is done in a Task to support async model detection (e.g., AppleSpeechAnalyzerProvider)
Task { [weak self] in
guard let self = self else { return }
-
+
// Use async check to accurately detect models (especially for Apple Speech Analyzer)
await self.checkIfModelsExistAsync()
-
+
// Auto-load models if they exist on disk to avoid "Downloaded but not loaded" state
if self.modelsExistOnDisk {
DebugLogger.shared.info("Models found on disk, auto-loading...", source: "ASRService")
@@ -307,7 +307,7 @@ final class ASRService: ObservableObject {
}
/// Check if models exist on disk without loading them (synchronous).
- ///
+ ///
/// **Note**: For `AppleSpeechAnalyzerProvider`, this returns a cached value that may be stale.
/// Use `checkIfModelsExistAsync()` for an up-to-date result.
func checkIfModelsExist() {
@@ -316,12 +316,12 @@ final class ASRService: ObservableObject {
}
/// Check if models exist on disk without loading them (async).
- ///
+ ///
/// This method performs an accurate async check for providers that require it
/// (e.g., `AppleSpeechAnalyzerProvider` uses `SpeechTranscriber.installedLocales`).
func checkIfModelsExistAsync() async {
let model = SettingsStore.shared.selectedSpeechModel
-
+
// For Apple Speech Analyzer, use the async refresh method
if model == .appleSpeechAnalyzer {
if #available(macOS 26.0, *) {
@@ -332,7 +332,7 @@ final class ASRService: ObservableObject {
return
}
}
-
+
// For other providers, use the synchronous method
self.modelsExistOnDisk = self.transcriptionProvider.modelsExistOnDisk()
DebugLogger.shared.debug("Models exist on disk: \(self.modelsExistOnDisk)", source: "ASRService")
diff --git a/Sources/Fluid/Services/AppleSpeechAnalyzerProvider.swift b/Sources/Fluid/Services/AppleSpeechAnalyzerProvider.swift
index 3cd4e1f0..0835d902 100644
--- a/Sources/Fluid/Services/AppleSpeechAnalyzerProvider.swift
+++ b/Sources/Fluid/Services/AppleSpeechAnalyzerProvider.swift
@@ -82,10 +82,10 @@ final class AppleSpeechAnalyzerProvider: TranscriptionProvider {
self.converter = BufferConverter()
self.isReady = true
-
+
// Update cache to reflect that model is now installed (thread-safe)
self._cacheQueue.sync { self._modelsInstalledCache = true }
-
+
DebugLogger.shared.info("AppleSpeechAnalyzerProvider ready", source: "AppleSpeechAnalyzerProvider")
}
@@ -95,18 +95,18 @@ final class AppleSpeechAnalyzerProvider: TranscriptionProvider {
for locale in reserved {
await AssetInventory.release(reservedLocale: locale)
}
-
+
// Reset cache to reflect models are no longer installed (thread-safe)
self._cacheQueue.sync { self._modelsInstalledCache = false }
-
+
self.isReady = false
}
/// Returns the cached result of whether models are installed (thread-safe).
- ///
+ ///
/// **Important**: This method returns a cached value that defaults to `false`.
/// For an accurate result, call `refreshModelsExistOnDiskAsync()` first.
- ///
+ ///
/// The synchronous nature of this protocol method makes it impossible to
/// perform the actual async `SpeechTranscriber.installedLocales` check inline.
/// Callers should use `refreshModelsExistOnDiskAsync()` during initialization
@@ -124,14 +124,14 @@ final class AppleSpeechAnalyzerProvider: TranscriptionProvider {
let installedLocales = await SpeechTranscriber.installedLocales
let currentLocaleID = Locale.current.identifier(.bcp47)
let isInstalled = installedLocales.map { $0.identifier(.bcp47) }.contains(currentLocaleID)
-
+
self._cacheQueue.sync { self._modelsInstalledCache = isInstalled }
-
+
DebugLogger.shared.debug(
"AppleSpeechAnalyzer: Model installed check - locale: \(currentLocaleID), installed: \(isInstalled)",
source: "AppleSpeechAnalyzerProvider"
)
-
+
return isInstalled
}