whisper.rn 0.3.0-rc.2 → 0.3.0-rc.4

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/README.md CHANGED
@@ -79,7 +79,7 @@ subscribe(evt => {
79
79
 
80
80
  In Android, you may need to request the microphone permission by [`PermissionAndroid`](https://reactnative.dev/docs/permissionsandroid).
81
81
 
82
- The documentation is not ready yet, please see the comments of [index](./src/index.ts) file for more details at the moment.
82
+ Please visit the [Documentation](docs/) for more details.
83
83
 
84
84
  ## Core ML support
85
85
 
@@ -239,7 +239,19 @@ public class WhisperContext {
239
239
  !isCapturing &&
240
240
  nSamplesTranscribing == nSamplesOfIndex &&
241
241
  sliceIndex == transcribeSliceIndex;
242
- if (isStopped) {
242
+
243
+ if (
244
+ // If no more samples on current slice, move to next slice
245
+ nSamplesTranscribing == sliceNSamples.get(transcribeSliceIndex) &&
246
+ transcribeSliceIndex != sliceIndex
247
+ ) {
248
+ transcribeSliceIndex++;
249
+ nSamplesTranscribing = 0;
250
+ }
251
+
252
+ boolean continueNeeded = !isCapturing && nSamplesTranscribing != nSamplesOfIndex;
253
+
254
+ if (isStopped && !continueNeeded) {
243
255
  payload.putBoolean("isCapturing", false);
244
256
  payload.putBoolean("isStoppedByAction", isStoppedByAction);
245
257
  emitTranscribeEvent("@RNWhisper_onRealtimeTranscribeEnd", payload);
@@ -251,16 +263,7 @@ public class WhisperContext {
251
263
  emitTranscribeEvent("@RNWhisper_onRealtimeTranscribe", payload);
252
264
  }
253
265
 
254
- if (
255
- // If no more samples on current slice, move to next slice
256
- nSamplesTranscribing == sliceNSamples.get(transcribeSliceIndex) &&
257
- transcribeSliceIndex != sliceIndex
258
- ) {
259
- transcribeSliceIndex++;
260
- nSamplesTranscribing = 0;
261
- }
262
-
263
- if (!isCapturing && nSamplesTranscribing != nSamplesOfIndex) {
266
+ if (continueNeeded) {
264
267
  // If no more capturing, continue transcribing until all slices are transcribed
265
268
  fullTranscribeSamples(options, true);
266
269
  } else if (isStopped) {
@@ -368,7 +371,6 @@ public class WhisperContext {
368
371
  public void stopTranscribe(int jobId) {
369
372
  abortTranscribe(jobId);
370
373
  isCapturing = false;
371
- isTranscribing = false;
372
374
  isStoppedByAction = true;
373
375
  }
374
376