Enable native Apple Speech Analyzer in build

This commit is contained in:
Beingpax 2025-08-11 09:07:29 +05:45
parent d62ffbc630
commit 0b8eb71048
2 changed files with 5 additions and 2 deletions

View File

@ -388,7 +388,7 @@
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG $(inherited)";
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG ENABLE_NATIVE_SPEECH_ANALYZER $(inherited)";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
};
name = Debug;
@ -445,6 +445,7 @@
MTL_FAST_MATH = YES;
SDKROOT = macosx;
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "ENABLE_NATIVE_SPEECH_ANALYZER $(inherited)";
};
name = Release;
};
@ -478,6 +479,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG ENABLE_NATIVE_SPEECH_ANALYZER $(inherited)";
};
name = Debug;
};
@ -511,6 +513,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "ENABLE_NATIVE_SPEECH_ANALYZER $(inherited)";
};
name = Release;
};

View File

@ -176,7 +176,7 @@ class NativeAppleTranscriptionService: TranscriptionService {
// 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: Any, locale: Locale) async throws {
private func ensureModelIsAvailable(for transcriber: SpeechTranscriber, 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))