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): tolerate duplicate entry ids
altic-devcb5809976033
diff --git a/Sources/Fluid/Services/FluidAudioProvider.swift b/Sources/Fluid/Services/FluidAudioProvider.swiftindex cee8a4bd..c9f5c0e8 100644--- a/Sources/Fluid/Services/FluidAudioProvider.swift+++ b/Sources/Fluid/Services/FluidAudioProvider.swift@@ -10,6 +10,15 @@ final class FluidAudioProvider: TranscriptionProvider {let label: String}+ static func dictionaryLabels(+ from entries: [SettingsStore.CustomDictionaryEntry]+ ) -> [UUID: String] {+ Dictionary(+ entries.map { ($0.id, $0.replacement) },+ uniquingKeysWith: { _, last in last }+ )+ }+let name = "FluidAudio (Apple Silicon Optimized)"/// Whether this provider is supported on the current system.@@ -267,8 +276,8 @@ final class FluidAudioProvider: TranscriptionProvider {private func transcribeFinalResult(_ samples: [Float], manager: AsrManager) async throws -> ASRTranscriptionResult {let matchingEnabled = SettingsStore.shared.pronunciationMatchingEnabled && samples.count <= 16_000 * 15- let dictionaryLabels = Dictionary(- uniqueKeysWithValues: SettingsStore.shared.customDictionaryEntries.map { ($0.id, $0.replacement) }+ let dictionaryLabels = Self.dictionaryLabels(+ from: SettingsStore.shared.customDictionaryEntries)let profiles: [PronunciationDictionaryProfile]if matchingEnabled {diff --git a/Tests/FluidDictationIntegrationTests/DictationE2ETests.swift b/Tests/FluidDictationIntegrationTests/DictationE2ETests.swiftindex f8f031b5..dea25cac 100644--- a/Tests/FluidDictationIntegrationTests/DictationE2ETests.swift+++ b/Tests/FluidDictationIntegrationTests/DictationE2ETests.swift@@ -309,6 +309,16 @@ final class DictationE2ETests: XCTestCase {}}+ func testPronunciationDictionaryLabelsUseLastDuplicateEntry() {+ let id = UUID()+ let labels = FluidAudioProvider.dictionaryLabels(from: [+ SettingsStore.CustomDictionaryEntry(id: id, triggers: ["old"], replacement: "Old"),+ SettingsStore.CustomDictionaryEntry(id: id, triggers: ["new"], replacement: "New"),+ ])++ XCTAssertEqual(labels, [id: "New"])+ }+func testCustomDictionaryReplacementMatchesPunctuationTriggers() {defer { ASRService.invalidateDictionaryCache() }let entry = SettingsStore.CustomDictionaryEntry(