diff --git a/TypeaheadAI.xcodeproj/project.pbxproj b/TypeaheadAI.xcodeproj/project.pbxproj index b1d2f5f..2c37211 100644 --- a/TypeaheadAI.xcodeproj/project.pbxproj +++ b/TypeaheadAI.xcodeproj/project.pbxproj @@ -119,6 +119,7 @@ 2BCF84352A9DD90F00359841 /* HistoryManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2BCF84342A9DD90F00359841 /* HistoryManager.swift */; }; 2BCF843A2A9DE6DA00359841 /* GeneralSettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2BCF84392A9DE6DA00359841 /* GeneralSettingsView.swift */; }; 2BD3821E2B2C4B2E00F96C19 /* CanSimulateEnter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2BD3821D2B2C4B2E00F96C19 /* CanSimulateEnter.swift */; }; + 2BD97C7E2B69FF57002570C1 /* WhisperKit in Frameworks */ = {isa = PBXBuildFile; productRef = 2BD97C7D2B69FF57002570C1 /* WhisperKit */; }; 2BDA45C32ABEE840006128BC /* MessageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2BDA45C22ABEE840006128BC /* MessageView.swift */; }; 2BDDB9892B27DDE100D52BF0 /* SwiftSoup in Frameworks */ = {isa = PBXBuildFile; productRef = 2BDDB9882B27DDE100D52BF0 /* SwiftSoup */; }; 2BDDB98B2B27DDFF00D52BF0 /* String+XMLMarkdown.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2BDDB98A2B27DDFF00D52BF0 /* String+XMLMarkdown.swift */; }; @@ -294,6 +295,7 @@ buildActionMask = 2147483647; files = ( 2B4BDB892ACBED2100E55D78 /* SettingsAccess in Frameworks */, + 2BD97C7E2B69FF57002570C1 /* WhisperKit in Frameworks */, 2BA3C2352AADAC5700537F95 /* llama in Frameworks */, 2B473E8C2AA860380042913D /* MenuBarExtraAccess in Frameworks */, 2BFC51552B38DAB200F3E559 /* LaunchAtLogin in Frameworks */, @@ -687,6 +689,7 @@ 2BDDB9882B27DDE100D52BF0 /* SwiftSoup */, 2BFC51542B38DAB200F3E559 /* LaunchAtLogin */, 2B3FF5342B50B70F00D7BE49 /* Sparkle */, + 2BD97C7D2B69FF57002570C1 /* WhisperKit */, ); productName = TypeaheadAI; productReference = 2BA7F0752A9ABBA8003D38BA /* TypeaheadAI.app */; @@ -736,7 +739,7 @@ attributes = { BuildIndependentTargetsInParallel = 1; LastSwiftUpdateCheck = 1430; - LastUpgradeCheck = 1500; + LastUpgradeCheck = 1520; TargetAttributes = { 2BA7F0742A9ABBA8003D38BA = { CreatedOnToolsVersion = 14.3.1; @@ -775,6 +778,7 @@ 2BDDB9872B27DDE100D52BF0 /* XCRemoteSwiftPackageReference "SwiftSoup" */, 2BFC51532B38DAB200F3E559 /* XCRemoteSwiftPackageReference "LaunchAtLogin-Modern" */, 2B3FF5332B50B70F00D7BE49 /* XCRemoteSwiftPackageReference "Sparkle" */, + 2B5CA39E2B69ED350070E01C /* XCRemoteSwiftPackageReference "whisperkit" */, ); productRefGroup = 2BA7F0762A9ABBA8003D38BA /* Products */; projectDirPath = ""; @@ -973,6 +977,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; @@ -1035,6 +1040,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; @@ -1317,6 +1323,14 @@ minimumVersion = 1.2.0; }; }; + 2B5CA39E2B69ED350070E01C /* XCRemoteSwiftPackageReference "whisperkit" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/argmaxinc/whisperkit"; + requirement = { + branch = main; + kind = branch; + }; + }; 2B8CD4BC2B0AB13B003E0589 /* XCRemoteSwiftPackageReference "swift-markdown-ui" */ = { isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/kchro3/swift-markdown-ui"; @@ -1411,6 +1425,11 @@ package = 2BA7F0AC2A9ABC47003D38BA /* XCRemoteSwiftPackageReference "KeyboardShortcuts" */; productName = KeyboardShortcuts; }; + 2BD97C7D2B69FF57002570C1 /* WhisperKit */ = { + isa = XCSwiftPackageProductDependency; + package = 2B5CA39E2B69ED350070E01C /* XCRemoteSwiftPackageReference "whisperkit" */; + productName = WhisperKit; + }; 2BDDB9882B27DDE100D52BF0 /* SwiftSoup */ = { isa = XCSwiftPackageProductDependency; package = 2BDDB9872B27DDE100D52BF0 /* XCRemoteSwiftPackageReference "SwiftSoup" */; diff --git a/TypeaheadAI.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/TypeaheadAI.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index d8e6ef0..a42c6ec 100644 --- a/TypeaheadAI.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/TypeaheadAI.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -189,6 +189,15 @@ "version" : "0.3.0" } }, + { + "identity" : "swift-argument-parser", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-argument-parser.git", + "state" : { + "revision" : "c8ed701b513cf5177118a175d85fbbbcd707ab41", + "version" : "1.3.0" + } + }, { "identity" : "swift-markdown-ui", "kind" : "remoteSourceControl", @@ -198,6 +207,15 @@ "revision" : "4fd836761e7178150adc370d216f748a21914684" } }, + { + "identity" : "swift-transformers", + "kind" : "remoteSourceControl", + "location" : "https://github.com/huggingface/swift-transformers.git", + "state" : { + "branch" : "main", + "revision" : "5e4031ee16afd10d208c1aee9b49f4def6ca5264" + } + }, { "identity" : "swiftsoup", "kind" : "remoteSourceControl", @@ -215,6 +233,15 @@ "revision" : "4ce950479707ea109f229d7230ec074a133b15d7", "version" : "0.2.1" } + }, + { + "identity" : "whisperkit", + "kind" : "remoteSourceControl", + "location" : "https://github.com/argmaxinc/whisperkit", + "state" : { + "branch" : "main", + "revision" : "60f565e04b15bde3683f32a498ad1ce03c2c11c4" + } } ], "version" : 2 diff --git a/TypeaheadAI/Traits/CanSimulateDictation.swift b/TypeaheadAI/Traits/CanSimulateDictation.swift index ecce665..95fe4b3 100644 --- a/TypeaheadAI/Traits/CanSimulateDictation.swift +++ b/TypeaheadAI/Traits/CanSimulateDictation.swift @@ -5,8 +5,9 @@ // Created by Jeff Hara on 1/19/24. // -import Foundation +import AudioToolbox import Carbon.HIToolbox +import Foundation protocol CanSimulateDictation { func simulateDictation() async throws diff --git a/TypeaheadAI/WindowManagers/ModalManager.swift b/TypeaheadAI/WindowManagers/ModalManager.swift index 490a0b3..15a9639 100644 --- a/TypeaheadAI/WindowManagers/ModalManager.swift +++ b/TypeaheadAI/WindowManagers/ModalManager.swift @@ -91,6 +91,7 @@ class ModalManager: ObservableObject, CanSimulateDictation { await self.showModal() } + try await Task.sleep(for: .milliseconds(100)) await NSApp.activate(ignoringOtherApps: true) try await Task.sleep(for: .milliseconds(200)) @@ -379,8 +380,10 @@ class ModalManager: ObservableObject, CanSimulateDictation { } messages[idx].text += text - if text.contains("\n") { - let chunks = messages[idx].text.split(separator: "\n", omittingEmptySubsequences: true) + if text.contains("\n") || text.contains(" ") { +// let chunks = messages[idx].text.split(separator: "\n", omittingEmptySubsequences: true) + let chunks = messages[idx].text.components(separatedBy: .whitespacesAndNewlines).filter { !$0.isEmpty } + print(chunks) if text.trimmingCharacters(in: .whitespaces).hasSuffix("\n") { // Case: If text looks like "bcd\n ", then chunks will look like ["abc", "bcd"] @@ -752,7 +755,9 @@ class ModalManager: ObservableObject, CanSimulateDictation { if bufferedPayload.mode == .text, let text = bufferedPayload.text { - if let lastChunk = text.split(separator: "\n", omittingEmptySubsequences: true).last { + + let components = text.components(separatedBy: CharacterSet.whitespacesAndNewlines).filter { !$0.isEmpty } + if let lastChunk = components.last { speaker.speak(String(lastChunk), withCallback: true) }