whisper.rn 0.3.1 → 0.3.3
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/android/src/main/java/com/rnwhisper/WhisperContext.java +11 -4
- package/cpp/ggml.c +5349 -5349
- package/cpp/ggml.h +810 -810
- package/cpp/whisper.cpp +518 -518
- package/cpp/whisper.h +2 -2
- package/ios/RNWhisper.mm +3 -1
- package/ios/RNWhisperContext.h +2 -1
- package/ios/RNWhisperContext.mm +15 -11
- package/jest/mock.js +1 -0
- package/lib/commonjs/NativeRNWhisper.js.map +1 -1
- package/lib/commonjs/index.js +15 -6
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/NativeRNWhisper.js.map +1 -1
- package/lib/module/index.js +15 -6
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/NativeRNWhisper.d.ts +1 -0
- package/lib/typescript/NativeRNWhisper.d.ts.map +1 -1
- package/lib/typescript/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/NativeRNWhisper.ts +1 -0
- package/src/index.ts +15 -3
- package/whisper-rn.podspec +1 -1
|
@@ -71,7 +71,7 @@ public class WhisperContext {
|
|
|
71
71
|
bufferSize = AudioRecord.getMinBufferSize(SAMPLE_RATE, CHANNEL_CONFIG, AUDIO_FORMAT);
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
private void
|
|
74
|
+
private void rewind() {
|
|
75
75
|
shortBufferSlices = null;
|
|
76
76
|
sliceNSamples = null;
|
|
77
77
|
sliceIndex = 0;
|
|
@@ -97,7 +97,7 @@ public class WhisperContext {
|
|
|
97
97
|
return state;
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
|
|
100
|
+
rewind();
|
|
101
101
|
|
|
102
102
|
this.jobId = jobId;
|
|
103
103
|
|
|
@@ -269,7 +269,7 @@ public class WhisperContext {
|
|
|
269
269
|
fullTranscribeSamples(options, true);
|
|
270
270
|
} else if (isStopped) {
|
|
271
271
|
// No next, cleanup
|
|
272
|
-
|
|
272
|
+
rewind();
|
|
273
273
|
}
|
|
274
274
|
isTranscribing = false;
|
|
275
275
|
}
|
|
@@ -303,6 +303,11 @@ public class WhisperContext {
|
|
|
303
303
|
}
|
|
304
304
|
|
|
305
305
|
public WritableMap transcribeInputStream(int jobId, InputStream inputStream, ReadableMap options) throws IOException, Exception {
|
|
306
|
+
if (isCapturing || isTranscribing) {
|
|
307
|
+
throw new Exception("Context is already in capturing or transcribing");
|
|
308
|
+
}
|
|
309
|
+
rewind();
|
|
310
|
+
|
|
306
311
|
this.jobId = jobId;
|
|
307
312
|
isTranscribing = true;
|
|
308
313
|
float[] audioData = decodeWaveFile(inputStream);
|
|
@@ -312,7 +317,9 @@ public class WhisperContext {
|
|
|
312
317
|
if (code != 0) {
|
|
313
318
|
throw new Exception("Failed to transcribe the file. Code: " + code);
|
|
314
319
|
}
|
|
315
|
-
|
|
320
|
+
WritableMap result = getTextSegments();
|
|
321
|
+
result.putBoolean("isAborted", isStoppedByAction);
|
|
322
|
+
return result;
|
|
316
323
|
}
|
|
317
324
|
|
|
318
325
|
private int full(int jobId, ReadableMap options, float[] audioData, int audioDataLen) {
|