@gmessier/nitro-speech 0.4.0 → 0.4.2
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 +56 -16
- package/android/src/main/java/com/margelo/nitro/nitrospeech/recognizer/AutoStopper.kt +7 -7
- package/android/src/main/java/com/margelo/nitro/nitrospeech/recognizer/HybridRecognizer.kt +29 -14
- package/android/src/main/java/com/margelo/nitro/nitrospeech/recognizer/Logger.kt +16 -0
- package/android/src/main/java/com/margelo/nitro/nitrospeech/recognizer/RecognitionListenerSession.kt +11 -12
- package/ios/Audio/AudioLevelTracker.swift +16 -22
- package/ios/Engines/RecognizerEngine.swift +16 -13
- package/ios/HybridRecognizer.swift +8 -0
- package/ios/Shared/AutoStopper.swift +1 -1
- package/lib/Recognizer/RecognizerRef.d.ts +2 -0
- package/lib/Recognizer/RecognizerRef.js +5 -1
- package/lib/Recognizer/SpeechRecognizer.d.ts +2 -1
- package/lib/Recognizer/SpeechRecognizer.js +2 -1
- package/lib/Recognizer/methods.d.ts +5 -3
- package/lib/Recognizer/methods.js +8 -0
- package/lib/Recognizer/types.d.ts +3 -3
- package/lib/Recognizer/useRecognizer.js +10 -9
- package/lib/Recognizer/useRecognizerIsActive.d.ts +25 -0
- package/lib/Recognizer/useRecognizerIsActive.js +40 -0
- package/lib/Recognizer/useVoiceInputVolume.d.ts +1 -1
- package/lib/index.d.ts +7 -6
- package/lib/index.js +7 -6
- package/lib/specs/Recognizer.nitro.d.ts +26 -11
- package/nitrogen/generated/android/c++/JHybridRecognizerSpec.cpp +5 -0
- package/nitrogen/generated/android/c++/JHybridRecognizerSpec.hpp +1 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrospeech/HybridRecognizerSpec.kt +4 -0
- package/nitrogen/generated/ios/NitroSpeech-Swift-Cxx-Bridge.hpp +9 -0
- package/nitrogen/generated/ios/c++/HybridRecognizerSpecSwift.hpp +8 -0
- package/nitrogen/generated/ios/swift/HybridRecognizerSpec.swift +1 -0
- package/nitrogen/generated/ios/swift/HybridRecognizerSpec_cxx.swift +12 -0
- package/nitrogen/generated/shared/c++/HybridRecognizerSpec.cpp +1 -0
- package/nitrogen/generated/shared/c++/HybridRecognizerSpec.hpp +1 -0
- package/package.json +1 -1
- package/src/Recognizer/RecognizerRef.ts +6 -0
- package/src/Recognizer/SpeechRecognizer.ts +2 -1
- package/src/Recognizer/methods.ts +16 -3
- package/src/Recognizer/types.ts +7 -1
- package/src/Recognizer/useRecognizer.ts +11 -7
- package/src/Recognizer/useRecognizerIsActive.ts +49 -0
- package/src/Recognizer/useVoiceInputVolume.ts +1 -1
- package/src/index.ts +20 -6
- package/src/specs/Recognizer.nitro.ts +27 -11
package/src/index.ts
CHANGED
|
@@ -1,6 +1,20 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export
|
|
1
|
+
export { useRecognizer } from './Recognizer/useRecognizer'
|
|
2
|
+
export {
|
|
3
|
+
useVoiceInputVolume,
|
|
4
|
+
speechRecognizerVolumeChangeHandler,
|
|
5
|
+
} from './Recognizer/useVoiceInputVolume'
|
|
6
|
+
export {
|
|
7
|
+
useRecognizerIsActive,
|
|
8
|
+
speechRecognizerActiveStateHandler,
|
|
9
|
+
} from './Recognizer/useRecognizerIsActive'
|
|
10
|
+
export { SpeechRecognizer } from './Recognizer/SpeechRecognizer'
|
|
11
|
+
export { RecognizerRef } from './Recognizer/RecognizerRef'
|
|
12
|
+
export { NitroSpeech } from './NitroSpeech'
|
|
13
|
+
export {
|
|
14
|
+
type RecognizerSpec,
|
|
15
|
+
type SpeechRecognitionConfig,
|
|
16
|
+
type MutableSpeechRecognitionConfig,
|
|
17
|
+
type VolumeChangeEvent,
|
|
18
|
+
type RecognizerCallbacks,
|
|
19
|
+
type RecognizerMethods,
|
|
20
|
+
} from './Recognizer/types'
|
|
@@ -12,9 +12,24 @@ export interface Recognizer extends HybridObject<{
|
|
|
12
12
|
/**
|
|
13
13
|
* Prepare the speech recognition engine and the model for the given parameters.
|
|
14
14
|
*
|
|
15
|
-
*
|
|
15
|
+
* @notes
|
|
16
|
+
* - Not required, {@linkcode startListening} will prewarm automatically.
|
|
17
|
+
*
|
|
18
|
+
* - Omit the {@linkcode Promise} result if you want to run synchronously.
|
|
16
19
|
* {@linkcode startListening} will start and resolve it automatically.
|
|
17
|
-
*
|
|
20
|
+
*
|
|
21
|
+
* - Only `await` if run beforehand and you want to react to the success
|
|
22
|
+
*
|
|
23
|
+
* @worklet **Do not** use `await` on Worklet or UI runtimes. It will not work properly.
|
|
24
|
+
*
|
|
25
|
+
* You can run it synchronously:
|
|
26
|
+
* ```typescript
|
|
27
|
+
* scheduleOnRuntime(workletRuntime, () => {
|
|
28
|
+
* RecognizerRef.prewarm({
|
|
29
|
+
* // your config to prepare
|
|
30
|
+
* });
|
|
31
|
+
* });
|
|
32
|
+
* ```
|
|
18
33
|
*/
|
|
19
34
|
prewarm(defaultParams?: SpeechRecognitionConfig): Promise<void>
|
|
20
35
|
|
|
@@ -30,9 +45,9 @@ export interface Recognizer extends HybridObject<{
|
|
|
30
45
|
startListening(params?: SpeechRecognitionConfig): void
|
|
31
46
|
|
|
32
47
|
/**
|
|
33
|
-
* Stops the speech recognition.
|
|
48
|
+
* Stops the speech recognition. If not started, does nothing.
|
|
34
49
|
*
|
|
35
|
-
* Not a sync operation for
|
|
50
|
+
* Not a sync operation for Android, delay about 250ms to polish the result.
|
|
36
51
|
*
|
|
37
52
|
* Use {@linkcode onRecordingStopped} to handle the stop event.
|
|
38
53
|
*/
|
|
@@ -66,6 +81,11 @@ export interface Recognizer extends HybridObject<{
|
|
|
66
81
|
*/
|
|
67
82
|
getIsActive(): boolean
|
|
68
83
|
|
|
84
|
+
/**
|
|
85
|
+
* Returns the current voice input volume.
|
|
86
|
+
*/
|
|
87
|
+
getVoiceInputVolume(): VolumeChangeEvent
|
|
88
|
+
|
|
69
89
|
/**
|
|
70
90
|
* Returns a list of supported locales.
|
|
71
91
|
*
|
|
@@ -82,15 +102,13 @@ export interface Recognizer extends HybridObject<{
|
|
|
82
102
|
*/
|
|
83
103
|
onRecordingStopped?: () => void
|
|
84
104
|
/**
|
|
85
|
-
*
|
|
105
|
+
* Fires each time either a new batch has been added or the last batch has been updated.
|
|
86
106
|
*/
|
|
87
107
|
onResult?: (resultBatches: string[]) => void
|
|
88
108
|
/**
|
|
89
|
-
*
|
|
109
|
+
* Fires every {@linkcode SpeechRecognitionConfig.autoFinishProgressIntervalMs} or 1000ms
|
|
90
110
|
*
|
|
91
111
|
* Time left in milliseconds until the timer stops.
|
|
92
|
-
*
|
|
93
|
-
* @note not implemented for Android yet.
|
|
94
112
|
*/
|
|
95
113
|
onAutoFinishProgress?: (timeLeftMs: number) => void
|
|
96
114
|
/**
|
|
@@ -102,9 +120,7 @@ export interface Recognizer extends HybridObject<{
|
|
|
102
120
|
*/
|
|
103
121
|
onPermissionDenied?: () => void
|
|
104
122
|
/**
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
* @warning overriding it will disable the built-in `useVoiceInputVolume` hook.
|
|
123
|
+
* Fires with high and arbitrary frequency (many times per second) while audio recording is active.
|
|
108
124
|
*/
|
|
109
125
|
onVolumeChange?: (event: VolumeChangeEvent) => void
|
|
110
126
|
}
|