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
feat(dictionary): polish voice training flow
altic-dev6bed0f069fd1
diff --git a/Sources/Fluid/Services/AutomaticDictionaryTrainingSession.swift b/Sources/Fluid/Services/AutomaticDictionaryTrainingSession.swiftindex ea930fbf..6df0ff08 100644--- a/Sources/Fluid/Services/AutomaticDictionaryTrainingSession.swift+++ b/Sources/Fluid/Services/AutomaticDictionaryTrainingSession.swift@@ -29,6 +29,7 @@ final class AutomaticDictionaryTrainingSession: ObservableObject {@Published private(set) var statusMessage = ""@Published private(set) var hasError = false@Published private(set) var successTitle = "Added to Dictionary"+ @Published private(set) var isAutomaticCaptureEnabled = falsevar onInteraction: (() -> Void)?var onSuccess: (() -> Void)?@@ -77,27 +78,31 @@ final class AutomaticDictionaryTrainingSession: ObservableObject {}var canSave: Bool {- !self.variants.isEmpty && self.capturePhase == .idle+ self.isReady && !self.variants.isEmpty && self.capturePhase == .idle}var canUseRecordButton: Bool {- switch self.capturePhase {- case .starting:- return !self.stopRequestedDuringStart- case .recording:+ if self.isAutomaticCaptureEnabled {return true- case .processing:+ }+ switch self.capturePhase {+ case .starting, .recording, .processing:return falsecase .idle:- return !self.asr.isRunning && self.sampleCount < CustomDictionaryTrainingMerge.maxSamples+ return !self.asr.isRunning && (+ self.sampleCount < CustomDictionaryTrainingMerge.maxSamples || !self.isReady+ )}}var recordButtonIsStop: Bool {- self.capturePhase == .starting || self.capturePhase == .recording+ self.isAutomaticCaptureEnabled || self.capturePhase == .starting || self.capturePhase == .recording}var recordButtonTitle: String {+ if self.isAutomaticCaptureEnabled {+ return "Stop"+ }switch self.capturePhase {case .starting:return self.stopRequestedDuringStart ? "Stopping..." : "Stop"@@ -106,7 +111,9 @@ final class AutomaticDictionaryTrainingSession: ObservableObject {case .processing:return "Checking..."case .idle:- return "Record"+ return self.sampleCount >= CustomDictionaryTrainingMerge.maxSamples && !self.isReady+ ? "Try Again"+ : "Start"}}@@ -119,12 +126,12 @@ final class AutomaticDictionaryTrainingSession: ObservableObject {var trainingDetail: String {if self.isReady {- return "You can add it now, or keep trying."+ return "FluidVoice got it right 3 times. Add it now, or keep training."}if self.sampleCount >= CustomDictionaryTrainingMerge.maxSamples {- return "Maximum samples reached. Add the replacement when ready."+ return "Not quite there yet. Try another round when you're ready."}- return "Keep going until FluidVoice understands you 3 times in a row."+ return "Start once and keep saying it. Each pause checks a try, then FluidVoice listens again until it gets it right 3 times."}func beginTraining() {@@ -139,18 +146,26 @@ final class AutomaticDictionaryTrainingSession: ObservableObject {func returnToChoice() {guard self.screen == .training, self.capturePhase == .idle else { return }self.onInteraction?()+ self.isAutomaticCaptureEnabled = falseself.screen = .choice}func toggleCapture() {self.onInteraction?()- switch self.capturePhase {- case .idle:+ if self.isAutomaticCaptureEnabled {+ self.isAutomaticCaptureEnabled = false+ switch self.capturePhase {+ case .starting, .recording:+ Task { await self.stopCapture() }+ case .idle, .processing:+ break+ }+ } else if self.capturePhase == .idle {+ if self.sampleCount >= CustomDictionaryTrainingMerge.maxSamples, !self.isReady {+ self.resetVerificationAttempts()+ }+ self.isAutomaticCaptureEnabled = trueTask { await self.startCapture() }- case .starting, .recording:- Task { await self.stopCapture() }- case .processing:- break}}@@ -173,6 +188,7 @@ final class AutomaticDictionaryTrainingSession: ObservableObject {func cancel() {self.isCancelled = trueself.discardCurrentCapture = true+ self.isAutomaticCaptureEnabled = falseDictionaryTrainingEndpointMonitor.shared.stop()switch self.capturePhase {case .starting:@@ -186,10 +202,12 @@ final class AutomaticDictionaryTrainingSession: ObservableObject {}private func startCapture() async {- guard self.capturePhase == .idle,+ guard self.isAutomaticCaptureEnabled,+ self.capturePhase == .idle,!self.asr.isRunning,self.sampleCount < CustomDictionaryTrainingMerge.maxSampleselse {+ self.isAutomaticCaptureEnabled = falsereturn}@@ -215,6 +233,7 @@ final class AutomaticDictionaryTrainingSession: ObservableObject {guard self.asr.isRunning else {self.capturePhase = .idleself.stopRequestedDuringStart = false+ self.isAutomaticCaptureEnabled = falseguard !self.didStartAudioCapture else { return }guard !self.isCancelled else { return }self.hasError = true@@ -250,7 +269,11 @@ final class AutomaticDictionaryTrainingSession: ObservableObject {}private func handleAutomaticSpeechEnd() {- guard self.capturePhase == .starting || self.capturePhase == .recording else { return }+ guard self.isAutomaticCaptureEnabled,+ self.capturePhase == .starting || self.capturePhase == .recording+ else {+ return+ }self.statusMessage = "Stopping..."self.stopTask?.cancel()self.stopTask = Task { await self.stopCapture() }@@ -270,6 +293,30 @@ final class AutomaticDictionaryTrainingSession: ObservableObject {self.discardCurrentCapture = falseguard !shouldDiscard else { return }self.addTrainingVariant(from: transcript)+ await self.continueAutomaticCaptureIfNeeded()+ }++ private func continueAutomaticCaptureIfNeeded() async {+ guard self.isAutomaticCaptureEnabled,+ !self.isReady,+ self.sampleCount < CustomDictionaryTrainingMerge.maxSamples,+ !self.isCancelled+ else {+ self.isAutomaticCaptureEnabled = false+ return+ }++ await Task.yield()+ await self.startCapture()+ }++ private func resetVerificationAttempts() {+ self.sampleCount = 0+ self.lastOutput = ""+ self.lastOutputIsCovered = false+ self.consecutiveCoveredCaptures = 0+ self.statusMessage = ""+ self.hasError = false}private func addTrainingVariant(from transcript: String) {diff --git a/Sources/Fluid/UI/CustomDictionaryView.swift b/Sources/Fluid/UI/CustomDictionaryView.swiftindex 7e1016cc..210b9ff5 100644--- a/Sources/Fluid/UI/CustomDictionaryView.swift+++ b/Sources/Fluid/UI/CustomDictionaryView.swift@@ -44,6 +44,9 @@ struct CustomDictionaryView: View {@State private var isTrainingRecording = false@State private var trainingStopRequestedDuringStart = false@State private var isTrainingProcessing = false+ @State private var isAutomaticTrainingEnabled = false+ @State private var isTrainedReplacementButtonHovered = false+ @State private var isTrainedReplacementGlowExpanded = false@State private var replacementConfirmation: ReplacementConfirmation?@State private var composerMode: DictionaryComposerMode = .train@State private var manualTriggerDraft = ""@@ -76,8 +79,22 @@ struct CustomDictionaryView: View {}private var canUseTrainingRecorderButton: Bool {+ if self.isAutomaticTrainingEnabled {+ return true+ }guard !self.trainingStopRequestedDuringStart, !self.isTrainingProcessing else { return false }- return self.isTrainingRecording || self.canRecordTrainingSample+ return self.isTrainingRecording || self.canRecordTrainingSample || self.canRetryTrainingAfterMaximum+ }++ private var trainingRecorderIsStop: Bool {+ self.isAutomaticTrainingEnabled || self.isTrainingRecording || self.isTrainingStarting+ }++ private var trainingRecorderButtonTitle: String {+ if self.trainingRecorderIsStop {+ return "Stop"+ }+ return self.canRetryTrainingAfterMaximum ? "Try Again" : "Start"}private var trainingRecorderTitle: String {@@ -93,16 +110,26 @@ struct CustomDictionaryView: View {if self.isTrainingRecording {return "Listening..."}+ if self.trainingFinalOutputIsReady {+ return "Ready to add"+ }if self.normalizedTrainingReplacement.isEmpty {- return "Record sample"+ return "Start training"}- return self.trainingVariants.isEmpty ? "Say it once" : "Say it again"+ return self.trainingSampleCount == 0 ? "Start once" : "Keep going"}private var trainingRecorderDetail: String {- self.normalizedTrainingReplacement.isEmpty- ? "Type the correct text first."- : "Keep trying until FluidVoice understands you 3 times in a row."+ if self.normalizedTrainingReplacement.isEmpty {+ return "Type the correct text first."+ }+ if self.trainingFinalOutputIsReady {+ return "FluidVoice got it right 3 times. Add the replacement, or keep training."+ }+ if self.canRetryTrainingAfterMaximum {+ return "Not quite there yet. Try another round when you're ready."+ }+ return "Start once and keep saying it. Each pause checks a try, then FluidVoice listens again until it gets it right 3 times."}private var trainingRecorderStatusText: String {@@ -167,24 +194,29 @@ struct CustomDictionaryView: View {return self.trainingOutputIsCovered ? self.normalizedTrainingReplacement : self.lastTrainingOutput}- private var canStartTraining: Bool {+ private var canRecordTrainingSample: Bool {!self.normalizedTrainingReplacement.isEmpty &&- !self.isTrainingRecording &&- !self.isTrainingProcessing+ !self.isTrainingProcessing &&+ !self.asr.isRunning &&+ self.trainingSampleCount < CustomDictionaryTrainingMerge.maxSamples}- private var canRecordTrainingSample: Bool {+ private var canRetryTrainingAfterMaximum: Bool {!self.normalizedTrainingReplacement.isEmpty &&+ !self.trainingFinalOutputIsReady &&+ !self.trainingAlreadyCorrectWithoutReplacement &&+ !self.isTrainingRecording &&!self.isTrainingProcessing &&!self.asr.isRunning &&- self.trainingSampleCount < CustomDictionaryTrainingMerge.maxSamples+ self.trainingSampleCount >= CustomDictionaryTrainingMerge.maxSamples}private var canAddTrainedReplacement: Bool {!self.normalizedTrainingReplacement.isEmpty &&!self.trainingVariants.isEmpty &&!self.isTrainingRecording &&- !self.isTrainingProcessing+ !self.isTrainingProcessing &&+ self.trainingFinalOutputIsReady}private var trainedReplacementButtonTitle: String {@@ -195,6 +227,12 @@ struct CustomDictionaryView: View {self.trainingFinalOutputIsReady && self.canAddTrainedReplacement}+ private var shouldPulseTrainedReplacementButton: Bool {+ self.shouldEmphasizeTrainedReplacementButton &&+ !self.isTrainedReplacementButtonHovered &&+ !self.reduceMotion+ }+private var manualTriggers: [String] {CustomDictionaryManualEntry.normalizedTriggers(self.manualTriggerChips + [self.manualTriggerDraft])}@@ -300,6 +338,8 @@ struct CustomDictionaryView: View {self.entries = SettingsStore.shared.customDictionaryEntries}.onDisappear {+ self.isAutomaticTrainingEnabled = false+ DictionaryTrainingEndpointMonitor.shared.stop()guard self.isTrainingRecording else { return }Task { @MainActor inawait self.stopTrainingSample()@@ -501,18 +541,28 @@ struct CustomDictionaryView: View {.frame(maxWidth: .infinity).frame(height: 38)}- .fluidButton(.accent, size: .small)+ .fluidButton(self.shouldEmphasizeTrainedReplacementButton ? .accent : .compact, size: .small).disabled(!self.canAddTrainedReplacement)- .opacity(self.canAddTrainedReplacement ? 1 : 0.45)+ .opacity(self.canAddTrainedReplacement ? 1 : 0.62).overlay(self.trainedReplacementButtonReadyOutline).shadow(- color: self.shouldEmphasizeTrainedReplacementButton ? self.theme.palette.success.opacity(0.18) : .clear,- radius: self.shouldEmphasizeTrainedReplacementButton ? 14 : 0,+ color: self.shouldEmphasizeTrainedReplacementButton+ ? self.theme.palette.accent.opacity(self.isTrainedReplacementGlowExpanded ? 0.34 : 0.14)+ : .clear,+ radius: self.shouldEmphasizeTrainedReplacementButton+ ? (self.isTrainedReplacementGlowExpanded ? 18 : 8)+ : 0,x: 0,- y: 5+ y: 4)- .scaleEffect(self.shouldEmphasizeTrainedReplacementButton ? 1.006 : 1)- .animation(.spring(response: 0.28, dampingFraction: 0.72), value: self.shouldEmphasizeTrainedReplacementButton)+ .onHover { self.isTrainedReplacementButtonHovered = $0 }+ .onAppear { self.updateTrainedReplacementGlow() }+ .onChange(of: self.shouldPulseTrainedReplacementButton) { _, _ in+ self.updateTrainedReplacementGlow()+ }+ }+ .task {+ await DictionaryTrainingEndpointMonitor.shared.prepare()}}@@ -656,17 +706,14 @@ struct CustomDictionaryView: View {Spacer()Button {- Task {- if self.isTrainingRecording {- await self.stopTrainingSample()- } else {- await self.startTrainingSample()- }- }+ Task { await self.toggleAutomaticTraining() }} label: {- Label(self.isTrainingRecording ? "Stop" : "Record", systemImage: self.isTrainingRecording ? "stop.fill" : "mic.fill")+ Label(+ self.trainingRecorderButtonTitle,+ systemImage: self.trainingRecorderIsStop ? "stop.fill" : "mic.fill"+ )}- .fluidButton(self.isTrainingRecording ? .destructive : .accent, size: .small)+ .fluidButton(self.trainingRecorderIsStop ? .destructive : .accent, size: .small).disabled(!self.canUseTrainingRecorderButton).opacity(self.canUseTrainingRecorderButton ? 1 : 0.45)}@@ -1579,6 +1626,20 @@ struct CustomDictionaryView: View {NotificationCenter.default.post(name: .parakeetVocabularyDidChange, object: nil)}+ private func updateTrainedReplacementGlow() {+ guard self.shouldPulseTrainedReplacementButton else {+ withAnimation(.easeOut(duration: 0.16)) {+ self.isTrainedReplacementGlowExpanded = false+ }+ return+ }++ self.isTrainedReplacementGlowExpanded = false+ withAnimation(.easeInOut(duration: 1.6).repeatForever(autoreverses: true)) {+ self.isTrainedReplacementGlowExpanded = true+ }+ }+private func addReplacementEntry(_ entry: SettingsStore.CustomDictionaryEntry) {self.entries.insert(entry, at: 0)self.saveEntries()@@ -1770,16 +1831,28 @@ struct CustomDictionaryView: View {self.isBoostWordEditorPresented = false}- private func beginTrainingReplacement() {- guard self.canStartTraining else { return }- self.isTrainingActive = true- self.trainingHasError = false- self.trainingStatusMessage = ""- Task { await DictionaryTrainingEndpointMonitor.shared.prepare() }+ private func toggleAutomaticTraining() async {+ if self.isAutomaticTrainingEnabled {+ self.isAutomaticTrainingEnabled = false+ if self.isTrainingRecording {+ await self.stopTrainingSample()+ }+ return+ }++ if self.canRetryTrainingAfterMaximum {+ self.resetTrainingVerificationAttempts()+ }+ guard self.canRecordTrainingSample else { return }+ self.isAutomaticTrainingEnabled = true+ await self.startTrainingSample()}private func startTrainingSample() async {- guard self.canRecordTrainingSample else { return }+ guard self.isAutomaticTrainingEnabled, self.canRecordTrainingSample else {+ self.isAutomaticTrainingEnabled = false+ return+ }self.isTrainingActive = trueself.trainingHasError = falseself.trainingStatusMessage = ""@@ -1792,6 +1865,7 @@ struct CustomDictionaryView: View {if !self.asr.isRunning {self.isTrainingRecording = falseself.trainingStopRequestedDuringStart = false+ self.isAutomaticTrainingEnabled = falseself.trainingHasError = trueself.trainingStatusMessage = "Couldn't start recording. Check microphone access and try again."return@@ -1822,7 +1896,7 @@ struct CustomDictionaryView: View {}private func handleAutomaticTrainingSpeechEnd() {- guard self.isTrainingRecording else { return }+ guard self.isAutomaticTrainingEnabled, self.isTrainingRecording else { return }Task { await self.stopTrainingSample() }}@@ -1839,6 +1913,30 @@ struct CustomDictionaryView: View {let transcript = await self.asr.stop(forDictionaryTraining: true)self.isTrainingProcessing = falseself.addTrainingVariant(from: transcript)+ await self.continueAutomaticTrainingIfNeeded()+ }++ private func continueAutomaticTrainingIfNeeded() async {+ guard self.isAutomaticTrainingEnabled,+ !self.trainingFinalOutputIsReady,+ !self.trainingAlreadyCorrectWithoutReplacement,+ self.trainingSampleCount < CustomDictionaryTrainingMerge.maxSamples+ else {+ self.isAutomaticTrainingEnabled = false+ return+ }++ await Task.yield()+ await self.startTrainingSample()+ }++ private func resetTrainingVerificationAttempts() {+ self.trainingSampleCount = 0+ self.lastTrainingOutput = ""+ self.lastTrainingOutputIsCovered = false+ self.consecutiveCoveredCaptures = 0+ self.trainingStatusMessage = ""+ self.trainingHasError = false}private func addTrainingVariant(from transcript: String) {@@ -1949,6 +2047,8 @@ struct CustomDictionaryView: View {}private func resetTraining(statusMessage: String = "Type the correct text.") {+ self.isAutomaticTrainingEnabled = false+ DictionaryTrainingEndpointMonitor.shared.stop()self.trainingReplacement = ""self.trainingVariants = []self.trainingSampleCount = 0diff --git a/Sources/Fluid/Views/AutomaticDictionaryCorrectionOverlay.swift b/Sources/Fluid/Views/AutomaticDictionaryCorrectionOverlay.swiftindex 02281178..edf27fe4 100644--- a/Sources/Fluid/Views/AutomaticDictionaryCorrectionOverlay.swift+++ b/Sources/Fluid/Views/AutomaticDictionaryCorrectionOverlay.swift@@ -202,6 +202,7 @@ final class DictionaryCorrectionOverlayController {private struct AutomaticDictionaryCorrectionOverlayView: View {@ObservedObject var session: AutomaticDictionaryTrainingSession+ @ObservedObject private var settings = SettingsStore.sharedlet displayDuration: TimeIntervallet onDismiss: () -> Void@@ -210,7 +211,7 @@ private struct AutomaticDictionaryCorrectionOverlayView: View {@State private var isDismissHovered = false@State private var progress: CGFloat = 1- private var accent: Color { SettingsStore.shared.accentColor }+ private var accent: Color { self.settings.accentColor }var body: some View {Group {@@ -435,7 +436,7 @@ private struct AutomaticDictionaryCorrectionOverlayView: View {ZStack(alignment: .leading) {Capsule().fill(Color.white.opacity(0.1))Capsule()- .fill(self.session.isReady ? Color.green.opacity(0.9) : self.accent)+ .fill(self.accent).frame(width: proxy.size.width * CGFloat(self.session.readinessFraction))}}@@ -472,7 +473,7 @@ private struct AutomaticDictionaryCorrectionOverlayView: View {if self.session.isReady {Label("Ready", systemImage: "checkmark.circle.fill").font(.system(size: 10.5, weight: .semibold))- .foregroundStyle(Color.green.opacity(0.9))+ .foregroundStyle(self.accent)}}.padding(.horizontal, 10)@@ -550,7 +551,13 @@ private struct CorrectionOverlayActionButton: View {var isReady = falselet action: () -> Void+ @Environment(\.accessibilityReduceMotion) private var reduceMotion@State private var isHovered = false+ @State private var isGlowExpanded = false++ private var shouldPulse: Bool {+ self.isReady && self.isEnabled && !self.isHovered && !self.reduceMotion+ }var body: some View {Button(action: self.action) {@@ -564,6 +571,10 @@ private struct CorrectionOverlayActionButton: View {.buttonStyle(.plain).disabled(!self.isEnabled).onHover { self.isHovered = $0 }+ .onAppear { self.updateGlow() }+ .onChange(of: self.shouldPulse) { _, _ in+ self.updateGlow()+ }}private var background: some View {@@ -573,21 +584,31 @@ private struct CorrectionOverlayActionButton: View {RoundedRectangle(cornerRadius: 8, style: .continuous).strokeBorder(self.borderColor, lineWidth: self.isReady ? 1.5 : 1))- .shadow(color: self.isReady ? Color.green.opacity(0.2) : .clear, radius: 10, y: 3)+ .shadow(+ color: self.isReady ? self.accent.opacity(self.isGlowExpanded ? 0.34 : 0.14) : .clear,+ radius: self.isReady ? (self.isGlowExpanded ? 16 : 7) : 0,+ y: 3+ )}private var fillColor: Color {+ guard self.isEnabled else {+ return Color.white.opacity(0.045)+ }switch self.style {case .accent:- return self.accent.opacity(self.isEnabled ? (self.isHovered ? 1 : 0.9) : 0.25)+ return self.accent.opacity(self.isHovered ? 1 : 0.9)case .secondary:return Color.white.opacity(self.isHovered ? 0.1 : 0.045)}}private var borderColor: Color {+ guard self.isEnabled else {+ return Color.white.opacity(0.1)+ }if self.isReady {- return Color.green.opacity(0.75)+ return self.accent.opacity(0.78)}switch self.style {case .accent:@@ -596,6 +617,20 @@ private struct CorrectionOverlayActionButton: View {return Color.white.opacity(self.isHovered ? 0.28 : 0.16)}}++ private func updateGlow() {+ guard self.shouldPulse else {+ withAnimation(.easeOut(duration: 0.16)) {+ self.isGlowExpanded = false+ }+ return+ }++ self.isGlowExpanded = false+ withAnimation(.easeInOut(duration: 1.6).repeatForever(autoreverses: true)) {+ self.isGlowExpanded = true+ }+ }}private struct CorrectionOverlayRecordButton: View {