ggerganov commited on
Commit
abbf9ee
·
1 Parent(s): abde4e1

ios : whisper.objc example

Browse files
.gitignore CHANGED
@@ -12,3 +12,7 @@ out/
12
  .vscode/
13
  compile_commands.json
14
  .DS_Store
 
 
 
 
 
12
  .vscode/
13
  compile_commands.json
14
  .DS_Store
15
+
16
+ examples/whisper.objc/whisper.objc.xcodeproj/xcshareddata
17
+ examples/whisper.objc/whisper.objc.xcodeproj/xcuserdata/
18
+ examples/whisper.objc/whisper.objc.xcodeproj/project.xcworkspace/xcuserdata
examples/whisper.objc/whisper.objc.xcodeproj/project.pbxproj ADDED
@@ -0,0 +1,382 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // !$*UTF8*$!
2
+ {
3
+ archiveVersion = 1;
4
+ classes = {
5
+ };
6
+ objectVersion = 56;
7
+ objects = {
8
+
9
+ /* Begin PBXBuildFile section */
10
+ 18627C7B29052BDF00BD2A04 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 18627C7A29052BDF00BD2A04 /* AppDelegate.m */; };
11
+ 18627C7E29052BDF00BD2A04 /* SceneDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 18627C7D29052BDF00BD2A04 /* SceneDelegate.m */; };
12
+ 18627C8129052BDF00BD2A04 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 18627C8029052BDF00BD2A04 /* ViewController.m */; };
13
+ 18627C8429052BDF00BD2A04 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 18627C8229052BDF00BD2A04 /* Main.storyboard */; };
14
+ 18627C8629052BE000BD2A04 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 18627C8529052BE000BD2A04 /* Assets.xcassets */; };
15
+ 18627C8929052BE000BD2A04 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 18627C8729052BE000BD2A04 /* LaunchScreen.storyboard */; };
16
+ 18627C8C29052BE000BD2A04 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 18627C8B29052BE000BD2A04 /* main.m */; };
17
+ 18627C9429052C4900BD2A04 /* whisper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 18627C9329052C4900BD2A04 /* whisper.cpp */; };
18
+ 18627C9629052C5800BD2A04 /* ggml.c in Sources */ = {isa = PBXBuildFile; fileRef = 18627C9529052C5800BD2A04 /* ggml.c */; settings = {COMPILER_FLAGS = "-DGGML_USE_ACCELERATE"; }; };
19
+ 18627C9B29052CFF00BD2A04 /* ggml-base.en.bin in Resources */ = {isa = PBXBuildFile; fileRef = 18627C9A29052CFF00BD2A04 /* ggml-base.en.bin */; };
20
+ /* End PBXBuildFile section */
21
+
22
+ /* Begin PBXFileReference section */
23
+ 18627C7629052BDF00BD2A04 /* whisper.objc.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = whisper.objc.app; sourceTree = BUILT_PRODUCTS_DIR; };
24
+ 18627C7929052BDF00BD2A04 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
25
+ 18627C7A29052BDF00BD2A04 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
26
+ 18627C7C29052BDF00BD2A04 /* SceneDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SceneDelegate.h; sourceTree = "<group>"; };
27
+ 18627C7D29052BDF00BD2A04 /* SceneDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SceneDelegate.m; sourceTree = "<group>"; };
28
+ 18627C7F29052BDF00BD2A04 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = "<group>"; };
29
+ 18627C8029052BDF00BD2A04 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = "<group>"; };
30
+ 18627C8329052BDF00BD2A04 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
31
+ 18627C8529052BE000BD2A04 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
32
+ 18627C8829052BE000BD2A04 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
33
+ 18627C8A29052BE000BD2A04 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
34
+ 18627C8B29052BE000BD2A04 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
35
+ 18627C9229052C2B00BD2A04 /* whisper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = whisper.h; path = ../../../whisper.h; sourceTree = "<group>"; };
36
+ 18627C9329052C4900BD2A04 /* whisper.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = whisper.cpp; path = ../../../whisper.cpp; sourceTree = "<group>"; };
37
+ 18627C9529052C5800BD2A04 /* ggml.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = ggml.c; path = ../../../ggml.c; sourceTree = "<group>"; };
38
+ 18627C9729052C6600BD2A04 /* ggml.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ggml.h; path = ../../../ggml.h; sourceTree = "<group>"; };
39
+ 18627C9A29052CFF00BD2A04 /* ggml-base.en.bin */ = {isa = PBXFileReference; lastKnownFileType = archive.macbinary; name = "ggml-base.en.bin"; path = "../../../models/ggml-base.en.bin"; sourceTree = "<group>"; };
40
+ /* End PBXFileReference section */
41
+
42
+ /* Begin PBXFrameworksBuildPhase section */
43
+ 18627C7329052BDF00BD2A04 /* Frameworks */ = {
44
+ isa = PBXFrameworksBuildPhase;
45
+ buildActionMask = 2147483647;
46
+ files = (
47
+ );
48
+ runOnlyForDeploymentPostprocessing = 0;
49
+ };
50
+ /* End PBXFrameworksBuildPhase section */
51
+
52
+ /* Begin PBXGroup section */
53
+ 18627C6D29052BDF00BD2A04 = {
54
+ isa = PBXGroup;
55
+ children = (
56
+ 18627C7829052BDF00BD2A04 /* whisper.objc */,
57
+ 18627C7729052BDF00BD2A04 /* Products */,
58
+ );
59
+ sourceTree = "<group>";
60
+ };
61
+ 18627C7729052BDF00BD2A04 /* Products */ = {
62
+ isa = PBXGroup;
63
+ children = (
64
+ 18627C7629052BDF00BD2A04 /* whisper.objc.app */,
65
+ );
66
+ name = Products;
67
+ sourceTree = "<group>";
68
+ };
69
+ 18627C7829052BDF00BD2A04 /* whisper.objc */ = {
70
+ isa = PBXGroup;
71
+ children = (
72
+ 18627C9A29052CFF00BD2A04 /* ggml-base.en.bin */,
73
+ 18627C9729052C6600BD2A04 /* ggml.h */,
74
+ 18627C9529052C5800BD2A04 /* ggml.c */,
75
+ 18627C9329052C4900BD2A04 /* whisper.cpp */,
76
+ 18627C9229052C2B00BD2A04 /* whisper.h */,
77
+ 18627C7929052BDF00BD2A04 /* AppDelegate.h */,
78
+ 18627C7A29052BDF00BD2A04 /* AppDelegate.m */,
79
+ 18627C7C29052BDF00BD2A04 /* SceneDelegate.h */,
80
+ 18627C7D29052BDF00BD2A04 /* SceneDelegate.m */,
81
+ 18627C7F29052BDF00BD2A04 /* ViewController.h */,
82
+ 18627C8029052BDF00BD2A04 /* ViewController.m */,
83
+ 18627C8229052BDF00BD2A04 /* Main.storyboard */,
84
+ 18627C8529052BE000BD2A04 /* Assets.xcassets */,
85
+ 18627C8729052BE000BD2A04 /* LaunchScreen.storyboard */,
86
+ 18627C8A29052BE000BD2A04 /* Info.plist */,
87
+ 18627C8B29052BE000BD2A04 /* main.m */,
88
+ );
89
+ path = whisper.objc;
90
+ sourceTree = "<group>";
91
+ };
92
+ /* End PBXGroup section */
93
+
94
+ /* Begin PBXNativeTarget section */
95
+ 18627C7529052BDF00BD2A04 /* whisper.objc */ = {
96
+ isa = PBXNativeTarget;
97
+ buildConfigurationList = 18627C8F29052BE000BD2A04 /* Build configuration list for PBXNativeTarget "whisper.objc" */;
98
+ buildPhases = (
99
+ 18627C7229052BDF00BD2A04 /* Sources */,
100
+ 18627C7329052BDF00BD2A04 /* Frameworks */,
101
+ 18627C7429052BDF00BD2A04 /* Resources */,
102
+ );
103
+ buildRules = (
104
+ );
105
+ dependencies = (
106
+ );
107
+ name = whisper.objc;
108
+ productName = whisper.objc;
109
+ productReference = 18627C7629052BDF00BD2A04 /* whisper.objc.app */;
110
+ productType = "com.apple.product-type.application";
111
+ };
112
+ /* End PBXNativeTarget section */
113
+
114
+ /* Begin PBXProject section */
115
+ 18627C6E29052BDF00BD2A04 /* Project object */ = {
116
+ isa = PBXProject;
117
+ attributes = {
118
+ BuildIndependentTargetsInParallel = 1;
119
+ LastUpgradeCheck = 1400;
120
+ TargetAttributes = {
121
+ 18627C7529052BDF00BD2A04 = {
122
+ CreatedOnToolsVersion = 14.0.1;
123
+ };
124
+ };
125
+ };
126
+ buildConfigurationList = 18627C7129052BDF00BD2A04 /* Build configuration list for PBXProject "whisper.objc" */;
127
+ compatibilityVersion = "Xcode 14.0";
128
+ developmentRegion = en;
129
+ hasScannedForEncodings = 0;
130
+ knownRegions = (
131
+ en,
132
+ Base,
133
+ );
134
+ mainGroup = 18627C6D29052BDF00BD2A04;
135
+ productRefGroup = 18627C7729052BDF00BD2A04 /* Products */;
136
+ projectDirPath = "";
137
+ projectRoot = "";
138
+ targets = (
139
+ 18627C7529052BDF00BD2A04 /* whisper.objc */,
140
+ );
141
+ };
142
+ /* End PBXProject section */
143
+
144
+ /* Begin PBXResourcesBuildPhase section */
145
+ 18627C7429052BDF00BD2A04 /* Resources */ = {
146
+ isa = PBXResourcesBuildPhase;
147
+ buildActionMask = 2147483647;
148
+ files = (
149
+ 18627C8929052BE000BD2A04 /* LaunchScreen.storyboard in Resources */,
150
+ 18627C8629052BE000BD2A04 /* Assets.xcassets in Resources */,
151
+ 18627C8429052BDF00BD2A04 /* Main.storyboard in Resources */,
152
+ 18627C9B29052CFF00BD2A04 /* ggml-base.en.bin in Resources */,
153
+ );
154
+ runOnlyForDeploymentPostprocessing = 0;
155
+ };
156
+ /* End PBXResourcesBuildPhase section */
157
+
158
+ /* Begin PBXSourcesBuildPhase section */
159
+ 18627C7229052BDF00BD2A04 /* Sources */ = {
160
+ isa = PBXSourcesBuildPhase;
161
+ buildActionMask = 2147483647;
162
+ files = (
163
+ 18627C8129052BDF00BD2A04 /* ViewController.m in Sources */,
164
+ 18627C9429052C4900BD2A04 /* whisper.cpp in Sources */,
165
+ 18627C9629052C5800BD2A04 /* ggml.c in Sources */,
166
+ 18627C7B29052BDF00BD2A04 /* AppDelegate.m in Sources */,
167
+ 18627C8C29052BE000BD2A04 /* main.m in Sources */,
168
+ 18627C7E29052BDF00BD2A04 /* SceneDelegate.m in Sources */,
169
+ );
170
+ runOnlyForDeploymentPostprocessing = 0;
171
+ };
172
+ /* End PBXSourcesBuildPhase section */
173
+
174
+ /* Begin PBXVariantGroup section */
175
+ 18627C8229052BDF00BD2A04 /* Main.storyboard */ = {
176
+ isa = PBXVariantGroup;
177
+ children = (
178
+ 18627C8329052BDF00BD2A04 /* Base */,
179
+ );
180
+ name = Main.storyboard;
181
+ sourceTree = "<group>";
182
+ };
183
+ 18627C8729052BE000BD2A04 /* LaunchScreen.storyboard */ = {
184
+ isa = PBXVariantGroup;
185
+ children = (
186
+ 18627C8829052BE000BD2A04 /* Base */,
187
+ );
188
+ name = LaunchScreen.storyboard;
189
+ sourceTree = "<group>";
190
+ };
191
+ /* End PBXVariantGroup section */
192
+
193
+ /* Begin XCBuildConfiguration section */
194
+ 18627C8D29052BE000BD2A04 /* Debug */ = {
195
+ isa = XCBuildConfiguration;
196
+ buildSettings = {
197
+ ALWAYS_SEARCH_USER_PATHS = NO;
198
+ CLANG_ANALYZER_NONNULL = YES;
199
+ CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
200
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
201
+ CLANG_ENABLE_MODULES = YES;
202
+ CLANG_ENABLE_OBJC_ARC = YES;
203
+ CLANG_ENABLE_OBJC_WEAK = YES;
204
+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
205
+ CLANG_WARN_BOOL_CONVERSION = YES;
206
+ CLANG_WARN_COMMA = YES;
207
+ CLANG_WARN_CONSTANT_CONVERSION = YES;
208
+ CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
209
+ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
210
+ CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
211
+ CLANG_WARN_EMPTY_BODY = YES;
212
+ CLANG_WARN_ENUM_CONVERSION = YES;
213
+ CLANG_WARN_INFINITE_RECURSION = YES;
214
+ CLANG_WARN_INT_CONVERSION = YES;
215
+ CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
216
+ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
217
+ CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
218
+ CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
219
+ CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
220
+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
221
+ CLANG_WARN_STRICT_PROTOTYPES = YES;
222
+ CLANG_WARN_SUSPICIOUS_MOVE = YES;
223
+ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
224
+ CLANG_WARN_UNREACHABLE_CODE = YES;
225
+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
226
+ COPY_PHASE_STRIP = NO;
227
+ DEBUG_INFORMATION_FORMAT = dwarf;
228
+ ENABLE_STRICT_OBJC_MSGSEND = YES;
229
+ ENABLE_TESTABILITY = YES;
230
+ GCC_C_LANGUAGE_STANDARD = gnu11;
231
+ GCC_DYNAMIC_NO_PIC = NO;
232
+ GCC_NO_COMMON_BLOCKS = YES;
233
+ GCC_OPTIMIZATION_LEVEL = 0;
234
+ GCC_PREPROCESSOR_DEFINITIONS = (
235
+ "DEBUG=1",
236
+ "$(inherited)",
237
+ );
238
+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
239
+ GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
240
+ GCC_WARN_UNDECLARED_SELECTOR = YES;
241
+ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
242
+ GCC_WARN_UNUSED_FUNCTION = YES;
243
+ GCC_WARN_UNUSED_VARIABLE = YES;
244
+ IPHONEOS_DEPLOYMENT_TARGET = 16.0;
245
+ MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
246
+ MTL_FAST_MATH = YES;
247
+ ONLY_ACTIVE_ARCH = YES;
248
+ SDKROOT = iphoneos;
249
+ };
250
+ name = Debug;
251
+ };
252
+ 18627C8E29052BE000BD2A04 /* Release */ = {
253
+ isa = XCBuildConfiguration;
254
+ buildSettings = {
255
+ ALWAYS_SEARCH_USER_PATHS = NO;
256
+ CLANG_ANALYZER_NONNULL = YES;
257
+ CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
258
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
259
+ CLANG_ENABLE_MODULES = YES;
260
+ CLANG_ENABLE_OBJC_ARC = YES;
261
+ CLANG_ENABLE_OBJC_WEAK = YES;
262
+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
263
+ CLANG_WARN_BOOL_CONVERSION = YES;
264
+ CLANG_WARN_COMMA = YES;
265
+ CLANG_WARN_CONSTANT_CONVERSION = YES;
266
+ CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
267
+ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
268
+ CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
269
+ CLANG_WARN_EMPTY_BODY = YES;
270
+ CLANG_WARN_ENUM_CONVERSION = YES;
271
+ CLANG_WARN_INFINITE_RECURSION = YES;
272
+ CLANG_WARN_INT_CONVERSION = YES;
273
+ CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
274
+ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
275
+ CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
276
+ CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
277
+ CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
278
+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
279
+ CLANG_WARN_STRICT_PROTOTYPES = YES;
280
+ CLANG_WARN_SUSPICIOUS_MOVE = YES;
281
+ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
282
+ CLANG_WARN_UNREACHABLE_CODE = YES;
283
+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
284
+ COPY_PHASE_STRIP = NO;
285
+ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
286
+ ENABLE_NS_ASSERTIONS = NO;
287
+ ENABLE_STRICT_OBJC_MSGSEND = YES;
288
+ GCC_C_LANGUAGE_STANDARD = gnu11;
289
+ GCC_NO_COMMON_BLOCKS = YES;
290
+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
291
+ GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
292
+ GCC_WARN_UNDECLARED_SELECTOR = YES;
293
+ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
294
+ GCC_WARN_UNUSED_FUNCTION = YES;
295
+ GCC_WARN_UNUSED_VARIABLE = YES;
296
+ IPHONEOS_DEPLOYMENT_TARGET = 16.0;
297
+ MTL_ENABLE_DEBUG_INFO = NO;
298
+ MTL_FAST_MATH = YES;
299
+ SDKROOT = iphoneos;
300
+ VALIDATE_PRODUCT = YES;
301
+ };
302
+ name = Release;
303
+ };
304
+ 18627C9029052BE000BD2A04 /* Debug */ = {
305
+ isa = XCBuildConfiguration;
306
+ buildSettings = {
307
+ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
308
+ ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
309
+ CODE_SIGN_STYLE = Automatic;
310
+ CURRENT_PROJECT_VERSION = 1;
311
+ DEVELOPMENT_TEAM = P8JZH34X63;
312
+ GENERATE_INFOPLIST_FILE = YES;
313
+ INFOPLIST_FILE = whisper.objc/Info.plist;
314
+ INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
315
+ INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen;
316
+ INFOPLIST_KEY_UIMainStoryboardFile = Main;
317
+ INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
318
+ INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
319
+ LD_RUNPATH_SEARCH_PATHS = (
320
+ "$(inherited)",
321
+ "@executable_path/Frameworks",
322
+ );
323
+ MARKETING_VERSION = 1.0;
324
+ PRODUCT_BUNDLE_IDENTIFIER = "com.ggerganov.whisper-objc";
325
+ PRODUCT_NAME = "$(TARGET_NAME)";
326
+ SWIFT_EMIT_LOC_STRINGS = YES;
327
+ TARGETED_DEVICE_FAMILY = "1,2";
328
+ };
329
+ name = Debug;
330
+ };
331
+ 18627C9129052BE000BD2A04 /* Release */ = {
332
+ isa = XCBuildConfiguration;
333
+ buildSettings = {
334
+ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
335
+ ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
336
+ CODE_SIGN_STYLE = Automatic;
337
+ CURRENT_PROJECT_VERSION = 1;
338
+ DEVELOPMENT_TEAM = P8JZH34X63;
339
+ GENERATE_INFOPLIST_FILE = YES;
340
+ INFOPLIST_FILE = whisper.objc/Info.plist;
341
+ INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
342
+ INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen;
343
+ INFOPLIST_KEY_UIMainStoryboardFile = Main;
344
+ INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
345
+ INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
346
+ LD_RUNPATH_SEARCH_PATHS = (
347
+ "$(inherited)",
348
+ "@executable_path/Frameworks",
349
+ );
350
+ MARKETING_VERSION = 1.0;
351
+ PRODUCT_BUNDLE_IDENTIFIER = "com.ggerganov.whisper-objc";
352
+ PRODUCT_NAME = "$(TARGET_NAME)";
353
+ SWIFT_EMIT_LOC_STRINGS = YES;
354
+ TARGETED_DEVICE_FAMILY = "1,2";
355
+ };
356
+ name = Release;
357
+ };
358
+ /* End XCBuildConfiguration section */
359
+
360
+ /* Begin XCConfigurationList section */
361
+ 18627C7129052BDF00BD2A04 /* Build configuration list for PBXProject "whisper.objc" */ = {
362
+ isa = XCConfigurationList;
363
+ buildConfigurations = (
364
+ 18627C8D29052BE000BD2A04 /* Debug */,
365
+ 18627C8E29052BE000BD2A04 /* Release */,
366
+ );
367
+ defaultConfigurationIsVisible = 0;
368
+ defaultConfigurationName = Release;
369
+ };
370
+ 18627C8F29052BE000BD2A04 /* Build configuration list for PBXNativeTarget "whisper.objc" */ = {
371
+ isa = XCConfigurationList;
372
+ buildConfigurations = (
373
+ 18627C9029052BE000BD2A04 /* Debug */,
374
+ 18627C9129052BE000BD2A04 /* Release */,
375
+ );
376
+ defaultConfigurationIsVisible = 0;
377
+ defaultConfigurationName = Release;
378
+ };
379
+ /* End XCConfigurationList section */
380
+ };
381
+ rootObject = 18627C6E29052BDF00BD2A04 /* Project object */;
382
+ }
examples/whisper.objc/whisper.objc.xcodeproj/project.xcworkspace/contents.xcworkspacedata ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <Workspace
3
+ version = "1.0">
4
+ <FileRef
5
+ location = "self:">
6
+ </FileRef>
7
+ </Workspace>
examples/whisper.objc/whisper.objc.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>IDEDidComputeMac32BitWarning</key>
6
+ <true/>
7
+ </dict>
8
+ </plist>
examples/whisper.objc/whisper.objc/AppDelegate.h ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //
2
+ // AppDelegate.h
3
+ // whisper.objc
4
+ //
5
+ // Created by Georgi Gerganov on 23.10.22.
6
+ //
7
+
8
+ #import <UIKit/UIKit.h>
9
+
10
+ @interface AppDelegate : UIResponder <UIApplicationDelegate>
11
+
12
+
13
+ @end
14
+
examples/whisper.objc/whisper.objc/AppDelegate.m ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //
2
+ // AppDelegate.m
3
+ // whisper.objc
4
+ //
5
+ // Created by Georgi Gerganov on 23.10.22.
6
+ //
7
+
8
+ #import "AppDelegate.h"
9
+
10
+ @interface AppDelegate ()
11
+
12
+ @end
13
+
14
+ @implementation AppDelegate
15
+
16
+
17
+ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
18
+ // Override point for customization after application launch.
19
+ return YES;
20
+ }
21
+
22
+
23
+ #pragma mark - UISceneSession lifecycle
24
+
25
+
26
+ - (UISceneConfiguration *)application:(UIApplication *)application configurationForConnectingSceneSession:(UISceneSession *)connectingSceneSession options:(UISceneConnectionOptions *)options {
27
+ // Called when a new scene session is being created.
28
+ // Use this method to select a configuration to create the new scene with.
29
+ return [[UISceneConfiguration alloc] initWithName:@"Default Configuration" sessionRole:connectingSceneSession.role];
30
+ }
31
+
32
+
33
+ - (void)application:(UIApplication *)application didDiscardSceneSessions:(NSSet<UISceneSession *> *)sceneSessions {
34
+ // Called when the user discards a scene session.
35
+ // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
36
+ // Use this method to release any resources that were specific to the discarded scenes, as they will not return.
37
+ }
38
+
39
+
40
+ @end
examples/whisper.objc/whisper.objc/Assets.xcassets/AccentColor.colorset/Contents.json ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "colors" : [
3
+ {
4
+ "idiom" : "universal"
5
+ }
6
+ ],
7
+ "info" : {
8
+ "author" : "xcode",
9
+ "version" : 1
10
+ }
11
+ }
examples/whisper.objc/whisper.objc/Assets.xcassets/AppIcon.appiconset/Contents.json ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "images" : [
3
+ {
4
+ "idiom" : "universal",
5
+ "platform" : "ios",
6
+ "size" : "1024x1024"
7
+ }
8
+ ],
9
+ "info" : {
10
+ "author" : "xcode",
11
+ "version" : 1
12
+ }
13
+ }
examples/whisper.objc/whisper.objc/Assets.xcassets/Contents.json ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ {
2
+ "info" : {
3
+ "author" : "xcode",
4
+ "version" : 1
5
+ }
6
+ }
examples/whisper.objc/whisper.objc/Base.lproj/LaunchScreen.storyboard ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
+ <document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
3
+ <dependencies>
4
+ <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
5
+ <capability name="Safe area layout guides" minToolsVersion="9.0"/>
6
+ <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
7
+ </dependencies>
8
+ <scenes>
9
+ <!--View Controller-->
10
+ <scene sceneID="EHf-IW-A2E">
11
+ <objects>
12
+ <viewController id="01J-lp-oVM" sceneMemberID="viewController">
13
+ <view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
14
+ <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
15
+ <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
16
+ <color key="backgroundColor" xcode11CocoaTouchSystemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
17
+ <viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
18
+ </view>
19
+ </viewController>
20
+ <placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
21
+ </objects>
22
+ <point key="canvasLocation" x="53" y="375"/>
23
+ </scene>
24
+ </scenes>
25
+ </document>
examples/whisper.objc/whisper.objc/Base.lproj/Main.storyboard ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="21225" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
3
+ <device id="retina6_0" orientation="portrait" appearance="light"/>
4
+ <dependencies>
5
+ <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21207"/>
6
+ <capability name="Safe area layout guides" minToolsVersion="9.0"/>
7
+ <capability name="System colors in document resources" minToolsVersion="11.0"/>
8
+ <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
9
+ </dependencies>
10
+ <scenes>
11
+ <!--View Controller-->
12
+ <scene sceneID="tne-QT-ifu">
13
+ <objects>
14
+ <viewController id="BYZ-38-t0r" customClass="ViewController" sceneMemberID="viewController">
15
+ <view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
16
+ <rect key="frame" x="0.0" y="0.0" width="390" height="844"/>
17
+ <autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMinY="YES" heightSizable="YES"/>
18
+ <subviews>
19
+ <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="VOi-PT-Rbu">
20
+ <rect key="frame" x="35" y="121" width="156" height="34"/>
21
+ <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
22
+ <color key="backgroundColor" systemColor="opaqueSeparatorColor"/>
23
+ <color key="tintColor" systemColor="opaqueSeparatorColor"/>
24
+ <state key="normal" title="Start Capturing">
25
+ <color key="titleColor" systemColor="labelColor"/>
26
+ </state>
27
+ <connections>
28
+ <action selector="toggleCapture:" destination="BYZ-38-t0r" eventType="touchUpInside" id="BuO-Wf-RgV"/>
29
+ </connections>
30
+ </button>
31
+ <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Status: Idle" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Tgu-2q-eHQ">
32
+ <rect key="frame" x="35" y="78" width="232" height="21"/>
33
+ <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
34
+ <fontDescription key="fontDescription" type="system" pointSize="17"/>
35
+ <nil key="textColor"/>
36
+ <nil key="highlightedColor"/>
37
+ </label>
38
+ <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="Brs-xi-o8i">
39
+ <rect key="frame" x="35" y="177" width="156" height="34"/>
40
+ <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
41
+ <color key="backgroundColor" systemColor="opaqueSeparatorColor"/>
42
+ <color key="tintColor" systemColor="opaqueSeparatorColor"/>
43
+ <state key="normal" title="Transcribe">
44
+ <color key="titleColor" systemColor="labelColor"/>
45
+ </state>
46
+ <connections>
47
+ <action selector="onTranscribe:" destination="BYZ-38-t0r" eventType="touchUpInside" id="ond-bx-48O"/>
48
+ <action selector="onTranscribePrepare:" destination="BYZ-38-t0r" eventType="touchDown" id="16T-dN-dfB"/>
49
+ </connections>
50
+ </button>
51
+ <textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" fixedFrame="YES" text="Record some speech and press &quot;Transcribe&quot;. The result will be displayed here." textAlignment="natural" translatesAutoresizingMaskIntoConstraints="NO" id="mv2-KD-7jn">
52
+ <rect key="frame" x="35" y="248" width="320" height="300"/>
53
+ <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
54
+ <color key="backgroundColor" systemColor="systemBackgroundColor"/>
55
+ <color key="textColor" systemColor="labelColor"/>
56
+ <fontDescription key="fontDescription" type="system" pointSize="14"/>
57
+ <textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
58
+ </textView>
59
+ </subviews>
60
+ <viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
61
+ <color key="backgroundColor" systemColor="systemBackgroundColor"/>
62
+ <constraints>
63
+ <constraint firstItem="Brs-xi-o8i" firstAttribute="trailing" secondItem="VOi-PT-Rbu" secondAttribute="trailing" id="8mF-AW-cbc"/>
64
+ </constraints>
65
+ </view>
66
+ <connections>
67
+ <outlet property="buttonTranscribe" destination="Brs-xi-o8i" id="N8h-9W-ywb"/>
68
+ <outlet property="labelStatusInp" destination="Tgu-2q-eHQ" id="1hH-Ql-K6j"/>
69
+ <outlet property="textviewResult" destination="mv2-KD-7jn" id="RBw-0L-iGj"/>
70
+ </connections>
71
+ </viewController>
72
+ <placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
73
+ </objects>
74
+ <point key="canvasLocation" x="30.769230769230766" y="-28.436018957345969"/>
75
+ </scene>
76
+ </scenes>
77
+ <resources>
78
+ <systemColor name="labelColor">
79
+ <color red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
80
+ </systemColor>
81
+ <systemColor name="opaqueSeparatorColor">
82
+ <color red="0.77647058823529413" green="0.77647058823529413" blue="0.78431372549019607" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
83
+ </systemColor>
84
+ <systemColor name="systemBackgroundColor">
85
+ <color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
86
+ </systemColor>
87
+ </resources>
88
+ </document>
examples/whisper.objc/whisper.objc/Info.plist ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>NSMicrophoneUsageDescription</key>
6
+ <string>This app requires microphone access in order to transcribe speech</string>
7
+ <key>UIApplicationSceneManifest</key>
8
+ <dict>
9
+ <key>UIApplicationSupportsMultipleScenes</key>
10
+ <false/>
11
+ <key>UISceneConfigurations</key>
12
+ <dict>
13
+ <key>UIWindowSceneSessionRoleApplication</key>
14
+ <array>
15
+ <dict>
16
+ <key>UISceneConfigurationName</key>
17
+ <string>Default Configuration</string>
18
+ <key>UISceneDelegateClassName</key>
19
+ <string>SceneDelegate</string>
20
+ <key>UISceneStoryboardFile</key>
21
+ <string>Main</string>
22
+ </dict>
23
+ </array>
24
+ </dict>
25
+ </dict>
26
+ </dict>
27
+ </plist>
examples/whisper.objc/whisper.objc/SceneDelegate.h ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //
2
+ // SceneDelegate.h
3
+ // whisper.objc
4
+ //
5
+ // Created by Georgi Gerganov on 23.10.22.
6
+ //
7
+
8
+ #import <UIKit/UIKit.h>
9
+
10
+ @interface SceneDelegate : UIResponder <UIWindowSceneDelegate>
11
+
12
+ @property (strong, nonatomic) UIWindow * window;
13
+
14
+ @end
15
+
examples/whisper.objc/whisper.objc/SceneDelegate.m ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //
2
+ // SceneDelegate.m
3
+ // whisper.objc
4
+ //
5
+ // Created by Georgi Gerganov on 23.10.22.
6
+ //
7
+
8
+ #import "SceneDelegate.h"
9
+
10
+ @interface SceneDelegate ()
11
+
12
+ @end
13
+
14
+ @implementation SceneDelegate
15
+
16
+
17
+ - (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session options:(UISceneConnectionOptions *)connectionOptions {
18
+ // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
19
+ // If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
20
+ // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
21
+ }
22
+
23
+
24
+ - (void)sceneDidDisconnect:(UIScene *)scene {
25
+ // Called as the scene is being released by the system.
26
+ // This occurs shortly after the scene enters the background, or when its session is discarded.
27
+ // Release any resources associated with this scene that can be re-created the next time the scene connects.
28
+ // The scene may re-connect later, as its session was not necessarily discarded (see `application:didDiscardSceneSessions` instead).
29
+ }
30
+
31
+
32
+ - (void)sceneDidBecomeActive:(UIScene *)scene {
33
+ // Called when the scene has moved from an inactive state to an active state.
34
+ // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive.
35
+ }
36
+
37
+
38
+ - (void)sceneWillResignActive:(UIScene *)scene {
39
+ // Called when the scene will move from an active state to an inactive state.
40
+ // This may occur due to temporary interruptions (ex. an incoming phone call).
41
+ }
42
+
43
+
44
+ - (void)sceneWillEnterForeground:(UIScene *)scene {
45
+ // Called as the scene transitions from the background to the foreground.
46
+ // Use this method to undo the changes made on entering the background.
47
+ }
48
+
49
+
50
+ - (void)sceneDidEnterBackground:(UIScene *)scene {
51
+ // Called as the scene transitions from the foreground to the background.
52
+ // Use this method to save data, release shared resources, and store enough scene-specific state information
53
+ // to restore the scene back to its current state.
54
+ }
55
+
56
+
57
+ @end
examples/whisper.objc/whisper.objc/ViewController.h ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //
2
+ // ViewController.h
3
+ // whisper.objc
4
+ //
5
+ // Created by Georgi Gerganov on 23.10.22.
6
+ //
7
+
8
+ #import <UIKit/UIKit.h>
9
+
10
+ #import <AVFoundation/AVFoundation.h>
11
+ #import <AudioToolbox/AudioQueue.h>
12
+
13
+ #define NUM_BUFFERS 3
14
+ #define MAX_AUDIO_SEC 30
15
+ #define SAMPLE_RATE 16000
16
+
17
+ struct whisper_context;
18
+
19
+ typedef struct
20
+ {
21
+ int ggwaveId;
22
+ bool isCapturing;
23
+ UILabel * labelReceived;
24
+
25
+ AudioQueueRef queue;
26
+ AudioStreamBasicDescription dataFormat;
27
+ AudioQueueBufferRef buffers[NUM_BUFFERS];
28
+
29
+ int n_samples;
30
+ int16_t * audioBufferI16;
31
+ float * audioBufferF32;
32
+
33
+ struct whisper_context * ctx;
34
+ } StateInp;
35
+
36
+ @interface ViewController : UIViewController
37
+ {
38
+ StateInp stateInp;
39
+ }
40
+
41
+ @end
examples/whisper.objc/whisper.objc/ViewController.m ADDED
@@ -0,0 +1,229 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //
2
+ // ViewController.m
3
+ // whisper.objc
4
+ //
5
+ // Created by Georgi Gerganov on 23.10.22.
6
+ //
7
+
8
+ #import "ViewController.h"
9
+
10
+ #import "whisper.h"
11
+
12
+ #define NUM_BYTES_PER_BUFFER 16*1024
13
+
14
+ // callback used to process captured audio
15
+ void AudioInputCallback(void * inUserData,
16
+ AudioQueueRef inAQ,
17
+ AudioQueueBufferRef inBuffer,
18
+ const AudioTimeStamp * inStartTime,
19
+ UInt32 inNumberPacketDescriptions,
20
+ const AudioStreamPacketDescription * inPacketDescs);
21
+
22
+ @interface ViewController ()
23
+
24
+ @property (weak, nonatomic) IBOutlet UILabel *labelStatusInp;
25
+ @property (weak, nonatomic) IBOutlet UIButton *buttonToggleCapture;
26
+ @property (weak, nonatomic) IBOutlet UIButton *buttonTranscribe;
27
+ @property (weak, nonatomic) IBOutlet UITextView *textviewResult;
28
+
29
+ @end
30
+
31
+ @implementation ViewController
32
+
33
+ - (void)setupAudioFormat:(AudioStreamBasicDescription*)format
34
+ {
35
+ format->mSampleRate = 16000;
36
+ format->mFormatID = kAudioFormatLinearPCM;
37
+ format->mFramesPerPacket = 1;
38
+ format->mChannelsPerFrame = 1;
39
+ format->mBytesPerFrame = 2;
40
+ format->mBytesPerPacket = 2;
41
+ format->mBitsPerChannel = 16;
42
+ format->mReserved = 0;
43
+ format->mFormatFlags = kLinearPCMFormatFlagIsSignedInteger;
44
+ }
45
+
46
+ - (void)viewDidLoad {
47
+ [super viewDidLoad];
48
+
49
+ // whisper.cpp initialization
50
+ {
51
+ // load the model
52
+ NSString *modelPath = [[NSBundle mainBundle] pathForResource:@"ggml-base.en" ofType:@"bin"];
53
+
54
+ // check if the model exists
55
+ if (![[NSFileManager defaultManager] fileExistsAtPath:modelPath]) {
56
+ NSLog(@"Model file not found");
57
+ return;
58
+ }
59
+
60
+ NSLog(@"Loading model from %@", modelPath);
61
+
62
+ // create ggml context
63
+ stateInp.ctx = whisper_init([modelPath UTF8String]);
64
+
65
+ // check if the model was loaded successfully
66
+ if (stateInp.ctx == NULL) {
67
+ NSLog(@"Failed to load model");
68
+ return;
69
+ }
70
+ }
71
+
72
+ // initialize audio format and buffers
73
+ {
74
+ [self setupAudioFormat:&stateInp.dataFormat];
75
+
76
+ stateInp.n_samples = 0;
77
+ stateInp.audioBufferI16 = malloc(MAX_AUDIO_SEC*SAMPLE_RATE*sizeof(int16_t));
78
+ stateInp.audioBufferF32 = malloc(MAX_AUDIO_SEC*SAMPLE_RATE*sizeof(float));
79
+ }
80
+ }
81
+
82
+ -(IBAction) stopCapturing {
83
+ NSLog(@"Stop capturing");
84
+
85
+ _labelStatusInp.text = @"Status: Idle";
86
+
87
+ stateInp.isCapturing = false;
88
+
89
+ AudioQueueStop(stateInp.queue, true);
90
+ for (int i = 0; i < NUM_BUFFERS; i++) {
91
+ AudioQueueFreeBuffer(stateInp.queue, stateInp.buffers[i]);
92
+ }
93
+
94
+ AudioQueueDispose(stateInp.queue, true);
95
+ }
96
+
97
+ - (IBAction)toggleCapture:(id)sender {
98
+ if (stateInp.isCapturing) {
99
+ // stop capturing
100
+ [self stopCapturing];
101
+ [sender setTitle:@"Start Capturing" forState:UIControlStateNormal];
102
+
103
+ return;
104
+ }
105
+
106
+ // initiate audio capturing
107
+ NSLog(@"Start capturing");
108
+
109
+ stateInp.n_samples = 0;
110
+
111
+ OSStatus status = AudioQueueNewInput(&stateInp.dataFormat,
112
+ AudioInputCallback,
113
+ &stateInp,
114
+ CFRunLoopGetCurrent(),
115
+ kCFRunLoopCommonModes,
116
+ 0,
117
+ &stateInp.queue);
118
+
119
+ if (status == 0) {
120
+ for (int i = 0; i < NUM_BUFFERS; i++) {
121
+ AudioQueueAllocateBuffer(stateInp.queue, NUM_BYTES_PER_BUFFER, &stateInp.buffers[i]);
122
+ AudioQueueEnqueueBuffer (stateInp.queue, stateInp.buffers[i], 0, NULL);
123
+ }
124
+
125
+ stateInp.isCapturing = true;
126
+ status = AudioQueueStart(stateInp.queue, NULL);
127
+ if (status == 0) {
128
+ _labelStatusInp.text = @"Status: Capturing";
129
+ [sender setTitle:@"Stop Capturing" forState:UIControlStateNormal];
130
+ }
131
+ }
132
+
133
+ if (status != 0) {
134
+ [self stopCapturing];
135
+ }
136
+ }
137
+
138
+ - (IBAction)onTranscribePrepare:(id)sender {
139
+ _textviewResult.text = @"Processing - please wait ...";
140
+
141
+ if (stateInp.isCapturing) {
142
+ // stop capturing
143
+ [self stopCapturing];
144
+ [sender setTitle:@"Start Capturing" forState:UIControlStateNormal];
145
+
146
+ return;
147
+ }
148
+ }
149
+
150
+ - (IBAction)onTranscribe:(id)sender {
151
+ NSLog(@"Processing %d samples", stateInp.n_samples);
152
+
153
+ // process captured audio
154
+ // convert I16 to F32
155
+ for (int i = 0; i < stateInp.n_samples; i++) {
156
+ stateInp.audioBufferF32[i] = (float)stateInp.audioBufferI16[i] / 32768.0f;
157
+ }
158
+
159
+ // run the model
160
+ struct whisper_full_params params = whisper_full_default_params(WHISPER_SAMPLING_GREEDY);
161
+
162
+ params.print_realtime = true;
163
+ params.print_progress = false;
164
+ params.print_timestamps = true;
165
+ params.print_special_tokens = false;
166
+ params.translate = false;
167
+ params.language = "en";
168
+ params.n_threads = 4;
169
+ params.offset_ms = 0;
170
+
171
+ if (whisper_full(stateInp.ctx, params, stateInp.audioBufferF32, stateInp.n_samples) != 0) {
172
+ NSLog(@"Failed to run the model");
173
+ _textviewResult.text = @"Failed to run the model";
174
+
175
+ return;
176
+ }
177
+
178
+ // clear the text in the textview
179
+ _textviewResult.text = @"";
180
+
181
+ int n_segments = whisper_full_n_segments(stateInp.ctx);
182
+ for (int i = 0; i < n_segments; i++) {
183
+ const char * text_cur = whisper_full_get_segment_text(stateInp.ctx, i);
184
+
185
+ // append the text to the textview
186
+ _textviewResult.text = [_textviewResult.text stringByAppendingString:[NSString stringWithUTF8String:text_cur]];
187
+ }
188
+
189
+ whisper_print_timings(stateInp.ctx);
190
+ }
191
+
192
+ //
193
+ // Callback implmentation
194
+ //
195
+
196
+ void AudioInputCallback(void * inUserData,
197
+ AudioQueueRef inAQ,
198
+ AudioQueueBufferRef inBuffer,
199
+ const AudioTimeStamp * inStartTime,
200
+ UInt32 inNumberPacketDescriptions,
201
+ const AudioStreamPacketDescription * inPacketDescs)
202
+ {
203
+ StateInp * stateInp = (StateInp*)inUserData;
204
+
205
+ if (!stateInp->isCapturing) {
206
+ NSLog(@"Not capturing, ignoring audio");
207
+ return;
208
+ }
209
+
210
+ const int n = inBuffer->mAudioDataByteSize / 2;
211
+
212
+ NSLog(@"Captured %d new samples", n);
213
+
214
+ if (stateInp->n_samples + n > MAX_AUDIO_SEC*SAMPLE_RATE) {
215
+ NSLog(@"Too much audio data, ignoring");
216
+ return;
217
+ }
218
+
219
+ for (int i = 0; i < n; i++) {
220
+ stateInp->audioBufferI16[stateInp->n_samples + i] = ((short*)inBuffer->mAudioData)[i];
221
+ }
222
+
223
+ stateInp->n_samples += n;
224
+
225
+ // put the buffer back in the queue
226
+ AudioQueueEnqueueBuffer(stateInp->queue, inBuffer, 0, NULL);
227
+ }
228
+
229
+ @end
examples/whisper.objc/whisper.objc/main.m ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //
2
+ // main.m
3
+ // whisper.objc
4
+ //
5
+ // Created by Georgi Gerganov on 23.10.22.
6
+ //
7
+
8
+ #import <UIKit/UIKit.h>
9
+ #import "AppDelegate.h"
10
+
11
+ int main(int argc, char * argv[]) {
12
+ NSString * appDelegateClassName;
13
+ @autoreleasepool {
14
+ // Setup code that might create autoreleased objects goes here.
15
+ appDelegateClassName = NSStringFromClass([AppDelegate class]);
16
+ }
17
+ return UIApplicationMain(argc, argv, nil, appDelegateClassName);
18
+ }