apps-sdk 2.0.5 → 2.0.6
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/package.json +1 -1
- package/src/libraries/Voice.js +22 -1
- package/types/index.d.ts +3 -1
package/package.json
CHANGED
package/src/libraries/Voice.js
CHANGED
|
@@ -10,10 +10,11 @@ class VoiceService {
|
|
|
10
10
|
constructor() {
|
|
11
11
|
this.inactivityTimeout = null;
|
|
12
12
|
this.resultListener = null;
|
|
13
|
+
this.volumeListener = null;
|
|
13
14
|
this.isRecognizing = false;
|
|
14
15
|
}
|
|
15
16
|
|
|
16
|
-
async startRecognizing(onSpeechStart, onSpeechRecognized, onSpeechResults, onInactivityTimeout, inactivitySeconds = 3) {
|
|
17
|
+
async startRecognizing(onSpeechStart, onSpeechRecognized, onSpeechResults, onInactivityTimeout, inactivitySeconds = 3, onVolumeChange = null, onNoSpeech = null) {
|
|
17
18
|
try {
|
|
18
19
|
const { status } = await ExpoSpeechRecognitionModule.requestPermissionsAsync();
|
|
19
20
|
if (status !== 'granted') {
|
|
@@ -36,6 +37,12 @@ class VoiceService {
|
|
|
36
37
|
this.resultListener.remove();
|
|
37
38
|
}
|
|
38
39
|
|
|
40
|
+
this.volumeListener = ExpoSpeechRecognitionModule.addListener("volumechange" , ({value}) => {
|
|
41
|
+
if (onVolumeChange) {
|
|
42
|
+
onVolumeChange(value);
|
|
43
|
+
}
|
|
44
|
+
})
|
|
45
|
+
|
|
39
46
|
ExpoSpeechRecognitionModule.addListener('start', () => {
|
|
40
47
|
onSpeechStart();
|
|
41
48
|
this.resetInactivityTimeout(inactivitySeconds, onInactivityTimeout);
|
|
@@ -51,6 +58,12 @@ class VoiceService {
|
|
|
51
58
|
|
|
52
59
|
ExpoSpeechRecognitionModule.addListener('error', (event) => {
|
|
53
60
|
console.error('Speech recognition error:', event.error, event.message);
|
|
61
|
+
|
|
62
|
+
// Handle "no-speech" error specifically
|
|
63
|
+
if (event.error === 'no-speech' && onNoSpeech) {
|
|
64
|
+
onNoSpeech();
|
|
65
|
+
// Don't stop recognition, just notify user
|
|
66
|
+
}
|
|
54
67
|
});
|
|
55
68
|
|
|
56
69
|
await ExpoSpeechRecognitionModule.start({
|
|
@@ -58,6 +71,10 @@ class VoiceService {
|
|
|
58
71
|
interimResults: true,
|
|
59
72
|
maxAlternatives: 1,
|
|
60
73
|
continuous: true,
|
|
74
|
+
volumeChangeEventOptions : {
|
|
75
|
+
enabled : true,
|
|
76
|
+
intervalMillis:150
|
|
77
|
+
}
|
|
61
78
|
});
|
|
62
79
|
|
|
63
80
|
this.isRecognizing = true;
|
|
@@ -89,6 +106,10 @@ class VoiceService {
|
|
|
89
106
|
this.resultListener.remove();
|
|
90
107
|
this.resultListener = null;
|
|
91
108
|
}
|
|
109
|
+
if (this.volumeListener) {
|
|
110
|
+
this.volumeListener.remove();
|
|
111
|
+
this.volumeListener = null;
|
|
112
|
+
}
|
|
92
113
|
if (this.isRecognizing) {
|
|
93
114
|
await ExpoSpeechRecognitionModule.stop();
|
|
94
115
|
this.isRecognizing = false;
|
package/types/index.d.ts
CHANGED
|
@@ -106,7 +106,7 @@ declare module 'apps-sdk' {
|
|
|
106
106
|
handleRequestGalleryPermission(): Promise<string>;
|
|
107
107
|
setTrackingPermissionGranted(value: boolean): Promise<void>;
|
|
108
108
|
setTrackingPermissionFromStorage(): Promise<void>;
|
|
109
|
-
selectImageFromGallery(galleryNotGrantedTitle: string, galleryNotGrantedMessage: string, cancelText:string, openSettingsText:string): Promise<string>;
|
|
109
|
+
selectImageFromGallery(galleryNotGrantedTitle: string, galleryNotGrantedMessage: string, cancelText:string, openSettingsText:string, maxPerPick?: number): Promise<string>;
|
|
110
110
|
removeAllKeys(): Promise<void>;
|
|
111
111
|
deleteTempFiles(): Promise<void>;
|
|
112
112
|
compressImage(imageURI: string, maxSizeMB: number): Promise<string>;
|
|
@@ -135,6 +135,8 @@ declare module 'apps-sdk' {
|
|
|
135
135
|
onSpeechResults: (results: string[]) => void,
|
|
136
136
|
onInactivityTimeout: () => void,
|
|
137
137
|
inactivitySeconds?: number,
|
|
138
|
+
onVolumeChange?: ((volumeValue: number) => void) | null,
|
|
139
|
+
onNoSpeech?: (() => void) | null
|
|
138
140
|
): Promise<void>;
|
|
139
141
|
|
|
140
142
|
stopRecognizing(): Promise<void>;
|