whisper.rn 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +20 -0
- package/README.md +82 -0
- package/android/build.gradle +85 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +4 -0
- package/android/src/main/java/com/rnwhisper/RNWhisperModule.java +175 -0
- package/android/src/main/java/com/rnwhisper/RNWhisperPackage.java +28 -0
- package/android/src/main/java/com/rnwhisper/WhisperContext.java +186 -0
- package/android/src/main/jni/whisper/Android.mk +26 -0
- package/android/src/main/jni/whisper/Application.mk +1 -0
- package/android/src/main/jni/whisper/Whisper.mk +18 -0
- package/android/src/main/jni/whisper/jni.c +159 -0
- package/ios/RNWhisper.h +9 -0
- package/ios/RNWhisper.mm +199 -0
- package/ios/RNWhisper.xcodeproj/project.pbxproj +278 -0
- package/ios/RNWhisper.xcodeproj/project.xcworkspace/contents.xcworkspacedata +4 -0
- package/ios/RNWhisper.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/ios/RNWhisper.xcodeproj/project.xcworkspace/xcuserdata/jhen.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/RNWhisper.xcodeproj/xcuserdata/jhen.xcuserdatad/xcschemes/xcschememanagement.plist +14 -0
- package/jest/mock.js +12 -0
- package/lib/commonjs/index.js +42 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/module/index.js +35 -0
- package/lib/module/index.js.map +1 -0
- package/lib/typescript/index.d.ts +28 -0
- package/lib/typescript/index.d.ts.map +1 -0
- package/package.json +132 -0
- package/src/index.tsx +63 -0
- package/whisper-rn.podspec +41 -0
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
#include <jni.h>
|
|
2
|
+
#include <android/asset_manager.h>
|
|
3
|
+
#include <android/asset_manager_jni.h>
|
|
4
|
+
#include <android/log.h>
|
|
5
|
+
#include <stdlib.h>
|
|
6
|
+
#include <sys/sysinfo.h>
|
|
7
|
+
#include <string.h>
|
|
8
|
+
#include "whisper.h"
|
|
9
|
+
#include "ggml.h"
|
|
10
|
+
|
|
11
|
+
#define UNUSED(x) (void)(x)
|
|
12
|
+
#define TAG "JNI"
|
|
13
|
+
|
|
14
|
+
#define LOGI(...) __android_log_print(ANDROID_LOG_INFO, TAG, __VA_ARGS__)
|
|
15
|
+
#define LOGW(...) __android_log_print(ANDROID_LOG_WARN, TAG, __VA_ARGS__)
|
|
16
|
+
|
|
17
|
+
static inline int min(int a, int b) {
|
|
18
|
+
return (a < b) ? a : b;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
static inline int max(int a, int b) {
|
|
22
|
+
return (a > b) ? a : b;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
static size_t asset_read(void *ctx, void *output, size_t read_size) {
|
|
26
|
+
return AAsset_read((AAsset *) ctx, output, read_size);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
static bool asset_is_eof(void *ctx) {
|
|
30
|
+
return AAsset_getRemainingLength64((AAsset *) ctx) <= 0;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
static void asset_close(void *ctx) {
|
|
34
|
+
AAsset_close((AAsset *) ctx);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
JNIEXPORT jlong JNICALL
|
|
38
|
+
Java_com_rnwhisper_WhisperContext_initContext(
|
|
39
|
+
JNIEnv *env, jobject thiz, jstring model_path_str) {
|
|
40
|
+
UNUSED(thiz);
|
|
41
|
+
struct whisper_context *context = NULL;
|
|
42
|
+
const char *model_path_chars = (*env)->GetStringUTFChars(env, model_path_str, NULL);
|
|
43
|
+
context = whisper_init_from_file(model_path_chars);
|
|
44
|
+
(*env)->ReleaseStringUTFChars(env, model_path_str, model_path_chars);
|
|
45
|
+
return (jlong) context;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
JNIEXPORT jint JNICALL
|
|
49
|
+
Java_com_rnwhisper_WhisperContext_fullTranscribe(
|
|
50
|
+
JNIEnv *env,
|
|
51
|
+
jobject thiz,
|
|
52
|
+
jlong context_ptr,
|
|
53
|
+
jfloatArray audio_data,
|
|
54
|
+
jint n_threads,
|
|
55
|
+
jint max_context,
|
|
56
|
+
jint max_len,
|
|
57
|
+
jint offset,
|
|
58
|
+
jint duration,
|
|
59
|
+
jint word_thold,
|
|
60
|
+
jfloat temperature,
|
|
61
|
+
jfloat temperature_inc,
|
|
62
|
+
jint beam_size,
|
|
63
|
+
jint best_of,
|
|
64
|
+
jboolean speed_up,
|
|
65
|
+
jboolean translate,
|
|
66
|
+
jstring language
|
|
67
|
+
) {
|
|
68
|
+
UNUSED(thiz);
|
|
69
|
+
struct whisper_context *context = (struct whisper_context *) context_ptr;
|
|
70
|
+
jfloat *audio_data_arr = (*env)->GetFloatArrayElements(env, audio_data, NULL);
|
|
71
|
+
const jsize audio_data_length = (*env)->GetArrayLength(env, audio_data);
|
|
72
|
+
|
|
73
|
+
int max_threads = max(1, min(8, get_nprocs() - 2));
|
|
74
|
+
|
|
75
|
+
LOGI("About to create params");
|
|
76
|
+
|
|
77
|
+
struct whisper_full_params params = whisper_full_default_params(WHISPER_SAMPLING_GREEDY);
|
|
78
|
+
|
|
79
|
+
if (beam_size > -1) {
|
|
80
|
+
params.strategy = WHISPER_SAMPLING_BEAM_SEARCH;
|
|
81
|
+
params.beam_search.beam_size = beam_size;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
params.print_realtime = false;
|
|
85
|
+
params.print_progress = false;
|
|
86
|
+
params.print_timestamps = false;
|
|
87
|
+
params.print_special = false;
|
|
88
|
+
params.translate = translate;
|
|
89
|
+
params.language = language;
|
|
90
|
+
params.n_threads = n_threads > 0 ? n_threads : max_threads;
|
|
91
|
+
params.speed_up = speed_up;
|
|
92
|
+
params.offset_ms = 0;
|
|
93
|
+
params.no_context = true;
|
|
94
|
+
params.single_segment = false;
|
|
95
|
+
|
|
96
|
+
if (best_of > -1) {
|
|
97
|
+
params.greedy.best_of = best_of;
|
|
98
|
+
}
|
|
99
|
+
if (max_context > -1) {
|
|
100
|
+
params.n_max_text_ctx = max_context;
|
|
101
|
+
}
|
|
102
|
+
if (max_len > -1) {
|
|
103
|
+
params.max_len = max_len;
|
|
104
|
+
}
|
|
105
|
+
if (offset > -1) {
|
|
106
|
+
params.offset_ms = offset;
|
|
107
|
+
}
|
|
108
|
+
if (duration > -1) {
|
|
109
|
+
params.duration_ms = duration;
|
|
110
|
+
}
|
|
111
|
+
if (word_thold > -1) {
|
|
112
|
+
params.thold_pt = word_thold;
|
|
113
|
+
}
|
|
114
|
+
if (temperature > -1) {
|
|
115
|
+
params.temperature = temperature;
|
|
116
|
+
}
|
|
117
|
+
if (temperature_inc > -1) {
|
|
118
|
+
params.temperature_inc = temperature_inc;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
LOGI("About to reset timings");
|
|
122
|
+
whisper_reset_timings(context);
|
|
123
|
+
|
|
124
|
+
LOGI("About to run whisper_full");
|
|
125
|
+
int code = whisper_full(context, params, audio_data_arr, audio_data_length);
|
|
126
|
+
if (code == 0) {
|
|
127
|
+
// whisper_print_timings(context);
|
|
128
|
+
}
|
|
129
|
+
(*env)->ReleaseFloatArrayElements(env, audio_data, audio_data_arr, JNI_ABORT);
|
|
130
|
+
return code;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
JNIEXPORT jint JNICALL
|
|
134
|
+
Java_com_rnwhisper_WhisperContext_getTextSegmentCount(
|
|
135
|
+
JNIEnv *env, jobject thiz, jlong context_ptr) {
|
|
136
|
+
UNUSED(env);
|
|
137
|
+
UNUSED(thiz);
|
|
138
|
+
struct whisper_context *context = (struct whisper_context *) context_ptr;
|
|
139
|
+
return whisper_full_n_segments(context);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
JNIEXPORT jstring JNICALL
|
|
143
|
+
Java_com_rnwhisper_WhisperContext_getTextSegment(
|
|
144
|
+
JNIEnv *env, jobject thiz, jlong context_ptr, jint index) {
|
|
145
|
+
UNUSED(thiz);
|
|
146
|
+
struct whisper_context *context = (struct whisper_context *) context_ptr;
|
|
147
|
+
const char *text = whisper_full_get_segment_text(context, index);
|
|
148
|
+
jstring string = (*env)->NewStringUTF(env, text);
|
|
149
|
+
return string;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
JNIEXPORT void JNICALL
|
|
153
|
+
Java_com_rnwhisper_WhisperContext_freeContext(
|
|
154
|
+
JNIEnv *env, jobject thiz, jlong context_ptr) {
|
|
155
|
+
UNUSED(env);
|
|
156
|
+
UNUSED(thiz);
|
|
157
|
+
struct whisper_context *context = (struct whisper_context *) context_ptr;
|
|
158
|
+
whisper_free(context);
|
|
159
|
+
}
|
package/ios/RNWhisper.h
ADDED
package/ios/RNWhisper.mm
ADDED
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
|
|
2
|
+
#import "RNWhisper.h"
|
|
3
|
+
#include <stdlib.h>
|
|
4
|
+
|
|
5
|
+
@interface WhisperContext : NSObject {
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
@property struct whisper_context * ctx;
|
|
9
|
+
|
|
10
|
+
@end
|
|
11
|
+
|
|
12
|
+
@implementation WhisperContext
|
|
13
|
+
|
|
14
|
+
- (void)invalidate {
|
|
15
|
+
whisper_free(self.ctx);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
@end
|
|
19
|
+
|
|
20
|
+
@implementation RNWhisper
|
|
21
|
+
|
|
22
|
+
NSMutableDictionary *contexts;
|
|
23
|
+
|
|
24
|
+
RCT_EXPORT_MODULE()
|
|
25
|
+
|
|
26
|
+
RCT_REMAP_METHOD(initContext,
|
|
27
|
+
withPath:(NSString *)modelPath
|
|
28
|
+
withResolver:(RCTPromiseResolveBlock)resolve
|
|
29
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
30
|
+
{
|
|
31
|
+
if (contexts == nil) {
|
|
32
|
+
contexts = [[NSMutableDictionary alloc] init];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
WhisperContext *context = [[WhisperContext alloc] init];
|
|
36
|
+
context.ctx = whisper_init_from_file([modelPath UTF8String]);
|
|
37
|
+
|
|
38
|
+
if (context.ctx == NULL) {
|
|
39
|
+
reject(@"whisper_cpp_error", @"Failed to load the model", nil);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
int contextId = arc4random_uniform(1000000);
|
|
44
|
+
[contexts setObject:context forKey:[NSNumber numberWithInt:contextId]];
|
|
45
|
+
|
|
46
|
+
resolve([NSNumber numberWithInt:contextId]);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
RCT_REMAP_METHOD(transcribe,
|
|
50
|
+
withContextId:(int)contextId
|
|
51
|
+
withWaveFile:(NSString *)waveFilePath
|
|
52
|
+
withOptions:(NSDictionary *)options
|
|
53
|
+
withResolver:(RCTPromiseResolveBlock)resolve
|
|
54
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
55
|
+
{
|
|
56
|
+
WhisperContext *context = contexts[[NSNumber numberWithInt:contextId]];
|
|
57
|
+
|
|
58
|
+
if (context == nil) {
|
|
59
|
+
reject(@"whisper_error", @"Context not found", nil);
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
NSURL *url = [NSURL fileURLWithPath:waveFilePath];
|
|
64
|
+
|
|
65
|
+
int count = 0;
|
|
66
|
+
float *waveFile = [self decodeWaveFile:url count:&count];
|
|
67
|
+
|
|
68
|
+
if (waveFile == nil) {
|
|
69
|
+
reject(@"whisper_error", @"Invalid file", nil);
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
struct whisper_full_params params = whisper_full_default_params(WHISPER_SAMPLING_GREEDY);
|
|
74
|
+
|
|
75
|
+
const int max_threads = options[@"maxThreads"] != nil ?
|
|
76
|
+
[options[@"maxThreads"] intValue] :
|
|
77
|
+
MIN(8, (int)[[NSProcessInfo processInfo] processorCount]) - 2;
|
|
78
|
+
|
|
79
|
+
if (options[@"beamSize"] != nil) {
|
|
80
|
+
params.strategy = WHISPER_SAMPLING_BEAM_SEARCH;
|
|
81
|
+
params.beam_search.beam_size = [options[@"beamSize"] intValue];
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
params.print_realtime = false;
|
|
85
|
+
params.print_progress = false;
|
|
86
|
+
params.print_timestamps = false;
|
|
87
|
+
params.print_special = false;
|
|
88
|
+
params.speed_up = options[@"speedUp"] != nil ? [options[@"speedUp"] boolValue] : false;
|
|
89
|
+
params.translate = options[@"translate"] != nil ? [options[@"translate"] boolValue] : false;
|
|
90
|
+
params.language = options[@"language"] != nil ? [options[@"language"] UTF8String] : "auto";
|
|
91
|
+
params.n_threads = max_threads;
|
|
92
|
+
params.offset_ms = 0;
|
|
93
|
+
params.no_context = true;
|
|
94
|
+
params.single_segment = false;
|
|
95
|
+
|
|
96
|
+
if (options[@"bestOf"] != nil) {
|
|
97
|
+
params.greedy.best_of = [options[@"bestOf"] intValue];
|
|
98
|
+
}
|
|
99
|
+
if (options[@"maxContext"] != nil) {
|
|
100
|
+
params.n_max_text_ctx = [options[@"maxContext"] intValue];
|
|
101
|
+
}
|
|
102
|
+
if (options[@"maxLen"] != nil) {
|
|
103
|
+
params.max_len = [options[@"maxLen"] intValue];
|
|
104
|
+
}
|
|
105
|
+
if (options[@"offset"] != nil) {
|
|
106
|
+
params.offset_ms = [options[@"offset"] intValue];
|
|
107
|
+
}
|
|
108
|
+
if (options[@"duration"] != nil) {
|
|
109
|
+
params.duration_ms = [options[@"duration"] intValue];
|
|
110
|
+
}
|
|
111
|
+
if (options[@"wordThold"] != nil) {
|
|
112
|
+
params.thold_pt = [options[@"wordThold"] intValue];
|
|
113
|
+
}
|
|
114
|
+
if (options[@"temperature"] != nil) {
|
|
115
|
+
params.temperature = [options[@"temperature"] floatValue];
|
|
116
|
+
}
|
|
117
|
+
if (options[@"temperatureInc"] != nil) {
|
|
118
|
+
params.temperature_inc = [options[@"temperature_inc"] floatValue];
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
whisper_reset_timings(context.ctx);
|
|
122
|
+
int code = whisper_full(context.ctx, params, waveFile, count);
|
|
123
|
+
if (code != 0) {
|
|
124
|
+
NSLog(@"Failed to run the model");
|
|
125
|
+
free(waveFile);
|
|
126
|
+
reject(@"whisper_cpp_error", [NSString stringWithFormat:@"Failed to run the model. Code: %d", code], nil);
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// whisper_print_timings(context.ctx);
|
|
131
|
+
free(waveFile);
|
|
132
|
+
|
|
133
|
+
NSString *result = @"";
|
|
134
|
+
int n_segments = whisper_full_n_segments(context.ctx);
|
|
135
|
+
for (int i = 0; i < n_segments; i++) {
|
|
136
|
+
const char * text_cur = whisper_full_get_segment_text(context.ctx, i);
|
|
137
|
+
result = [result stringByAppendingString:[NSString stringWithUTF8String:text_cur]];
|
|
138
|
+
}
|
|
139
|
+
resolve(result);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
RCT_REMAP_METHOD(releaseContext,
|
|
143
|
+
withContextId:(int)contextId
|
|
144
|
+
withResolver:(RCTPromiseResolveBlock)resolve
|
|
145
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
146
|
+
{
|
|
147
|
+
WhisperContext *context = contexts[[NSNumber numberWithInt:contextId]];
|
|
148
|
+
if (context == nil) {
|
|
149
|
+
reject(@"whisper_error", @"Context not found", nil);
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
[context invalidate];
|
|
153
|
+
[contexts removeObjectForKey:[NSNumber numberWithInt:contextId]];
|
|
154
|
+
resolve(nil);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
RCT_REMAP_METHOD(releaseAllContexts,
|
|
158
|
+
withResolver:(RCTPromiseResolveBlock)resolve
|
|
159
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
160
|
+
{
|
|
161
|
+
[self invalidate];
|
|
162
|
+
resolve(nil);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
- (float *)decodeWaveFile:(NSURL*)fileURL count:(int *)count {
|
|
166
|
+
NSData *fileData = [NSData dataWithContentsOfURL:fileURL];
|
|
167
|
+
if (fileData == nil) {
|
|
168
|
+
return nil;
|
|
169
|
+
}
|
|
170
|
+
NSMutableData *waveData = [[NSMutableData alloc] init];
|
|
171
|
+
[waveData appendData:[fileData subdataWithRange:NSMakeRange(44, [fileData length]-44)]];
|
|
172
|
+
const short *shortArray = (const short *)[waveData bytes];
|
|
173
|
+
int shortCount = (int) ([waveData length] / sizeof(short));
|
|
174
|
+
float *floatArray = (float *) malloc(shortCount * sizeof(float));
|
|
175
|
+
for (NSInteger i = 0; i < shortCount; i++) {
|
|
176
|
+
float floatValue = ((float)shortArray[i]) / 32767.0;
|
|
177
|
+
floatValue = MAX(floatValue, -1.0);
|
|
178
|
+
floatValue = MIN(floatValue, 1.0);
|
|
179
|
+
floatArray[i] = floatValue;
|
|
180
|
+
}
|
|
181
|
+
*count = shortCount;
|
|
182
|
+
return floatArray;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
- (void)invalidate {
|
|
186
|
+
if (contexts == nil) {
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
for (NSNumber *contextId in contexts) {
|
|
191
|
+
WhisperContext *context = contexts[contextId];
|
|
192
|
+
[context invalidate];
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
[contexts removeAllObjects];
|
|
196
|
+
contexts = nil;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
@end
|
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
// !$*UTF8*$!
|
|
2
|
+
{
|
|
3
|
+
archiveVersion = 1;
|
|
4
|
+
classes = {
|
|
5
|
+
};
|
|
6
|
+
objectVersion = 46;
|
|
7
|
+
objects = {
|
|
8
|
+
|
|
9
|
+
/* Begin PBXBuildFile section */
|
|
10
|
+
5E555C0D2413F4C50049A1A2 /* RNWhisper.mm in Sources */ = {isa = PBXBuildFile; fileRef = B3E7B5891CC2AC0600A0062D /* RNWhisper.mm */; };
|
|
11
|
+
/* End PBXBuildFile section */
|
|
12
|
+
|
|
13
|
+
/* Begin PBXCopyFilesBuildPhase section */
|
|
14
|
+
58B511D91A9E6C8500147676 /* CopyFiles */ = {
|
|
15
|
+
isa = PBXCopyFilesBuildPhase;
|
|
16
|
+
buildActionMask = 2147483647;
|
|
17
|
+
dstPath = "include/$(PRODUCT_NAME)";
|
|
18
|
+
dstSubfolderSpec = 16;
|
|
19
|
+
files = (
|
|
20
|
+
);
|
|
21
|
+
runOnlyForDeploymentPostprocessing = 0;
|
|
22
|
+
};
|
|
23
|
+
/* End PBXCopyFilesBuildPhase section */
|
|
24
|
+
|
|
25
|
+
/* Begin PBXFileReference section */
|
|
26
|
+
134814201AA4EA6300B7C361 /* libRNWhisper.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRNWhisper.a; sourceTree = BUILT_PRODUCTS_DIR; };
|
|
27
|
+
B3E7B5891CC2AC0600A0062D /* RNWhisper.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RNWhisper.mm; sourceTree = "<group>"; };
|
|
28
|
+
/* End PBXFileReference section */
|
|
29
|
+
|
|
30
|
+
/* Begin PBXFrameworksBuildPhase section */
|
|
31
|
+
58B511D81A9E6C8500147676 /* Frameworks */ = {
|
|
32
|
+
isa = PBXFrameworksBuildPhase;
|
|
33
|
+
buildActionMask = 2147483647;
|
|
34
|
+
files = (
|
|
35
|
+
);
|
|
36
|
+
runOnlyForDeploymentPostprocessing = 0;
|
|
37
|
+
};
|
|
38
|
+
/* End PBXFrameworksBuildPhase section */
|
|
39
|
+
|
|
40
|
+
/* Begin PBXGroup section */
|
|
41
|
+
134814211AA4EA7D00B7C361 /* Products */ = {
|
|
42
|
+
isa = PBXGroup;
|
|
43
|
+
children = (
|
|
44
|
+
134814201AA4EA6300B7C361 /* libRNWhisper.a */,
|
|
45
|
+
);
|
|
46
|
+
name = Products;
|
|
47
|
+
sourceTree = "<group>";
|
|
48
|
+
};
|
|
49
|
+
58B511D21A9E6C8500147676 = {
|
|
50
|
+
isa = PBXGroup;
|
|
51
|
+
children = (
|
|
52
|
+
B3E7B5891CC2AC0600A0062D /* RNWhisper.mm */,
|
|
53
|
+
134814211AA4EA7D00B7C361 /* Products */,
|
|
54
|
+
);
|
|
55
|
+
sourceTree = "<group>";
|
|
56
|
+
};
|
|
57
|
+
/* End PBXGroup section */
|
|
58
|
+
|
|
59
|
+
/* Begin PBXNativeTarget section */
|
|
60
|
+
58B511DA1A9E6C8500147676 /* RNWhisper */ = {
|
|
61
|
+
isa = PBXNativeTarget;
|
|
62
|
+
buildConfigurationList = 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "RNWhisper" */;
|
|
63
|
+
buildPhases = (
|
|
64
|
+
58B511D71A9E6C8500147676 /* Sources */,
|
|
65
|
+
58B511D81A9E6C8500147676 /* Frameworks */,
|
|
66
|
+
58B511D91A9E6C8500147676 /* CopyFiles */,
|
|
67
|
+
);
|
|
68
|
+
buildRules = (
|
|
69
|
+
);
|
|
70
|
+
dependencies = (
|
|
71
|
+
);
|
|
72
|
+
name = RNWhisper;
|
|
73
|
+
productName = RCTDataManager;
|
|
74
|
+
productReference = 134814201AA4EA6300B7C361 /* libRNWhisper.a */;
|
|
75
|
+
productType = "com.apple.product-type.library.static";
|
|
76
|
+
};
|
|
77
|
+
/* End PBXNativeTarget section */
|
|
78
|
+
|
|
79
|
+
/* Begin PBXProject section */
|
|
80
|
+
58B511D31A9E6C8500147676 /* Project object */ = {
|
|
81
|
+
isa = PBXProject;
|
|
82
|
+
attributes = {
|
|
83
|
+
LastUpgradeCheck = 0920;
|
|
84
|
+
ORGANIZATIONNAME = Facebook;
|
|
85
|
+
TargetAttributes = {
|
|
86
|
+
58B511DA1A9E6C8500147676 = {
|
|
87
|
+
CreatedOnToolsVersion = 6.1.1;
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
buildConfigurationList = 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "RNWhisper" */;
|
|
92
|
+
compatibilityVersion = "Xcode 3.2";
|
|
93
|
+
developmentRegion = English;
|
|
94
|
+
hasScannedForEncodings = 0;
|
|
95
|
+
knownRegions = (
|
|
96
|
+
English,
|
|
97
|
+
en,
|
|
98
|
+
);
|
|
99
|
+
mainGroup = 58B511D21A9E6C8500147676;
|
|
100
|
+
productRefGroup = 58B511D21A9E6C8500147676;
|
|
101
|
+
projectDirPath = "";
|
|
102
|
+
projectRoot = "";
|
|
103
|
+
targets = (
|
|
104
|
+
58B511DA1A9E6C8500147676 /* RNWhisper */,
|
|
105
|
+
);
|
|
106
|
+
};
|
|
107
|
+
/* End PBXProject section */
|
|
108
|
+
|
|
109
|
+
/* Begin PBXSourcesBuildPhase section */
|
|
110
|
+
58B511D71A9E6C8500147676 /* Sources */ = {
|
|
111
|
+
isa = PBXSourcesBuildPhase;
|
|
112
|
+
buildActionMask = 2147483647;
|
|
113
|
+
files = (
|
|
114
|
+
5E555C0D2413F4C50049A1A2 /* RNWhisper.mm in Sources */,
|
|
115
|
+
);
|
|
116
|
+
runOnlyForDeploymentPostprocessing = 0;
|
|
117
|
+
};
|
|
118
|
+
/* End PBXSourcesBuildPhase section */
|
|
119
|
+
|
|
120
|
+
/* Begin XCBuildConfiguration section */
|
|
121
|
+
58B511ED1A9E6C8500147676 /* Debug */ = {
|
|
122
|
+
isa = XCBuildConfiguration;
|
|
123
|
+
buildSettings = {
|
|
124
|
+
ALWAYS_SEARCH_USER_PATHS = NO;
|
|
125
|
+
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
|
126
|
+
CLANG_CXX_LIBRARY = "libc++";
|
|
127
|
+
CLANG_ENABLE_MODULES = YES;
|
|
128
|
+
CLANG_ENABLE_OBJC_ARC = YES;
|
|
129
|
+
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
|
130
|
+
CLANG_WARN_BOOL_CONVERSION = YES;
|
|
131
|
+
CLANG_WARN_COMMA = YES;
|
|
132
|
+
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
|
133
|
+
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
|
134
|
+
CLANG_WARN_EMPTY_BODY = YES;
|
|
135
|
+
CLANG_WARN_ENUM_CONVERSION = YES;
|
|
136
|
+
CLANG_WARN_INFINITE_RECURSION = YES;
|
|
137
|
+
CLANG_WARN_INT_CONVERSION = YES;
|
|
138
|
+
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
|
139
|
+
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
|
140
|
+
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
|
141
|
+
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
|
142
|
+
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
|
143
|
+
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
|
144
|
+
CLANG_WARN_UNREACHABLE_CODE = YES;
|
|
145
|
+
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
|
146
|
+
COPY_PHASE_STRIP = NO;
|
|
147
|
+
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
|
148
|
+
ENABLE_TESTABILITY = YES;
|
|
149
|
+
"EXCLUDED_ARCHS[sdk=*]" = arm64;
|
|
150
|
+
GCC_C_LANGUAGE_STANDARD = gnu99;
|
|
151
|
+
GCC_DYNAMIC_NO_PIC = NO;
|
|
152
|
+
GCC_NO_COMMON_BLOCKS = YES;
|
|
153
|
+
GCC_OPTIMIZATION_LEVEL = 0;
|
|
154
|
+
GCC_PREPROCESSOR_DEFINITIONS = (
|
|
155
|
+
"DEBUG=1",
|
|
156
|
+
"$(inherited)",
|
|
157
|
+
);
|
|
158
|
+
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
|
|
159
|
+
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
|
160
|
+
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
|
161
|
+
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
|
162
|
+
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
|
163
|
+
GCC_WARN_UNUSED_FUNCTION = YES;
|
|
164
|
+
GCC_WARN_UNUSED_VARIABLE = YES;
|
|
165
|
+
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
|
166
|
+
MTL_ENABLE_DEBUG_INFO = YES;
|
|
167
|
+
ONLY_ACTIVE_ARCH = YES;
|
|
168
|
+
SDKROOT = iphoneos;
|
|
169
|
+
};
|
|
170
|
+
name = Debug;
|
|
171
|
+
};
|
|
172
|
+
58B511EE1A9E6C8500147676 /* Release */ = {
|
|
173
|
+
isa = XCBuildConfiguration;
|
|
174
|
+
buildSettings = {
|
|
175
|
+
ALWAYS_SEARCH_USER_PATHS = NO;
|
|
176
|
+
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
|
177
|
+
CLANG_CXX_LIBRARY = "libc++";
|
|
178
|
+
CLANG_ENABLE_MODULES = YES;
|
|
179
|
+
CLANG_ENABLE_OBJC_ARC = YES;
|
|
180
|
+
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
|
181
|
+
CLANG_WARN_BOOL_CONVERSION = YES;
|
|
182
|
+
CLANG_WARN_COMMA = YES;
|
|
183
|
+
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
|
184
|
+
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
|
185
|
+
CLANG_WARN_EMPTY_BODY = YES;
|
|
186
|
+
CLANG_WARN_ENUM_CONVERSION = YES;
|
|
187
|
+
CLANG_WARN_INFINITE_RECURSION = YES;
|
|
188
|
+
CLANG_WARN_INT_CONVERSION = YES;
|
|
189
|
+
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
|
190
|
+
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
|
191
|
+
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
|
192
|
+
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
|
193
|
+
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
|
194
|
+
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
|
195
|
+
CLANG_WARN_UNREACHABLE_CODE = YES;
|
|
196
|
+
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
|
197
|
+
COPY_PHASE_STRIP = YES;
|
|
198
|
+
ENABLE_NS_ASSERTIONS = NO;
|
|
199
|
+
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
|
200
|
+
"EXCLUDED_ARCHS[sdk=*]" = arm64;
|
|
201
|
+
GCC_C_LANGUAGE_STANDARD = gnu99;
|
|
202
|
+
GCC_NO_COMMON_BLOCKS = YES;
|
|
203
|
+
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
|
204
|
+
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
|
205
|
+
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
|
206
|
+
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
|
207
|
+
GCC_WARN_UNUSED_FUNCTION = YES;
|
|
208
|
+
GCC_WARN_UNUSED_VARIABLE = YES;
|
|
209
|
+
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
|
210
|
+
MTL_ENABLE_DEBUG_INFO = NO;
|
|
211
|
+
SDKROOT = iphoneos;
|
|
212
|
+
VALIDATE_PRODUCT = YES;
|
|
213
|
+
};
|
|
214
|
+
name = Release;
|
|
215
|
+
};
|
|
216
|
+
58B511F01A9E6C8500147676 /* Debug */ = {
|
|
217
|
+
isa = XCBuildConfiguration;
|
|
218
|
+
buildSettings = {
|
|
219
|
+
HEADER_SEARCH_PATHS = (
|
|
220
|
+
"$(inherited)",
|
|
221
|
+
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
|
|
222
|
+
"$(SRCROOT)/../../../React/**",
|
|
223
|
+
"$(SRCROOT)/../../react-native/React/**",
|
|
224
|
+
);
|
|
225
|
+
LIBRARY_SEARCH_PATHS = "$(inherited)";
|
|
226
|
+
OTHER_LDFLAGS = (
|
|
227
|
+
"-ObjC",
|
|
228
|
+
);
|
|
229
|
+
PRODUCT_NAME = RNWhisper;
|
|
230
|
+
SKIP_INSTALL = YES;
|
|
231
|
+
};
|
|
232
|
+
name = Debug;
|
|
233
|
+
};
|
|
234
|
+
58B511F11A9E6C8500147676 /* Release */ = {
|
|
235
|
+
isa = XCBuildConfiguration;
|
|
236
|
+
buildSettings = {
|
|
237
|
+
HEADER_SEARCH_PATHS = (
|
|
238
|
+
"$(inherited)",
|
|
239
|
+
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
|
|
240
|
+
"$(SRCROOT)/../../../React/**",
|
|
241
|
+
"$(SRCROOT)/../../react-native/React/**",
|
|
242
|
+
);
|
|
243
|
+
LIBRARY_SEARCH_PATHS = "$(inherited)";
|
|
244
|
+
OTHER_LDFLAGS = (
|
|
245
|
+
"-framework",
|
|
246
|
+
Accelerate,
|
|
247
|
+
"-ObjC",
|
|
248
|
+
);
|
|
249
|
+
PRODUCT_NAME = RNWhisper;
|
|
250
|
+
SKIP_INSTALL = YES;
|
|
251
|
+
};
|
|
252
|
+
name = Release;
|
|
253
|
+
};
|
|
254
|
+
/* End XCBuildConfiguration section */
|
|
255
|
+
|
|
256
|
+
/* Begin XCConfigurationList section */
|
|
257
|
+
58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "RNWhisper" */ = {
|
|
258
|
+
isa = XCConfigurationList;
|
|
259
|
+
buildConfigurations = (
|
|
260
|
+
58B511ED1A9E6C8500147676 /* Debug */,
|
|
261
|
+
58B511EE1A9E6C8500147676 /* Release */,
|
|
262
|
+
);
|
|
263
|
+
defaultConfigurationIsVisible = 0;
|
|
264
|
+
defaultConfigurationName = Release;
|
|
265
|
+
};
|
|
266
|
+
58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "RNWhisper" */ = {
|
|
267
|
+
isa = XCConfigurationList;
|
|
268
|
+
buildConfigurations = (
|
|
269
|
+
58B511F01A9E6C8500147676 /* Debug */,
|
|
270
|
+
58B511F11A9E6C8500147676 /* Release */,
|
|
271
|
+
);
|
|
272
|
+
defaultConfigurationIsVisible = 0;
|
|
273
|
+
defaultConfigurationName = Release;
|
|
274
|
+
};
|
|
275
|
+
/* End XCConfigurationList section */
|
|
276
|
+
};
|
|
277
|
+
rootObject = 58B511D31A9E6C8500147676 /* Project object */;
|
|
278
|
+
}
|
|
Binary file
|
package/ios/RNWhisper.xcodeproj/xcuserdata/jhen.xcuserdatad/xcschemes/xcschememanagement.plist
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
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>SchemeUserState</key>
|
|
6
|
+
<dict>
|
|
7
|
+
<key>WhisperCpp.xcscheme_^#shared#^_</key>
|
|
8
|
+
<dict>
|
|
9
|
+
<key>orderHint</key>
|
|
10
|
+
<integer>0</integer>
|
|
11
|
+
</dict>
|
|
12
|
+
</dict>
|
|
13
|
+
</dict>
|
|
14
|
+
</plist>
|
package/jest/mock.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { NativeModules } from 'react-native'
|
|
2
|
+
|
|
3
|
+
if (!NativeModules.RNWhisper) {
|
|
4
|
+
NativeModules.RNWhisper = {
|
|
5
|
+
initContext: jest.fn(() => Promise.resolve(1)),
|
|
6
|
+
transcribe: jest.fn(() => Promise.resolve('TEST')),
|
|
7
|
+
releaseContext: jest.fn(() => Promise.resolve()),
|
|
8
|
+
releaseAllContexts: jest.fn(() => Promise.resolve()),
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
module.exports = jest.requireActual('whisper.rn')
|