mirror of
https://github.com/anomalyco/hex.git
synced 2026-11-28 13:02:21 +01:00
With Hex's engine on the multilingual model, KeyboardSpeechPreparation took the keyboard's speech as following Hex (keyboardSpeechFollowsApp was true for Parakeet Ultra) because the keyboard used to send those dictations to Hex. Since the previous commit the keyboard dictates them itself, with Apple's speech recognition until it has the multilingual model loaded, so Hex now gets that language's Apple model ready for the keyboard as it does with Parakeet V2. Without this, the keyboard would have had to download it on its first dictation. Verified: DictationSSOTTests' engine case updated to expect it; the full suite runs on the Studio.
49 lines
1.8 KiB
Swift
49 lines
1.8 KiB
Swift
import Foundation
|
|
|
|
/// The speech engine Hex dictates with. Display copy lives in `displayName`; every decision
|
|
/// switches on the enum instead of comparing display strings.
|
|
nonisolated enum DictationEngine: Equatable, Sendable {
|
|
/// Launch hasn't resolved the engine yet.
|
|
case undecided
|
|
/// iOS 26+ `SpeechAnalyzer` (`SpeechTranscriber` or `DictationTranscriber`).
|
|
case appleSpeech
|
|
/// Pre-iOS 26 on-device `SFSpeechRecognizer` (model managed by iOS, never downloaded by Hex).
|
|
case onDeviceRecognizer
|
|
/// FluidAudio Parakeet V2 (English).
|
|
case parakeetV2
|
|
/// FluidAudio Parakeet Ultra (multilingual).
|
|
case parakeetUltra
|
|
|
|
var displayName: String {
|
|
switch self {
|
|
case .undecided: "Local speech"
|
|
case .appleSpeech, .onDeviceRecognizer: "Apple Speech"
|
|
case .parakeetV2: "Parakeet V2"
|
|
case .parakeetUltra: "Parakeet Ultra"
|
|
}
|
|
}
|
|
|
|
var isAppleSpeech: Bool {
|
|
self == .appleSpeech || self == .onDeviceRecognizer
|
|
}
|
|
|
|
/// Whether getting this engine ready downloads a model in Hex (not `SFSpeechRecognizer`,
|
|
/// whose model iOS keeps).
|
|
var downloads: Bool {
|
|
self != .onDeviceRecognizer
|
|
}
|
|
|
|
/// Whether the keyboard's own speech preparation simply follows Hex's app engine: Apple
|
|
/// Speech shares the same on-device model unless the keyboard can't get it
|
|
/// (`keyboardNeedsHex`). With Parakeet in Hex the keyboard still needs Apple's model, which
|
|
/// it dictates with until it has Parakeet loaded itself (the multilingual model's languages
|
|
/// too: they never go to Hex).
|
|
func keyboardSpeechFollowsApp(keyboardNeedsHex: Bool) -> Bool {
|
|
switch self {
|
|
case .appleSpeech, .onDeviceRecognizer:
|
|
!keyboardNeedsHex
|
|
case .undecided, .parakeetV2, .parakeetUltra:
|
|
false
|
|
}
|
|
}
|
|
}
|