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(dictation): add literal formatting toggle

altic-devb19765acf04b
diff --git a/Sources/Fluid/Persistence/BackupService.swift b/Sources/Fluid/Persistence/BackupService.swift
index 4261af6c..58795c47 100644
--- a/Sources/Fluid/Persistence/BackupService.swift
+++ b/Sources/Fluid/Persistence/BackupService.swift
@@ -76,6 +76,7 @@ struct SettingsBackupPayload: Codable, Equatable {
let fillerWords: [String]
let removeFillerWordsEnabled: Bool
let autoConvertPunctuationEnabled: Bool?
+ let literalDictationFormattingEnabled: Bool?
let punctuationDictionaryPrefix: String?
// swiftlint:disable:next discouraged_optional_collection
let punctuationDictionaryRules: [SettingsStore.PunctuationDictionaryRule]?
diff --git a/Sources/Fluid/Persistence/SettingsStore.swift b/Sources/Fluid/Persistence/SettingsStore.swift
index 2bb02d5d..bc100315 100644
--- a/Sources/Fluid/Persistence/SettingsStore.swift
+++ b/Sources/Fluid/Persistence/SettingsStore.swift
@@ -2953,6 +2953,7 @@ final class SettingsStore: ObservableObject {
fillerWords: self.fillerWords,
removeFillerWordsEnabled: self.removeFillerWordsEnabled,
autoConvertPunctuationEnabled: self.autoConvertPunctuationEnabled,
+ literalDictationFormattingEnabled: self.literalDictationFormattingEnabled,
punctuationDictionaryPrefix: self.punctuationDictionaryPrefix,
punctuationDictionaryRules: self.punctuationDictionaryRules,
gaavModeEnabled: self.gaavModeEnabled,
@@ -3072,6 +3073,9 @@ final class SettingsStore: ObservableObject {
if let autoConvertPunctuationEnabled = payload.autoConvertPunctuationEnabled {
self.autoConvertPunctuationEnabled = autoConvertPunctuationEnabled
}
+ if let literalDictationFormattingEnabled = payload.literalDictationFormattingEnabled {
+ self.literalDictationFormattingEnabled = literalDictationFormattingEnabled
+ }
if let punctuationDictionaryPrefix = payload.punctuationDictionaryPrefix {
self.punctuationDictionaryPrefix = punctuationDictionaryPrefix
}
@@ -3689,6 +3693,14 @@ final class SettingsStore: ObservableObject {
}
}
+ var literalDictationFormattingEnabled: Bool {
+ get { self.defaults.object(forKey: Keys.literalDictationFormattingEnabled) as? Bool ?? false }
+ set {
+ objectWillChange.send()
+ self.defaults.set(newValue, forKey: Keys.literalDictationFormattingEnabled)
+ }
+ }
+
static let defaultPunctuationDictionaryPrefix = "literal"
static let defaultPunctuationDictionaryRules: [PunctuationDictionaryRule] = [
@@ -4832,6 +4844,7 @@ private extension SettingsStore {
static let fillerWords = "FillerWords"
static let removeFillerWordsEnabled = "RemoveFillerWordsEnabled"
static let autoConvertPunctuationEnabled = "AutoConvertPunctuationEnabled"
+ static let literalDictationFormattingEnabled = "LiteralDictationFormattingEnabled"
static let punctuationDictionaryPrefix = "PunctuationDictionaryPrefix"
static let punctuationDictionaryRules = "PunctuationDictionaryRules"
diff --git a/Sources/Fluid/Services/ASRService+DictationLiteralFormatting.swift b/Sources/Fluid/Services/ASRService+DictationLiteralFormatting.swift
index 85331aba..6ae5729d 100644
--- a/Sources/Fluid/Services/ASRService+DictationLiteralFormatting.swift
+++ b/Sources/Fluid/Services/ASRService+DictationLiteralFormatting.swift
@@ -156,6 +156,8 @@ private enum DictationLiteralFormatter {
bundleID: String? = nil,
windowTitle: String? = nil
) -> String {
+ guard SettingsStore.shared.literalDictationFormattingEnabled else { return text }
+
let commandFormatted = self.applySlashCommandFormatting(text)
return self.applyMentionFormatting(
commandFormatted,
@@ -166,6 +168,7 @@ private enum DictationLiteralFormatter {
}
static func applySlashCommandFormatting(_ text: String) -> String {
+ guard SettingsStore.shared.literalDictationFormattingEnabled else { return text }
guard !text.isEmpty,
text.contains("/") || text.range(of: "slash", options: .caseInsensitive) != nil
else {
@@ -190,6 +193,7 @@ private enum DictationLiteralFormatter {
bundleID: String? = nil,
windowTitle: String? = nil
) -> String {
+ guard SettingsStore.shared.literalDictationFormattingEnabled else { return text }
guard !text.isEmpty,
text.range(of: "at ", options: .caseInsensitive) != nil ||
text.range(of: "tag ", options: .caseInsensitive) != nil ||
@@ -235,6 +239,7 @@ private enum DictationLiteralFormatter {
bundleID: String? = nil,
windowTitle: String? = nil
) -> String {
+ guard SettingsStore.shared.literalDictationFormattingEnabled else { return text }
guard text.last?.isHorizontalWhitespace == true else { return text }
let withoutTrailingWhitespace = self.removingTrailingHorizontalWhitespace(from: text)
diff --git a/Sources/Fluid/UI/CustomDictionaryView.swift b/Sources/Fluid/UI/CustomDictionaryView.swift
index 576ef89e..10060771 100644
--- a/Sources/Fluid/UI/CustomDictionaryView.swift
+++ b/Sources/Fluid/UI/CustomDictionaryView.swift
@@ -15,8 +15,6 @@ struct CustomDictionaryView: View {
@Environment(\.accessibilityReduceMotion) private var reduceMotion
@EnvironmentObject private var appServices: AppServices
- private var asr: ASRService { self.appServices.asr }
-
@State private var entries: [SettingsStore.CustomDictionaryEntry] = SettingsStore.shared.customDictionaryEntries
@State private var boostTerms: [ParakeetVocabularyStore.VocabularyConfig.Term] = []
@State private var editingEntry: SettingsStore.CustomDictionaryEntry?
@@ -2278,6 +2276,8 @@ struct CustomDictionaryView: View {
}
private extension CustomDictionaryView {
+ var asr: ASRService { self.appServices.asr }
+
var trainedReplacementButtonTitle: String {
self.trainingAlreadyCorrectWithoutReplacement ? "Nothing to Save" : "Add Replacement"
}
diff --git a/Sources/Fluid/UI/SettingsView.swift b/Sources/Fluid/UI/SettingsView.swift
index e2530106..46d3342d 100644
--- a/Sources/Fluid/UI/SettingsView.swift
+++ b/Sources/Fluid/UI/SettingsView.swift
@@ -939,6 +939,18 @@ struct SettingsView: View {
)
Divider().opacity(0.2)
+ self.optionToggleRow(
+ title: "Slash Commands & @ Formatting",
+ description: "When on, \"slash status\" becomes \"/status\"; \"tag Paul\", \"mention Paul\", \"at sign Paul\", and \"at the rate Paul\" become \"@Paul\". " +
+ "In chat apps, \"at Paul\" also works. Turn it off to leave all of these unchanged.",
+ isOn: Binding(
+ get: { SettingsStore.shared.literalDictationFormattingEnabled },
+ set: { SettingsStore.shared.literalDictationFormattingEnabled = $0 }
+ ),
+ allowsDescriptionWrapping: true
+ )
+ Divider().opacity(0.2)
+
self.optionToggleRow(
title: "Space Between Dictations",
description: "Add spacing so consecutive dictations chain without manually pressing the spacebar.",
@@ -1986,7 +1998,8 @@ struct SettingsView: View {
private func optionToggleRow(
title: String,
description: String,
- isOn: Binding<Bool>
+ isOn: Binding<Bool>,
+ allowsDescriptionWrapping: Bool = false
) -> some View {
HStack(alignment: .center) {
VStack(alignment: .leading, spacing: 2) {
@@ -1996,9 +2009,13 @@ struct SettingsView: View {
Text(description)
.font(self.theme.typography.bodySmall)
.foregroundStyle(self.settingsSecondaryText)
+ .fixedSize(horizontal: false, vertical: allowsDescriptionWrapping)
}
+ .frame(maxWidth: allowsDescriptionWrapping ? .infinity : nil, alignment: .leading)
- Spacer()
+ if !allowsDescriptionWrapping {
+ Spacer()
+ }
Toggle("", isOn: isOn)
.toggleStyle(.switch)
diff --git a/Tests/FluidDictationIntegrationTests/DictationE2ETests.swift b/Tests/FluidDictationIntegrationTests/DictationE2ETests.swift
index 393685bb..c748a169 100644
--- a/Tests/FluidDictationIntegrationTests/DictationE2ETests.swift
+++ b/Tests/FluidDictationIntegrationTests/DictationE2ETests.swift
@@ -20,6 +20,7 @@ final class DictationE2ETests: XCTestCase {
private let selectedModelByProviderKey = "SelectedModelByProvider"
private let customDictionaryEntriesKey = "CustomDictionaryEntries"
private let autoConvertPunctuationEnabledKey = "AutoConvertPunctuationEnabled"
+ private let literalDictationFormattingEnabledKey = "LiteralDictationFormattingEnabled"
private let punctuationDictionaryPrefixKey = "PunctuationDictionaryPrefix"
private let punctuationDictionaryRulesKey = "PunctuationDictionaryRules"
private let commandModeLinkedToGlobalKey = "CommandModeLinkedToGlobal"
@@ -354,6 +355,26 @@ final class DictationE2ETests: XCTestCase {
)
}
+ func testLiteralFormattingCanBeDisabled() {
+ self.withRestoredDefaults(keys: [self.literalDictationFormattingEnabledKey]) {
+ UserDefaults.standard.removeObject(forKey: self.literalDictationFormattingEnabledKey)
+ XCTAssertFalse(SettingsStore.shared.literalDictationFormattingEnabled)
+
+ UserDefaults.standard.set(false, forKey: self.literalDictationFormattingEnabledKey)
+
+ XCTAssertEqual(ASRService.applySlashCommandFormatting("slash compact"), "slash compact")
+ XCTAssertEqual(ASRService.applyMentionFormatting("mention Paul"), "mention Paul")
+ XCTAssertEqual(
+ ASRService.makeDictationLiteralOutputPlan(
+ for: "/compact ",
+ appName: "Codex",
+ bundleID: "com.openai.codex"
+ ).plainText,
+ "/compact "
+ )
+ }
+ }
+
func testMentionFormattingExplicitPhrasesWorkWithoutAppContext() {
XCTAssertEqual(
ASRService.applyMentionFormatting("tag Paul"),