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
fix(dictionary): guard voice matching lifecycle
altic-deva789f934ddb3
diff --git a/Sources/Fluid/Persistence/SettingsStore.swift b/Sources/Fluid/Persistence/SettingsStore.swiftindex bdf97656..f8d997e6 100644--- a/Sources/Fluid/Persistence/SettingsStore.swift+++ b/Sources/Fluid/Persistence/SettingsStore.swift@@ -4478,6 +4478,19 @@ final class SettingsStore: ObservableObject {}}+ var supportsPronunciationMatching: Bool {+ #if arch(arm64)+ switch self {+ case .parakeetTDT, .parakeetTDTv2:+ return true+ default:+ return false+ }+ #else+ return false+ #endif+ }+/// Preview update cadence for real-time transcription./// Models without native incremental decoding should use a slower interval.var streamingPreviewIntervalSeconds: Double {diff --git a/Sources/Fluid/Services/ASRService.swift b/Sources/Fluid/Services/ASRService.swiftindex 7fe7b399..c780641b 100644--- a/Sources/Fluid/Services/ASRService.swift+++ b/Sources/Fluid/Services/ASRService.swift@@ -1328,8 +1328,8 @@ final class ASRService: ObservableObject {do {try self.startPreferredAudioCapture()- self.isRunning = trueself.isDictionaryTrainingCaptureActive = forDictionaryTraining+ self.isRunning = trueDebugLogger.shared.info("✅ Audio capture running", source: "ASRService")onCaptureStarted?()diff --git a/Sources/Fluid/UI/CustomDictionaryView.swift b/Sources/Fluid/UI/CustomDictionaryView.swiftindex cc6a2c0a..2c89a7fc 100644--- a/Sources/Fluid/UI/CustomDictionaryView.swift+++ b/Sources/Fluid/UI/CustomDictionaryView.swift@@ -65,6 +65,17 @@ struct CustomDictionaryView: View {self.trainingReplacement.trimmingCharacters(in: .whitespacesAndNewlines)}+ private var activePronunciationMatching: Bool {+ self.pronunciationMatchingEnabled && SettingsStore.shared.selectedSpeechModel.supportsPronunciationMatching+ }++ private var pronunciationMatchingBinding: Binding<Bool> {+ Binding(+ get: { self.activePronunciationMatching },+ set: { self.pronunciationMatchingEnabled = $0 }+ )+ }+private var trainingTargetReference: String {DictionaryTrainingCopy.target(for: self.normalizedTrainingReplacement)}@@ -93,7 +104,7 @@ struct CustomDictionaryView: View {}private var trainingFinalOutputIsReady: Bool {- if self.pronunciationMatchingEnabled {+ if self.activePronunciationMatching {return !self.trainingAlreadyCorrectWithoutReplacement &&self.trainingPronunciationEnrollments.count >= CustomDictionaryTrainingMerge.readyCoveredCount}@@ -103,7 +114,7 @@ struct CustomDictionaryView: View {}private var trainingAlreadyCorrectWithoutReplacement: Bool {- if self.pronunciationMatchingEnabled {+ if self.activePronunciationMatching {return self.trainingVariants.isEmpty &&!self.lastTrainingOutput.isEmpty &&self.lastTrainingOutput.caseInsensitiveCompare(self.normalizedTrainingReplacement) == .orderedSame &&@@ -117,7 +128,7 @@ struct CustomDictionaryView: View {}private var trainingReadinessProgress: Int {- if self.pronunciationMatchingEnabled {+ if self.activePronunciationMatching {return min(self.trainingPronunciationEnrollments.count, CustomDictionaryTrainingMerge.readyCoveredCount)}guard !self.trainingAlreadyCorrectWithoutReplacement else {@@ -128,7 +139,7 @@ struct CustomDictionaryView: View {}private var trainingOutputIsCovered: Bool {- if self.pronunciationMatchingEnabled {+ if self.activePronunciationMatching {return !self.trainingPronunciationEnrollments.isEmpty}return self.lastTrainingOutputIsCovered@@ -264,10 +275,17 @@ struct CustomDictionaryView: View {self.entries[index] = updatedEntryself.saveEntries()Task {- try? await PronunciationDictionaryStore.shared.updateLabel(- dictionaryEntryID: updatedEntry.id,- label: updatedEntry.replacement- )+ if PronunciationProfileEditPolicy.shouldDiscardProfile(+ previousReplacement: entry.replacement,+ updatedReplacement: updatedEntry.replacement+ ) {+ try? await PronunciationDictionaryStore.shared.delete(dictionaryEntryID: updatedEntry.id)+ } else {+ try? await PronunciationDictionaryStore.shared.updateLabel(+ dictionaryEntryID: updatedEntry.id,+ label: updatedEntry.replacement+ )+ }}}}@@ -277,6 +295,10 @@ struct CustomDictionaryView: View {self.loadBoostTerms()self.automaticDictionaryLearningEnabled = SettingsStore.shared.automaticDictionaryLearningEnabledself.pronunciationMatchingEnabled = SettingsStore.shared.pronunciationMatchingEnabled+ if !SettingsStore.shared.selectedSpeechModel.supportsPronunciationMatching {+ self.pronunciationMatchingEnabled = false+ SettingsStore.shared.pronunciationMatchingEnabled = false+ }self.punctuationAutoConvertEnabled = SettingsStore.shared.autoConvertPunctuationEnabled}.onReceive(NotificationCenter.default.publisher(for: .parakeetVocabularyDidChange)) { _ in@@ -609,8 +631,9 @@ struct CustomDictionaryView: View {private var voiceMatchingSettingsRow: some View {VoiceMatchingSettingsRow(- isEnabled: self.$pronunciationMatchingEnabled,+ isEnabled: self.pronunciationMatchingBinding,isDisabled: self.isTrainingRecording || self.isTrainingProcessing,+ isAdvancedAvailable: SettingsStore.shared.selectedSpeechModel.supportsPronunciationMatching,onChange: self.handlePronunciationMatchingChange(enabled:))}@@ -626,7 +649,7 @@ struct CustomDictionaryView: View {.foregroundStyle(self.theme.palette.accent)} else if self.trainingFinalOutputIsReady {Label(- self.pronunciationMatchingEnabled+ self.activePronunciationMatching? "Voice profile for \(self.trainingTargetReference) captured 3 times.": "FluidVoice recognized \(self.trainingTargetReference) 3 times in a row.",systemImage: "checkmark.circle.fill"@@ -645,7 +668,7 @@ struct CustomDictionaryView: View {)self.trainingInstruction(number: 3,- text: self.pronunciationMatchingEnabled+ text: self.activePronunciationMatching? "Repeat 3 times to teach FluidVoice how your voice sounds.": "Keep repeating it until the circle reaches 3/3.")@@ -704,7 +727,7 @@ struct CustomDictionaryView: View {target: self.trainingTargetReference,isAlreadyCorrect: self.trainingAlreadyCorrectWithoutReplacement,isReady: self.trainingFinalOutputIsReady,- usesVoiceMatching: self.pronunciationMatchingEnabled+ usesVoiceMatching: self.activePronunciationMatching)}@@ -1819,7 +1842,7 @@ struct CustomDictionaryView: View {let transcript = await self.asr.stop(forDictionaryTraining: true)self.isTrainingProcessing = false- if self.pronunciationMatchingEnabled,+ if self.activePronunciationMatching,CustomDictionaryTrainingMerge.normalizedTrigger(transcript) != nil,let enrollment = self.asr.lastDictionaryTrainingResult?.pronunciationEnrollment{@@ -1853,7 +1876,7 @@ struct CustomDictionaryView: View {}private func addTrainingVariant(from transcript: String) {- if self.pronunciationMatchingEnabled,+ if self.activePronunciationMatching,self.asr.lastDictionaryTrainingResult?.pronunciationEnrollment == nil{self.trainingHasError = true@@ -1938,7 +1961,7 @@ struct CustomDictionaryView: View {$0.replacement.caseInsensitiveCompare(replacementText) == .orderedSame}let enrollments = self.trainingPronunciationEnrollments- if self.pronunciationMatchingEnabled, let entry, let modelKey = enrollments.first?.modelKey {+ if self.activePronunciationMatching, let entry, let modelKey = enrollments.first?.modelKey {do {try await PronunciationDictionaryStore.shared.upsert(dictionaryEntryID: entry.id,@@ -2269,6 +2292,7 @@ private struct VoiceMatchingSettingsRow: View {@Binding var isEnabled: Boollet isDisabled: Bool+ let isAdvancedAvailable: Boollet onChange: (Bool) -> Void@Environment(\.theme) private var theme@@ -2292,6 +2316,11 @@ private struct VoiceMatchingSettingsRow: View {.fixedSize(horizontal: false, vertical: true)}.padding(.horizontal, 2)+ } else if !self.isAdvancedAvailable {+ Text("Advanced voice matching requires Parakeet TDT on Apple Silicon.")+ .font(self.theme.typography.caption)+ .foregroundStyle(self.theme.palette.secondaryText)+ .padding(.horizontal, 2)}}.padding(self.theme.metrics.spacing.md)@@ -2352,8 +2381,8 @@ private struct VoiceMatchingSettingsRow: View {.contentShape(RoundedRectangle(cornerRadius: 7, style: .continuous))}.buttonStyle(.plain)- .disabled(self.isDisabled)- .opacity(self.isDisabled ? 0.55 : 1)+ .disabled(self.isDisabled || (enabledValue && !self.isAdvancedAvailable))+ .opacity(self.isDisabled || (enabledValue && !self.isAdvancedAvailable) ? 0.55 : 1).onHover { hovering inlet update = { self.hoveredMethod = hovering ? enabledValue : nil }if self.reduceMotion {@@ -2636,6 +2665,12 @@ enum CustomDictionaryManualEntry {}}+enum PronunciationProfileEditPolicy {+ static func shouldDiscardProfile(previousReplacement: String, updatedReplacement: String) -> Bool {+ previousReplacement.caseInsensitiveCompare(updatedReplacement) != .orderedSame+ }+}+enum CustomDictionaryTrainingMerge {static let recommendedSamples = 5static let maxSamples = 20diff --git a/Tests/FluidDictationIntegrationTests/DictationE2ETests.swift b/Tests/FluidDictationIntegrationTests/DictationE2ETests.swiftindex e05ba5f2..daa244a3 100644--- a/Tests/FluidDictationIntegrationTests/DictationE2ETests.swift+++ b/Tests/FluidDictationIntegrationTests/DictationE2ETests.swift@@ -858,6 +858,33 @@ final class DictationE2ETests: XCTestCase {}}+ func testPronunciationProfileEditPolicyDiscardsProfileWhenMeaningChanges() {+ XCTAssertTrue(+ PronunciationProfileEditPolicy.shouldDiscardProfile(+ previousReplacement: "Barath",+ updatedReplacement: "FluidVoice"+ )+ )+ XCTAssertFalse(+ PronunciationProfileEditPolicy.shouldDiscardProfile(+ previousReplacement: "Barath",+ updatedReplacement: "BARATH"+ )+ )+ }++ func testPronunciationMatchingRequiresSupportedAppleSiliconModel() {+ #if arch(arm64)+ XCTAssertTrue(SettingsStore.SpeechModel.parakeetTDT.supportsPronunciationMatching)+ XCTAssertTrue(SettingsStore.SpeechModel.parakeetTDTv2.supportsPronunciationMatching)+ #else+ XCTAssertFalse(SettingsStore.SpeechModel.parakeetTDT.supportsPronunciationMatching)+ XCTAssertFalse(SettingsStore.SpeechModel.parakeetTDTv2.supportsPronunciationMatching)+ #endif+ XCTAssertFalse(SettingsStore.SpeechModel.whisperLargeTurbo.supportsPronunciationMatching)+ XCTAssertFalse(SettingsStore.SpeechModel.cohereTranscribeSixBit.supportsPronunciationMatching)+ }+func testProgressiveDownloaderRetainsFileByMovingIt() throws {let source = FileManager.default.temporaryDirectory.appendingPathComponent("FluidVoiceDownloadSource-\(UUID().uuidString)")