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

feat(dictionary): add circular training progress

altic-dev46c06add0b3d
diff --git a/Sources/Fluid/Services/AutomaticDictionaryTrainingSession.swift b/Sources/Fluid/Services/AutomaticDictionaryTrainingSession.swift
index 6df0ff08..f96b1ad5 100644
--- a/Sources/Fluid/Services/AutomaticDictionaryTrainingSession.swift
+++ b/Sources/Fluid/Services/AutomaticDictionaryTrainingSession.swift
@@ -64,10 +64,6 @@ final class AutomaticDictionaryTrainingSession: ObservableObject {
return min(self.consecutiveCoveredCaptures, CustomDictionaryTrainingMerge.readyCoveredCount)
}
- var readinessFraction: Double {
- Double(self.readinessProgress) / Double(CustomDictionaryTrainingMerge.readyCoveredCount)
- }
-
var isReady: Bool {
self.readinessProgress >= CustomDictionaryTrainingMerge.readyCoveredCount
}
@@ -117,23 +113,6 @@ final class AutomaticDictionaryTrainingSession: ObservableObject {
}
}
- var trainingHeadline: String {
- if self.isReady {
- return "FluidVoice understands you"
- }
- return self.sampleCount == 0 ? "Say it naturally" : "Say it again"
- }
-
- var trainingDetail: String {
- if self.isReady {
- return "FluidVoice got it right 3 times. Add it now, or keep training."
- }
- if self.sampleCount >= CustomDictionaryTrainingMerge.maxSamples {
- 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."
- }
-
func beginTraining() {
guard self.screen == .choice else { return }
self.onInteraction?()
diff --git a/Sources/Fluid/UI/CustomDictionaryView.swift b/Sources/Fluid/UI/CustomDictionaryView.swift
index 210b9ff5..c178ffa5 100644
--- a/Sources/Fluid/UI/CustomDictionaryView.swift
+++ b/Sources/Fluid/UI/CustomDictionaryView.swift
@@ -66,18 +66,6 @@ struct CustomDictionaryView: View {
self.trainingReplacement.trimmingCharacters(in: .whitespacesAndNewlines)
}
- private var trainingProgressText: String {
- let count = self.trainingSampleCount
- return "\(count) \(count == 1 ? "sample" : "samples") · up to \(CustomDictionaryTrainingMerge.maxSamples)"
- }
-
- private var shouldShowTrainingStatus: Bool {
- self.trainingHasError || (
- !self.trainingStatusMessage.isEmpty &&
- self.trainingStatusMessage != "Type the correct text."
- )
- }
-
private var canUseTrainingRecorderButton: Bool {
if self.isAutomaticTrainingEnabled {
return true
@@ -97,72 +85,6 @@ struct CustomDictionaryView: View {
return self.canRetryTrainingAfterMaximum ? "Try Again" : "Start"
}
- private var trainingRecorderTitle: String {
- if self.trainingStopRequestedDuringStart {
- return "Stopping..."
- }
- if self.isTrainingProcessing {
- return "Working..."
- }
- if self.isTrainingStarting {
- return "Starting..."
- }
- if self.isTrainingRecording {
- return "Listening..."
- }
- if self.trainingFinalOutputIsReady {
- return "Ready to add"
- }
- if self.normalizedTrainingReplacement.isEmpty {
- return "Start training"
- }
- return self.trainingSampleCount == 0 ? "Start once" : "Keep going"
- }
-
- private var trainingRecorderDetail: String {
- 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 {
- guard !self.lastTrainingOutput.isEmpty else { return "Record to check" }
- if self.trainingAlreadyCorrectWithoutReplacement {
- return "Already correct"
- }
- if self.trainingFinalOutputIsReady {
- return "Ready to add"
- }
- return "\(self.trainingReadinessProgress)/\(CustomDictionaryTrainingMerge.readyCoveredCount) understood"
- }
-
- private var trainingRecorderStatusColor: Color {
- self.trainingFinalOutputIsReady || self.trainingAlreadyCorrectWithoutReplacement
- ? self.theme.palette.success
- : self.theme.palette.secondaryText
- }
-
- private var trainingRecorderFillColor: Color {
- self.trainingFinalOutputIsReady || self.trainingAlreadyCorrectWithoutReplacement
- ? self.theme.palette.success
- : self.theme.palette.accent
- }
-
- private var trainingRecorderFillFraction: Double {
- guard !self.lastTrainingOutput.isEmpty else { return 0 }
- if self.trainingAlreadyCorrectWithoutReplacement {
- return 1
- }
- return Double(self.trainingReadinessProgress) / Double(CustomDictionaryTrainingMerge.readyCoveredCount)
- }
-
private var trainingFinalOutputIsReady: Bool {
!self.trainingAlreadyCorrectWithoutReplacement &&
self.trainingOutputIsCovered &&
@@ -537,9 +459,14 @@ struct CustomDictionaryView: View {
Button {
self.addTrainedReplacement()
} label: {
- Label(self.trainedReplacementButtonTitle, systemImage: self.trainingAlreadyCorrectWithoutReplacement ? "checkmark" : "plus")
- .frame(maxWidth: .infinity)
- .frame(height: 38)
+ Label(
+ self.trainedReplacementButtonTitle,
+ systemImage: self.shouldEmphasizeTrainedReplacementButton
+ ? "sparkles"
+ : (self.trainingAlreadyCorrectWithoutReplacement ? "checkmark" : "plus")
+ )
+ .frame(maxWidth: .infinity)
+ .frame(height: 38)
}
.fluidButton(self.shouldEmphasizeTrainedReplacementButton ? .accent : .compact, size: .small)
.disabled(!self.canAddTrainedReplacement)
@@ -678,102 +605,90 @@ struct CustomDictionaryView: View {
}
private var trainingRecorderPanel: some View {
- HStack(alignment: .center, spacing: self.theme.metrics.spacing.md) {
- VStack(alignment: .leading, spacing: 6) {
- Text(self.trainingRecorderTitle)
- .font(self.theme.typography.bodySmallStrong)
-
- Text(self.trainingRecorderDetail)
- .font(self.theme.typography.caption)
- .foregroundStyle(self.theme.palette.secondaryText)
- .lineLimit(2)
-
- self.trainingRecorderProgressRow
-
- HStack(spacing: 7) {
- Text(self.trainingRecorderStatusText)
- .font(self.theme.typography.captionStrong)
- .foregroundStyle(self.trainingRecorderStatusColor)
- .lineLimit(1)
+ VStack(alignment: .leading, spacing: self.theme.metrics.spacing.md) {
+ Text("Teach FluidVoice your pronunciation")
+ .font(self.theme.typography.bodySmallStrong)
- Text("· \(self.trainingProgressText) recorded")
- .font(self.theme.typography.caption)
- .foregroundStyle(self.theme.palette.tertiaryText)
- .lineLimit(1)
+ if self.trainingFinalOutputIsReady {
+ Label("FluidVoice got it right 3 times in a row.", systemImage: "checkmark.circle.fill")
+ .font(self.theme.typography.captionStrong)
+ .foregroundStyle(self.theme.palette.accent)
+ } else {
+ VStack(alignment: .leading, spacing: 7) {
+ self.trainingInstruction(number: 1, text: "Press Start once.")
+ self.trainingInstruction(number: 2, text: "Say the word, then pause. FluidVoice captures it and listens again.")
+ self.trainingInstruction(number: 3, text: "Repeat naturally until the circle reaches 3/3.")
}
}
- Spacer()
-
- Button {
- Task { await self.toggleAutomaticTraining() }
- } label: {
- Label(
- self.trainingRecorderButtonTitle,
- systemImage: self.trainingRecorderIsStop ? "stop.fill" : "mic.fill"
+ HStack(spacing: self.theme.metrics.spacing.md) {
+ DictionaryTrainingReadinessRing(
+ progress: self.trainingReadinessProgress,
+ total: CustomDictionaryTrainingMerge.readyCoveredCount,
+ isReady: self.trainingFinalOutputIsReady || self.trainingAlreadyCorrectWithoutReplacement
)
+
+ Text(self.trainingReadinessCaption)
+ .font(self.theme.typography.captionStrong)
+ .foregroundStyle(
+ self.trainingFinalOutputIsReady
+ ? self.theme.palette.accent
+ : self.theme.palette.secondaryText
+ )
+ .fixedSize(horizontal: false, vertical: true)
+
+ Spacer()
+
+ Button {
+ Task { await self.toggleAutomaticTraining() }
+ } label: {
+ Label(
+ self.trainingRecorderButtonTitle,
+ systemImage: self.trainingRecorderIsStop ? "stop.fill" : "mic.fill"
+ )
+ }
+ .fluidButton(self.trainingRecorderIsStop ? .destructive : .accent, size: .small)
+ .disabled(!self.canUseTrainingRecorderButton)
+ .opacity(self.canUseTrainingRecorderButton ? 1 : 0.45)
}
- .fluidButton(self.trainingRecorderIsStop ? .destructive : .accent, size: .small)
- .disabled(!self.canUseTrainingRecorderButton)
- .opacity(self.canUseTrainingRecorderButton ? 1 : 0.45)
}
.padding(self.theme.metrics.spacing.md)
- .background(self.trainingRecorderBackground)
- }
-
- private var trainingRecorderBackground: some View {
- GeometryReader { proxy in
- let fillWidth = proxy.size.width * min(max(self.trainingRecorderFillFraction, 0), 1)
-
+ .background(
RoundedRectangle(cornerRadius: self.theme.metrics.corners.md, style: .continuous)
.fill(self.theme.palette.contentBackground.opacity(0.5))
- .overlay(alignment: .leading) {
- RoundedRectangle(cornerRadius: self.theme.metrics.corners.md, style: .continuous)
- .fill(self.trainingRecorderFillColor.opacity(0.16))
- .frame(width: fillWidth)
- }
.overlay(
RoundedRectangle(cornerRadius: self.theme.metrics.corners.md, style: .continuous)
- .stroke(self.trainingRecorderBorderColor, lineWidth: 1)
+ .stroke(
+ self.trainingFinalOutputIsReady
+ ? self.theme.palette.accent.opacity(0.26)
+ : self.theme.palette.cardBorder.opacity(0.25),
+ lineWidth: 1
+ )
)
- .animation(.easeOut(duration: 0.18), value: self.trainingRecorderFillFraction)
- }
- .allowsHitTesting(false)
- }
-
- private var trainingRecorderBorderColor: Color {
- self.trainingFinalOutputIsReady || self.trainingAlreadyCorrectWithoutReplacement
- ? self.theme.palette.success.opacity(0.28)
- : self.theme.palette.cardBorder.opacity(0.25)
+ )
}
- private var trainingRecorderProgressBar: some View {
- GeometryReader { proxy in
- let width = proxy.size.width * min(max(self.trainingRecorderFillFraction, 0), 1)
-
- ZStack(alignment: .leading) {
- Capsule(style: .continuous)
- .fill(self.theme.palette.cardBorder.opacity(0.35))
-
- Capsule(style: .continuous)
- .fill(self.trainingRecorderFillColor)
- .frame(width: width)
- }
+ private var trainingReadinessCaption: String {
+ if self.trainingAlreadyCorrectWithoutReplacement {
+ return "Already correct. No replacement is needed."
+ }
+ if self.trainingFinalOutputIsReady {
+ return "Ready. Add Replacement is unlocked."
}
- .frame(height: 5)
- .animation(.easeOut(duration: 0.18), value: self.trainingRecorderFillFraction)
- .accessibilityHidden(true)
+ let remaining = max(0, CustomDictionaryTrainingMerge.readyCoveredCount - self.trainingReadinessProgress)
+ return "\(remaining) correct \(remaining == 1 ? "try" : "tries") to unlock Add Replacement."
}
- private var trainingRecorderProgressRow: some View {
- HStack(spacing: self.theme.metrics.spacing.sm) {
- self.trainingRecorderProgressBar
-
- Text("\(self.trainingReadinessProgress)/\(CustomDictionaryTrainingMerge.readyCoveredCount)")
+ private func trainingInstruction(number: Int, text: String) -> some View {
+ HStack(alignment: .firstTextBaseline, spacing: 8) {
+ Text("\(number)")
.font(self.theme.typography.captionStrong)
- .foregroundStyle(self.trainingRecorderStatusColor)
- .monospacedDigit()
- .frame(width: 34, alignment: .trailing)
+ .foregroundStyle(self.theme.palette.accent)
+ .frame(width: 16, alignment: .center)
+
+ Text(text)
+ .font(self.theme.typography.caption)
+ .foregroundStyle(self.theme.palette.secondaryText)
}
}
@@ -856,16 +771,12 @@ struct CustomDictionaryView: View {
@ViewBuilder
private var trainingFooter: some View {
- if self.shouldShowTrainingStatus || self.isTrainingActive || !self.trainingVariants.isEmpty {
+ if self.trainingHasError || self.isTrainingActive || !self.trainingVariants.isEmpty {
HStack(spacing: self.theme.metrics.spacing.sm) {
if self.trainingHasError {
Label(self.trainingStatusMessage, systemImage: "exclamationmark.triangle.fill")
.font(self.theme.typography.caption)
.foregroundStyle(self.theme.palette.warning)
- } else if self.shouldShowTrainingStatus {
- Text(self.trainingStatusMessage)
- .font(self.theme.typography.caption)
- .foregroundStyle(self.theme.palette.secondaryText)
}
if self.isTrainingActive || !self.trainingVariants.isEmpty || !self.normalizedTrainingReplacement.isEmpty {
@@ -2306,7 +2217,7 @@ private enum DictionaryComposerMode: CaseIterable, Identifiable {
var detail: String {
switch self {
case .train:
- return "Say it a few times so FluidVoice can catch the versions it hears."
+ return "Teach a word by speaking it."
case .manual:
return "Type the misheard text and the spelling you want."
}
@@ -2562,6 +2473,51 @@ private struct ReplacementConfirmationToast: View {
}
}
+private struct DictionaryTrainingReadinessRing: View {
+ let progress: Int
+ let total: Int
+ let isReady: Bool
+
+ @Environment(\.theme) private var theme
+
+ private var fraction: Double {
+ guard self.total > 0 else { return 0 }
+ return min(max(Double(self.progress) / Double(self.total), 0), 1)
+ }
+
+ var body: some View {
+ ZStack {
+ Circle()
+ .stroke(self.theme.palette.cardBorder.opacity(0.62), lineWidth: 8)
+
+ Circle()
+ .trim(from: 0, to: self.fraction)
+ .stroke(
+ self.theme.palette.accent,
+ style: StrokeStyle(lineWidth: 8, lineCap: .round)
+ )
+ .rotationEffect(.degrees(-90))
+
+ VStack(spacing: 1) {
+ Text("\(self.progress)/\(self.total)")
+ .font(self.theme.typography.sectionTitle)
+ .foregroundStyle(self.isReady ? self.theme.palette.accent : self.theme.palette.primaryText)
+ .monospacedDigit()
+
+ Text(self.isReady ? "Ready" : "correct")
+ .font(self.theme.typography.captionSmall)
+ .foregroundStyle(self.theme.palette.secondaryText)
+ }
+ }
+ .frame(width: 92, height: 92)
+ .shadow(color: self.isReady ? self.theme.palette.accent.opacity(0.2) : .clear, radius: 10)
+ .animation(.easeOut(duration: 0.24), value: self.progress)
+ .accessibilityElement(children: .ignore)
+ .accessibilityLabel("Training progress")
+ .accessibilityValue("\(self.progress) of \(self.total) correct")
+ }
+}
+
private struct TrainingVariantChip: View {
let number: Int
let variant: String
diff --git a/Sources/Fluid/Views/AutomaticDictionaryCorrectionOverlay.swift b/Sources/Fluid/Views/AutomaticDictionaryCorrectionOverlay.swift
index edf27fe4..b2ed3845 100644
--- a/Sources/Fluid/Views/AutomaticDictionaryCorrectionOverlay.swift
+++ b/Sources/Fluid/Views/AutomaticDictionaryCorrectionOverlay.swift
@@ -286,28 +286,49 @@ private struct AutomaticDictionaryCorrectionOverlayView: View {
self.correctionPair
- HStack(alignment: .center, spacing: 12) {
- VStack(alignment: .leading, spacing: 4) {
- Text(self.session.trainingHeadline)
- .font(.system(size: 13, weight: .semibold))
- .foregroundStyle(.white.opacity(0.94))
-
- Text(self.session.trainingDetail)
- .font(.system(size: 10.5))
- .foregroundStyle(.white.opacity(0.56))
- .lineLimit(2)
-
- self.readinessRow
+ VStack(alignment: .leading, spacing: 9) {
+ Text("Teach FluidVoice your pronunciation")
+ .font(.system(size: 13, weight: .semibold))
+ .foregroundStyle(.white.opacity(0.94))
+
+ if self.session.isReady {
+ Label("FluidVoice got it right 3 times in a row.", systemImage: "checkmark.circle.fill")
+ .font(.system(size: 10.5, weight: .medium))
+ .foregroundStyle(self.accent)
+ } else {
+ VStack(alignment: .leading, spacing: 5) {
+ self.trainingInstruction(number: 1, text: "Press Start once.")
+ self.trainingInstruction(
+ number: 2,
+ text: "Say the word, then pause. FluidVoice captures it and listens again."
+ )
+ self.trainingInstruction(number: 3, text: "Repeat naturally until the circle reaches 3/3.")
+ }
}
- .frame(maxWidth: .infinity, alignment: .leading)
- CorrectionOverlayRecordButton(
- title: self.session.recordButtonTitle,
- isStop: self.session.recordButtonIsStop,
- isEnabled: self.session.canUseRecordButton,
- accent: self.accent,
- action: self.session.toggleCapture
- )
+ HStack(spacing: 12) {
+ CorrectionOverlayReadinessRing(
+ progress: self.session.readinessProgress,
+ total: CustomDictionaryTrainingMerge.readyCoveredCount,
+ isReady: self.session.isReady,
+ accent: self.accent
+ )
+
+ Text(self.overlayReadinessCaption)
+ .font(.system(size: 10.5, weight: .medium))
+ .foregroundStyle(self.session.isReady ? self.accent : .white.opacity(0.58))
+ .fixedSize(horizontal: false, vertical: true)
+
+ Spacer(minLength: 8)
+
+ CorrectionOverlayRecordButton(
+ title: self.session.recordButtonTitle,
+ isStop: self.session.recordButtonIsStop,
+ isEnabled: self.session.canUseRecordButton,
+ accent: self.accent,
+ action: self.session.toggleCapture
+ )
+ }
}
.padding(10)
.background(self.panelSurface)
@@ -318,19 +339,19 @@ private struct AutomaticDictionaryCorrectionOverlayView: View {
self.capturedVariantsRow
}
- if self.session.capturePhase == .idle, !self.session.statusMessage.isEmpty {
+ if self.session.capturePhase == .idle, self.session.hasError, !self.session.statusMessage.isEmpty {
Label(
self.session.statusMessage,
- systemImage: self.session.hasError ? "exclamationmark.triangle.fill" : "checkmark.circle"
+ systemImage: "exclamationmark.triangle.fill"
)
.font(.system(size: 10.5, weight: .medium))
- .foregroundStyle(self.session.hasError ? Color.red.opacity(0.9) : .white.opacity(0.58))
+ .foregroundStyle(Color.red.opacity(0.9))
.lineLimit(1)
}
CorrectionOverlayActionButton(
title: "Add Replacement",
- systemImage: "plus",
+ systemImage: self.session.isReady ? "sparkles" : "plus",
style: .accent,
accent: self.accent,
isEnabled: self.session.canSave,
@@ -341,6 +362,31 @@ private struct AutomaticDictionaryCorrectionOverlayView: View {
.transition(.opacity.combined(with: .move(edge: .bottom)))
}
+ private var overlayReadinessCaption: String {
+ if self.session.isReady {
+ return "Ready. Add Replacement is unlocked."
+ }
+ let remaining = max(
+ 0,
+ CustomDictionaryTrainingMerge.readyCoveredCount - self.session.readinessProgress
+ )
+ return "\(remaining) correct \(remaining == 1 ? "try" : "tries") to unlock Add Replacement."
+ }
+
+ private func trainingInstruction(number: Int, text: String) -> some View {
+ HStack(alignment: .firstTextBaseline, spacing: 7) {
+ Text("\(number)")
+ .font(.system(size: 10.5, weight: .semibold, design: .rounded))
+ .foregroundStyle(self.accent)
+ .frame(width: 14)
+
+ Text(text)
+ .font(.system(size: 10.5))
+ .foregroundStyle(.white.opacity(0.58))
+ .fixedSize(horizontal: false, vertical: true)
+ }
+ }
+
private var successContent: some View {
HStack(spacing: 12) {
ZStack {
@@ -430,32 +476,6 @@ private struct AutomaticDictionaryCorrectionOverlayView: View {
.frame(maxWidth: .infinity, alignment: .leading)
}
- private var readinessRow: some View {
- HStack(spacing: 8) {
- GeometryReader { proxy in
- ZStack(alignment: .leading) {
- Capsule().fill(Color.white.opacity(0.1))
- Capsule()
- .fill(self.accent)
- .frame(width: proxy.size.width * CGFloat(self.session.readinessFraction))
- }
- }
- .frame(height: 4)
-
- Text("\(self.session.readinessProgress)/\(CustomDictionaryTrainingMerge.readyCoveredCount)")
- .font(.system(size: 10, weight: .semibold, design: .rounded))
- .foregroundStyle(.white.opacity(0.58))
- .monospacedDigit()
- .frame(width: 24, alignment: .trailing)
-
- Text("\(self.session.sampleCount)/\(CustomDictionaryTrainingMerge.maxSamples)")
- .font(.system(size: 10, weight: .medium, design: .rounded))
- .foregroundStyle(.white.opacity(0.38))
- .monospacedDigit()
- .frame(width: 30, alignment: .trailing)
- }
- }
-
private var finalOutputRow: some View {
HStack(spacing: 8) {
VStack(alignment: .leading, spacing: 2) {
@@ -537,6 +557,50 @@ private struct AutomaticDictionaryCorrectionOverlayView: View {
}
}
+private struct CorrectionOverlayReadinessRing: View {
+ let progress: Int
+ let total: Int
+ let isReady: Bool
+ let accent: Color
+
+ private var fraction: Double {
+ guard self.total > 0 else { return 0 }
+ return min(max(Double(self.progress) / Double(self.total), 0), 1)
+ }
+
+ var body: some View {
+ ZStack {
+ Circle()
+ .stroke(Color.white.opacity(0.16), lineWidth: 7)
+
+ Circle()
+ .trim(from: 0, to: self.fraction)
+ .stroke(
+ self.accent,
+ style: StrokeStyle(lineWidth: 7, lineCap: .round)
+ )
+ .rotationEffect(.degrees(-90))
+
+ VStack(spacing: 0) {
+ Text("\(self.progress)/\(self.total)")
+ .font(.system(size: 16, weight: .bold, design: .rounded))
+ .foregroundStyle(self.isReady ? self.accent : .white.opacity(0.92))
+ .monospacedDigit()
+
+ Text(self.isReady ? "Ready" : "correct")
+ .font(.system(size: 8.5, weight: .medium))
+ .foregroundStyle(.white.opacity(0.46))
+ }
+ }
+ .frame(width: 76, height: 76)
+ .shadow(color: self.isReady ? self.accent.opacity(0.22) : .clear, radius: 9)
+ .animation(.easeOut(duration: 0.24), value: self.progress)
+ .accessibilityElement(children: .ignore)
+ .accessibilityLabel("Training progress")
+ .accessibilityValue("\(self.progress) of \(self.total) correct")
+ }
+}
+
private struct CorrectionOverlayActionButton: View {
enum Style {
case accent