dmed-voice-assistant 1.2.6 → 1.2.7

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.js CHANGED
@@ -24,7 +24,9 @@ const VoiceAssistant = _ref => {
24
24
  onRecordDataChange,
25
25
  onNewRecognitionEvent,
26
26
  onRecognitionDataChange,
27
- onCloseRecognition
27
+ onCloseRecognition,
28
+ onRecognitionStopEvent,
29
+ onRealTimeRecognitionCommandEvent
28
30
  } = _ref;
29
31
  const [mode, setMode] = (0, _react.useState)(!isOnlyRecognitionMode ? "recorder" : "recognition");
30
32
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
@@ -41,10 +43,12 @@ const VoiceAssistant = _ref => {
41
43
  mode: mode,
42
44
  setMode: setMode,
43
45
  recognitionHistoryList: recognitionListValue,
46
+ onRealTimeRecognitionCommandEvent: onRealTimeRecognitionCommandEvent,
44
47
  onNewRecognitionEvent: onNewRecognitionEvent,
45
48
  onRecognitionDataChange: onRecognitionDataChange,
46
49
  isOnlyRecognitionMode: isOnlyRecognitionMode,
47
- onCloseRecognition: onCloseRecognition
50
+ onCloseRecognition: onCloseRecognition,
51
+ onRecognitionStopEvent: onRecognitionStopEvent
48
52
  })]
49
53
  })
50
54
  });
@@ -75,7 +75,9 @@ const Recognition = _ref4 => {
75
75
  setMode,
76
76
  onNewRecognitionEvent,
77
77
  onRecognitionDataChange,
78
- onCloseRecognition
78
+ onCloseRecognition,
79
+ onRealTimeRecognitionCommandEvent,
80
+ onRecognitionStopEvent
79
81
  } = _ref4;
80
82
  const [open, setOpen] = (0, _react.useState)(false);
81
83
  const [anchorEl, setAnchorEl] = (0, _react.useState)(null);
@@ -168,6 +170,9 @@ const Recognition = _ref4 => {
168
170
  const stopRecording = () => {
169
171
  if (recognitionRef.current && mediaRecorderRef.current) {
170
172
  recognitionRef.current.stop();
173
+ if (onRecognitionStopEvent) {
174
+ onRecognitionStopEvent();
175
+ }
171
176
  clearInterval(intervalId);
172
177
  mediaRecorderRef.current.stop().then(async _ref5 => {
173
178
  let {
@@ -226,6 +231,14 @@ const Recognition = _ref4 => {
226
231
  }
227
232
  return updatedTranscript;
228
233
  });
234
+ for (let i = event.resultIndex; i < event.results.length; i++) {
235
+ if (event.results[i].isFinal) {
236
+ const resultArr = event.results[i][0].transcript.split(' ').filter(word => word.trim() !== '');
237
+ if (onRealTimeRecognitionCommandEvent) {
238
+ onRealTimeRecognitionCommandEvent(resultArr);
239
+ }
240
+ }
241
+ }
229
242
  };
230
243
  recognition.onerror = event => {
231
244
  console.error('Speech recognition error:', event.error);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dmed-voice-assistant",
3
- "version": "1.2.6",
3
+ "version": "1.2.7",
4
4
  "main": "dist/index.js",
5
5
  "files": [
6
6
  "dist"