Merge pull request #232 from objectiveSee/fix/build-on-mac15

Fix to build on Mac OS15
This commit is contained in:
Prakash Joshi Pax 2025-08-11 08:36:10 +05:45 committed by GitHub
commit 98108cdf42
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 15 additions and 5 deletions

1
.gitignore vendored
View File

@ -30,6 +30,7 @@ playground.xcworkspace
# .swiftpm
.build/
build/
# CocoaPods
#

View File

@ -54,7 +54,7 @@
E11473B02CBE0F0A00318EE4 /* VoiceInk.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = VoiceInk.app; sourceTree = BUILT_PRODUCTS_DIR; };
E11473C32CBE0F0B00318EE4 /* VoiceInkTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = VoiceInkTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
E11473CD2CBE0F0B00318EE4 /* VoiceInkUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = VoiceInkUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
E1B2DCAA2E3DE70A008DFD68 /* whisper.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = whisper.xcframework; path = "../Downloads/build-apple/whisper.xcframework"; sourceTree = "<group>"; };
E1B2DCAA2E3DE70A008DFD68 /* whisper.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = whisper.xcframework; path = "../whisper.cpp/build-apple/whisper.xcframework"; sourceTree = "<group>"; };
E1CE28772E4336150082B758 /* whisper.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = whisper.xcframework; path = "../build-apple/whisper.xcframework"; sourceTree = "<group>"; };
/* End PBXFileReference section */

View File

@ -62,6 +62,9 @@ class NativeAppleTranscriptionService: TranscriptionService {
throw ServiceError.unsupportedOS
}
// Feature gated: SpeechAnalyzer/SpeechTranscriber are future APIs.
// Enable by defining ENABLE_NATIVE_SPEECH_ANALYZER in build settings once building against macOS 26+ SDKs.
#if canImport(Speech) && ENABLE_NATIVE_SPEECH_ANALYZER
logger.notice("Starting Apple native transcription with SpeechAnalyzer.")
let audioFile = try AVAudioFile(forReading: audioURL)
@ -140,11 +143,15 @@ class NativeAppleTranscriptionService: TranscriptionService {
logger.notice("Native transcription successful. Length: \(finalTranscription.count) characters.")
return finalTranscription
#else
logger.notice("Native Apple transcription is disabled in this build (future Speech APIs not enabled).")
throw ServiceError.unsupportedOS
#endif
}
@available(macOS 26, *)
private func deallocateExistingAssets() async throws {
#if canImport(Speech)
#if canImport(Speech) && ENABLE_NATIVE_SPEECH_ANALYZER
// Deallocate any existing allocated locales to avoid conflicts
for locale in await AssetInventory.allocatedLocales {
await AssetInventory.deallocate(locale: locale)
@ -155,7 +162,7 @@ class NativeAppleTranscriptionService: TranscriptionService {
@available(macOS 26, *)
private func allocateAssetsForLocale(_ locale: Locale) async throws {
#if canImport(Speech)
#if canImport(Speech) && ENABLE_NATIVE_SPEECH_ANALYZER
do {
try await AssetInventory.allocate(locale: locale)
logger.notice("Successfully allocated assets for locale: '\(locale.identifier(.bcp47))'")
@ -166,9 +173,11 @@ class NativeAppleTranscriptionService: TranscriptionService {
#endif
}
// Forward-compatibility: Use Any here because SpeechTranscriber is only available in future macOS SDKs.
// This avoids referencing an unavailable SDK symbol while keeping the method shape for later adoption.
@available(macOS 26, *)
private func ensureModelIsAvailable(for transcriber: SpeechTranscriber, locale: Locale) async throws {
#if canImport(Speech)
private func ensureModelIsAvailable(for transcriber: Any, locale: Locale) async throws {
#if canImport(Speech) && ENABLE_NATIVE_SPEECH_ANALYZER
let installedLocales = await SpeechTranscriber.installedLocales
let isInstalled = installedLocales.map({ $0.identifier(.bcp47) }).contains(locale.identifier(.bcp47))