whisper.rn 0.3.0-rc.3 → 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.
|
@@ -239,7 +239,19 @@ public class WhisperContext {
|
|
|
239
239
|
!isCapturing &&
|
|
240
240
|
nSamplesTranscribing == nSamplesOfIndex &&
|
|
241
241
|
sliceIndex == transcribeSliceIndex;
|
|
242
|
-
|
|
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
|
|
package/ios/RNWhisperContext.mm
CHANGED
|
@@ -180,14 +180,26 @@ void AudioInputCallback(void * inUserData,
|
|
|
180
180
|
}
|
|
181
181
|
|
|
182
182
|
nSamplesOfIndex = [[state->sliceNSamples objectAtIndex:state->transcribeSliceIndex] intValue];
|
|
183
|
+
|
|
184
|
+
bool isStopped = state->isStoppedByAction || (
|
|
185
|
+
!state->isCapturing &&
|
|
186
|
+
state->nSamplesTranscribing == nSamplesOfIndex &&
|
|
187
|
+
state->sliceIndex == state->transcribeSliceIndex
|
|
188
|
+
);
|
|
189
|
+
|
|
183
190
|
if (
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
state->nSamplesTranscribing == nSamplesOfIndex &&
|
|
188
|
-
state->sliceIndex == state->transcribeSliceIndex
|
|
189
|
-
)
|
|
191
|
+
// If no more samples on current slice, move to next slice
|
|
192
|
+
state->nSamplesTranscribing == nSamplesOfIndex &&
|
|
193
|
+
state->transcribeSliceIndex != state->sliceIndex
|
|
190
194
|
) {
|
|
195
|
+
state->transcribeSliceIndex++;
|
|
196
|
+
state->nSamplesTranscribing = 0;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
bool continueNeeded = !state->isCapturing &&
|
|
200
|
+
state->nSamplesTranscribing != nSamplesOfIndex;
|
|
201
|
+
|
|
202
|
+
if (isStopped && !continueNeeded) {
|
|
191
203
|
NSLog(@"[RNWhisper] Transcribe end");
|
|
192
204
|
result[@"isStoppedByAction"] = @(state->isStoppedByAction);
|
|
193
205
|
result[@"isCapturing"] = @(false);
|
|
@@ -200,19 +212,7 @@ void AudioInputCallback(void * inUserData,
|
|
|
200
212
|
state->transcribeHandler(state->jobId, @"transcribe", result);
|
|
201
213
|
}
|
|
202
214
|
|
|
203
|
-
if (
|
|
204
|
-
// If no more samples on current slice, move to next slice
|
|
205
|
-
state->nSamplesTranscribing == nSamplesOfIndex &&
|
|
206
|
-
state->transcribeSliceIndex != state->sliceIndex
|
|
207
|
-
) {
|
|
208
|
-
state->transcribeSliceIndex++;
|
|
209
|
-
state->nSamplesTranscribing = 0;
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
if (
|
|
213
|
-
!state->isCapturing &&
|
|
214
|
-
state->nSamplesTranscribing != nSamplesOfIndex
|
|
215
|
-
) {
|
|
215
|
+
if (continueNeeded) {
|
|
216
216
|
state->isTranscribing = true;
|
|
217
217
|
// Finish transcribing the rest of the samples
|
|
218
218
|
[self fullTranscribeSamples:state];
|
|
@@ -285,7 +285,6 @@ void AudioInputCallback(void * inUserData,
|
|
|
285
285
|
if (!self->recordState.isRealtime || !self->recordState.isCapturing) {
|
|
286
286
|
return;
|
|
287
287
|
}
|
|
288
|
-
self->recordState.isTranscribing = false;
|
|
289
288
|
self->recordState.isCapturing = false;
|
|
290
289
|
self->recordState.isStoppedByAction = true;
|
|
291
290
|
[self stopAudio];
|