Skip to content

Commit

Permalink
feat: force min of vadMs to 2000
Browse files Browse the repository at this point in the history
  • Loading branch information
jhen0409 committed Oct 18, 2023
1 parent f3ce9a6 commit 8e5e582
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 45 deletions.
1 change: 1 addition & 0 deletions android/src/main/java/com/rnwhisper/WhisperContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ private boolean vad(ReadableMap options, short[] shortBuffer, int nSamples, int
boolean isSpeech = true;
if (!isTranscribing && options.hasKey("useVad") && options.getBoolean("useVad")) {
int vadSec = options.hasKey("vadMs") ? options.getInt("vadMs") / 1000 : 2;
if (vadSec < 2) vadSec = 2;
int sampleSize = vadSec * SAMPLE_RATE;
if (nSamples + n > sampleSize) {
int start = nSamples + n - sampleSize;
Expand Down
36 changes: 18 additions & 18 deletions docs/API/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ whisper.rn

#### Defined in

[index.ts:76](https://github.com/mybigday/whisper.rn/blob/66e9a0c/src/index.ts#L76)
[index.ts:76](https://github.com/mybigday/whisper.rn/blob/f3ce9a6/src/index.ts#L76)

___

Expand All @@ -79,7 +79,7 @@ ___

#### Defined in

[index.ts:428](https://github.com/mybigday/whisper.rn/blob/66e9a0c/src/index.ts#L428)
[index.ts:428](https://github.com/mybigday/whisper.rn/blob/f3ce9a6/src/index.ts#L428)

___

Expand All @@ -89,7 +89,7 @@ ___

#### Defined in

[index.ts:59](https://github.com/mybigday/whisper.rn/blob/66e9a0c/src/index.ts#L59)
[index.ts:59](https://github.com/mybigday/whisper.rn/blob/f3ce9a6/src/index.ts#L59)

___

Expand All @@ -107,7 +107,7 @@ ___

#### Defined in

[index.ts:52](https://github.com/mybigday/whisper.rn/blob/66e9a0c/src/index.ts#L52)
[index.ts:52](https://github.com/mybigday/whisper.rn/blob/f3ce9a6/src/index.ts#L52)

___

Expand All @@ -126,7 +126,7 @@ ___

#### Defined in

[index.ts:45](https://github.com/mybigday/whisper.rn/blob/66e9a0c/src/index.ts#L45)
[index.ts:45](https://github.com/mybigday/whisper.rn/blob/f3ce9a6/src/index.ts#L45)

___

Expand Down Expand Up @@ -156,7 +156,7 @@ ___

#### Defined in

[NativeRNWhisper.ts:5](https://github.com/mybigday/whisper.rn/blob/66e9a0c/src/NativeRNWhisper.ts#L5)
[NativeRNWhisper.ts:5](https://github.com/mybigday/whisper.rn/blob/f3ce9a6/src/NativeRNWhisper.ts#L5)

___

Expand All @@ -174,7 +174,7 @@ ___

#### Defined in

[index.ts:70](https://github.com/mybigday/whisper.rn/blob/66e9a0c/src/index.ts#L70)
[index.ts:70](https://github.com/mybigday/whisper.rn/blob/f3ce9a6/src/index.ts#L70)

___

Expand All @@ -199,7 +199,7 @@ ___

#### Defined in

[index.ts:133](https://github.com/mybigday/whisper.rn/blob/66e9a0c/src/index.ts#L133)
[index.ts:133](https://github.com/mybigday/whisper.rn/blob/f3ce9a6/src/index.ts#L133)

___

Expand All @@ -217,7 +217,7 @@ ___

#### Defined in

[index.ts:166](https://github.com/mybigday/whisper.rn/blob/66e9a0c/src/index.ts#L166)
[index.ts:166](https://github.com/mybigday/whisper.rn/blob/f3ce9a6/src/index.ts#L166)

___

Expand All @@ -241,7 +241,7 @@ ___

#### Defined in

[index.ts:153](https://github.com/mybigday/whisper.rn/blob/66e9a0c/src/index.ts#L153)
[index.ts:153](https://github.com/mybigday/whisper.rn/blob/f3ce9a6/src/index.ts#L153)

___

Expand All @@ -251,7 +251,7 @@ ___

#### Defined in

[index.ts:84](https://github.com/mybigday/whisper.rn/blob/66e9a0c/src/index.ts#L84)
[index.ts:84](https://github.com/mybigday/whisper.rn/blob/f3ce9a6/src/index.ts#L84)

___

Expand All @@ -269,7 +269,7 @@ ___

#### Defined in

[NativeRNWhisper.ts:37](https://github.com/mybigday/whisper.rn/blob/66e9a0c/src/NativeRNWhisper.ts#L37)
[NativeRNWhisper.ts:37](https://github.com/mybigday/whisper.rn/blob/f3ce9a6/src/NativeRNWhisper.ts#L37)

## Variables

Expand All @@ -294,7 +294,7 @@ AudioSession Utility, iOS only.

#### Defined in

[AudioSessionIos.ts:50](https://github.com/mybigday/whisper.rn/blob/66e9a0c/src/AudioSessionIos.ts#L50)
[AudioSessionIos.ts:50](https://github.com/mybigday/whisper.rn/blob/f3ce9a6/src/AudioSessionIos.ts#L50)

___

Expand All @@ -306,7 +306,7 @@ Is allow fallback to CPU if load CoreML model failed

#### Defined in

[index.ts:526](https://github.com/mybigday/whisper.rn/blob/66e9a0c/src/index.ts#L526)
[index.ts:526](https://github.com/mybigday/whisper.rn/blob/f3ce9a6/src/index.ts#L526)

___

Expand All @@ -318,7 +318,7 @@ Is use CoreML models on iOS

#### Defined in

[index.ts:523](https://github.com/mybigday/whisper.rn/blob/66e9a0c/src/index.ts#L523)
[index.ts:523](https://github.com/mybigday/whisper.rn/blob/f3ce9a6/src/index.ts#L523)

___

Expand All @@ -330,7 +330,7 @@ Current version of whisper.cpp

#### Defined in

[index.ts:518](https://github.com/mybigday/whisper.rn/blob/66e9a0c/src/index.ts#L518)
[index.ts:518](https://github.com/mybigday/whisper.rn/blob/f3ce9a6/src/index.ts#L518)

## Functions

Expand All @@ -350,7 +350,7 @@ Current version of whisper.cpp

#### Defined in

[index.ts:452](https://github.com/mybigday/whisper.rn/blob/66e9a0c/src/index.ts#L452)
[index.ts:452](https://github.com/mybigday/whisper.rn/blob/f3ce9a6/src/index.ts#L452)

___

Expand All @@ -364,4 +364,4 @@ ___

#### Defined in

[index.ts:513](https://github.com/mybigday/whisper.rn/blob/66e9a0c/src/index.ts#L513)
[index.ts:513](https://github.com/mybigday/whisper.rn/blob/f3ce9a6/src/index.ts#L513)
10 changes: 5 additions & 5 deletions docs/API/classes/WhisperContext.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

#### Defined in

[index.ts:186](https://github.com/mybigday/whisper.rn/blob/66e9a0c/src/index.ts#L186)
[index.ts:186](https://github.com/mybigday/whisper.rn/blob/f3ce9a6/src/index.ts#L186)

## Properties

Expand All @@ -42,7 +42,7 @@

#### Defined in

[index.ts:184](https://github.com/mybigday/whisper.rn/blob/66e9a0c/src/index.ts#L184)
[index.ts:184](https://github.com/mybigday/whisper.rn/blob/f3ce9a6/src/index.ts#L184)

## Methods

Expand All @@ -56,7 +56,7 @@

#### Defined in

[index.ts:423](https://github.com/mybigday/whisper.rn/blob/66e9a0c/src/index.ts#L423)
[index.ts:423](https://github.com/mybigday/whisper.rn/blob/f3ce9a6/src/index.ts#L423)

___

Expand Down Expand Up @@ -84,7 +84,7 @@ Transcribe audio file

#### Defined in

[index.ts:191](https://github.com/mybigday/whisper.rn/blob/66e9a0c/src/index.ts#L191)
[index.ts:191](https://github.com/mybigday/whisper.rn/blob/f3ce9a6/src/index.ts#L191)

___

Expand All @@ -106,4 +106,4 @@ Transcribe the microphone audio stream, the microphone user permission is requir

#### Defined in

[index.ts:287](https://github.com/mybigday/whisper.rn/blob/66e9a0c/src/index.ts#L287)
[index.ts:287](https://github.com/mybigday/whisper.rn/blob/f3ce9a6/src/index.ts#L287)
12 changes: 6 additions & 6 deletions docs/API/enums/AudioSessionCategoryIos.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ https://developer.apple.com/documentation/avfaudio/avaudiosessioncategory?langua

#### Defined in

[AudioSessionIos.ts:8](https://github.com/mybigday/whisper.rn/blob/66e9a0c/src/AudioSessionIos.ts#L8)
[AudioSessionIos.ts:8](https://github.com/mybigday/whisper.rn/blob/f3ce9a6/src/AudioSessionIos.ts#L8)

___

Expand All @@ -35,7 +35,7 @@ ___

#### Defined in

[AudioSessionIos.ts:13](https://github.com/mybigday/whisper.rn/blob/66e9a0c/src/AudioSessionIos.ts#L13)
[AudioSessionIos.ts:13](https://github.com/mybigday/whisper.rn/blob/f3ce9a6/src/AudioSessionIos.ts#L13)

___

Expand All @@ -45,7 +45,7 @@ ___

#### Defined in

[AudioSessionIos.ts:12](https://github.com/mybigday/whisper.rn/blob/66e9a0c/src/AudioSessionIos.ts#L12)
[AudioSessionIos.ts:12](https://github.com/mybigday/whisper.rn/blob/f3ce9a6/src/AudioSessionIos.ts#L12)

___

Expand All @@ -55,7 +55,7 @@ ___

#### Defined in

[AudioSessionIos.ts:10](https://github.com/mybigday/whisper.rn/blob/66e9a0c/src/AudioSessionIos.ts#L10)
[AudioSessionIos.ts:10](https://github.com/mybigday/whisper.rn/blob/f3ce9a6/src/AudioSessionIos.ts#L10)

___

Expand All @@ -65,7 +65,7 @@ ___

#### Defined in

[AudioSessionIos.ts:11](https://github.com/mybigday/whisper.rn/blob/66e9a0c/src/AudioSessionIos.ts#L11)
[AudioSessionIos.ts:11](https://github.com/mybigday/whisper.rn/blob/f3ce9a6/src/AudioSessionIos.ts#L11)

___

Expand All @@ -75,4 +75,4 @@ ___

#### Defined in

[AudioSessionIos.ts:9](https://github.com/mybigday/whisper.rn/blob/66e9a0c/src/AudioSessionIos.ts#L9)
[AudioSessionIos.ts:9](https://github.com/mybigday/whisper.rn/blob/f3ce9a6/src/AudioSessionIos.ts#L9)
14 changes: 7 additions & 7 deletions docs/API/enums/AudioSessionCategoryOptionIos.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ https://developer.apple.com/documentation/avfaudio/avaudiosessioncategoryoptions

#### Defined in

[AudioSessionIos.ts:25](https://github.com/mybigday/whisper.rn/blob/66e9a0c/src/AudioSessionIos.ts#L25)
[AudioSessionIos.ts:25](https://github.com/mybigday/whisper.rn/blob/f3ce9a6/src/AudioSessionIos.ts#L25)

___

Expand All @@ -36,7 +36,7 @@ ___

#### Defined in

[AudioSessionIos.ts:23](https://github.com/mybigday/whisper.rn/blob/66e9a0c/src/AudioSessionIos.ts#L23)
[AudioSessionIos.ts:23](https://github.com/mybigday/whisper.rn/blob/f3ce9a6/src/AudioSessionIos.ts#L23)

___

Expand All @@ -46,7 +46,7 @@ ___

#### Defined in

[AudioSessionIos.ts:24](https://github.com/mybigday/whisper.rn/blob/66e9a0c/src/AudioSessionIos.ts#L24)
[AudioSessionIos.ts:24](https://github.com/mybigday/whisper.rn/blob/f3ce9a6/src/AudioSessionIos.ts#L24)

___

Expand All @@ -56,7 +56,7 @@ ___

#### Defined in

[AudioSessionIos.ts:26](https://github.com/mybigday/whisper.rn/blob/66e9a0c/src/AudioSessionIos.ts#L26)
[AudioSessionIos.ts:26](https://github.com/mybigday/whisper.rn/blob/f3ce9a6/src/AudioSessionIos.ts#L26)

___

Expand All @@ -66,7 +66,7 @@ ___

#### Defined in

[AudioSessionIos.ts:21](https://github.com/mybigday/whisper.rn/blob/66e9a0c/src/AudioSessionIos.ts#L21)
[AudioSessionIos.ts:21](https://github.com/mybigday/whisper.rn/blob/f3ce9a6/src/AudioSessionIos.ts#L21)

___

Expand All @@ -76,7 +76,7 @@ ___

#### Defined in

[AudioSessionIos.ts:22](https://github.com/mybigday/whisper.rn/blob/66e9a0c/src/AudioSessionIos.ts#L22)
[AudioSessionIos.ts:22](https://github.com/mybigday/whisper.rn/blob/f3ce9a6/src/AudioSessionIos.ts#L22)

___

Expand All @@ -86,4 +86,4 @@ ___

#### Defined in

[AudioSessionIos.ts:20](https://github.com/mybigday/whisper.rn/blob/66e9a0c/src/AudioSessionIos.ts#L20)
[AudioSessionIos.ts:20](https://github.com/mybigday/whisper.rn/blob/f3ce9a6/src/AudioSessionIos.ts#L20)
16 changes: 8 additions & 8 deletions docs/API/enums/AudioSessionModeIos.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ https://developer.apple.com/documentation/avfaudio/avaudiosessionmode?language=o

#### Defined in

[AudioSessionIos.ts:33](https://github.com/mybigday/whisper.rn/blob/66e9a0c/src/AudioSessionIos.ts#L33)
[AudioSessionIos.ts:33](https://github.com/mybigday/whisper.rn/blob/f3ce9a6/src/AudioSessionIos.ts#L33)

___

Expand All @@ -37,7 +37,7 @@ ___

#### Defined in

[AudioSessionIos.ts:36](https://github.com/mybigday/whisper.rn/blob/66e9a0c/src/AudioSessionIos.ts#L36)
[AudioSessionIos.ts:36](https://github.com/mybigday/whisper.rn/blob/f3ce9a6/src/AudioSessionIos.ts#L36)

___

Expand All @@ -47,7 +47,7 @@ ___

#### Defined in

[AudioSessionIos.ts:38](https://github.com/mybigday/whisper.rn/blob/66e9a0c/src/AudioSessionIos.ts#L38)
[AudioSessionIos.ts:38](https://github.com/mybigday/whisper.rn/blob/f3ce9a6/src/AudioSessionIos.ts#L38)

___

Expand All @@ -57,7 +57,7 @@ ___

#### Defined in

[AudioSessionIos.ts:39](https://github.com/mybigday/whisper.rn/blob/66e9a0c/src/AudioSessionIos.ts#L39)
[AudioSessionIos.ts:39](https://github.com/mybigday/whisper.rn/blob/f3ce9a6/src/AudioSessionIos.ts#L39)

___

Expand All @@ -67,7 +67,7 @@ ___

#### Defined in

[AudioSessionIos.ts:40](https://github.com/mybigday/whisper.rn/blob/66e9a0c/src/AudioSessionIos.ts#L40)
[AudioSessionIos.ts:40](https://github.com/mybigday/whisper.rn/blob/f3ce9a6/src/AudioSessionIos.ts#L40)

___

Expand All @@ -77,7 +77,7 @@ ___

#### Defined in

[AudioSessionIos.ts:35](https://github.com/mybigday/whisper.rn/blob/66e9a0c/src/AudioSessionIos.ts#L35)
[AudioSessionIos.ts:35](https://github.com/mybigday/whisper.rn/blob/f3ce9a6/src/AudioSessionIos.ts#L35)

___

Expand All @@ -87,7 +87,7 @@ ___

#### Defined in

[AudioSessionIos.ts:37](https://github.com/mybigday/whisper.rn/blob/66e9a0c/src/AudioSessionIos.ts#L37)
[AudioSessionIos.ts:37](https://github.com/mybigday/whisper.rn/blob/f3ce9a6/src/AudioSessionIos.ts#L37)

___

Expand All @@ -97,4 +97,4 @@ ___

#### Defined in

[AudioSessionIos.ts:34](https://github.com/mybigday/whisper.rn/blob/66e9a0c/src/AudioSessionIos.ts#L34)
[AudioSessionIos.ts:34](https://github.com/mybigday/whisper.rn/blob/f3ce9a6/src/AudioSessionIos.ts#L34)
2 changes: 2 additions & 0 deletions ios/RNWhisperContext.mm
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ - (void)prepareRealtime:(NSDictionary *)options {

self->recordState.useVad = options[@"useVad"] != nil ? [options[@"useVad"] boolValue] : false;
self->recordState.vadSec = options[@"vadMs"] != nil ? [options[@"vadMs"] intValue] / 1000 : 2;
if (self->recordState.vadSec < 2) self->recordState.vadSec = 2;

self->recordState.vadThold = options[@"vadThold"] != nil ? [options[@"vadThold"] floatValue] : 0.6f;
self->recordState.vadFreqThold = options[@"vadFreqThold"] != nil ? [options[@"vadFreqThold"] floatValue] : 100.0f;

Expand Down
Loading

0 comments on commit 8e5e582

Please sign in to comment.