set(TARGET whisper.coreml)
add_library(${TARGET}
+ coreml/whisper-compat.m
coreml/whisper-encoder.h
coreml/whisper-encoder.mm
coreml/whisper-encoder-impl.h
COMPILE_FLAGS "-fobjc-arc"
XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC YES
)
+
set_target_properties(${TARGET} PROPERTIES FOLDER "libs")
endif()
--- /dev/null
+#import <CoreML/CoreML.h>
+
+@interface MLModel (Compat)
+- (void) predictionFromFeatures:(id<MLFeatureProvider>) input
+ completionHandler:(void (^)(id<MLFeatureProvider> output, NSError * error)) completionHandler;
+
+- (void) predictionFromFeatures:(id<MLFeatureProvider>) input
+ options:(MLPredictionOptions *) options
+ completionHandler:(void (^)(id<MLFeatureProvider> output, NSError * error)) completionHandler;
+@end
--- /dev/null
+#import "whisper-compat.h"
+#import <Foundation/Foundation.h>
+
+@implementation MLModel (Compat)
+
+#if !defined(MAC_OS_X_VERSION_14_00) || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_14_00
+
+- (void) predictionFromFeatures:(id<MLFeatureProvider>) input
+ completionHandler:(void (^)(id<MLFeatureProvider> output, NSError * error)) completionHandler {
+ [NSOperationQueue.new addOperationWithBlock:^{
+ NSError *error = nil;
+ id<MLFeatureProvider> prediction = [self predictionFromFeatures:input error:&error];
+
+ [NSOperationQueue.mainQueue addOperationWithBlock:^{
+ completionHandler(prediction, error);
+ }];
+ }];
+}
+
+- (void) predictionFromFeatures:(id<MLFeatureProvider>) input
+ options:(MLPredictionOptions *) options
+ completionHandler:(void (^)(id<MLFeatureProvider> output, NSError * error)) completionHandler {
+ [NSOperationQueue.new addOperationWithBlock:^{
+ NSError *error = nil;
+ id<MLFeatureProvider> prediction = [self predictionFromFeatures:input options:options error:&error];
+
+ [NSOperationQueue.mainQueue addOperationWithBlock:^{
+ completionHandler(prediction, error);
+ }];
+ }];
+}
+
+#endif
+
+@end
#error This file must be compiled with automatic reference counting enabled (-fobjc-arc)
#endif
+#import "whisper-compat.h"
#import "whisper-decoder-impl.h"
@implementation whisper_decoder_implInput
#error This file must be compiled with automatic reference counting enabled (-fobjc-arc)
#endif
+#import "whisper-compat.h"
#import "whisper-encoder-impl.h"
@implementation whisper_encoder_implInput