@dreamtree-org/twreact-ui 1.1.30 → 1.1.31
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/dist/components/core/SpeechToText.d.ts.map +1 -1
- package/dist/index.esm.js +11 -3
- package/dist/index.js +11 -3
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SpeechToText.d.ts","sourceRoot":"","sources":["../../../src/components/core/SpeechToText.jsx"],"names":[],"mappings":";AAcA,
|
|
1
|
+
{"version":3,"file":"SpeechToText.d.ts","sourceRoot":"","sources":["../../../src/components/core/SpeechToText.jsx"],"names":[],"mappings":";AAcA,sFAoPE;kBA3PK,OAAO"}
|
package/dist/index.esm.js
CHANGED
|
@@ -16188,7 +16188,7 @@ var SpeechToText = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
16188
16188
|
_ref$resetOnStart = _ref.resetOnStart,
|
|
16189
16189
|
resetOnStart = _ref$resetOnStart === void 0 ? false : _ref$resetOnStart;
|
|
16190
16190
|
var recognitionRef = useRef(null);
|
|
16191
|
-
var isMountedRef = useRef(
|
|
16191
|
+
var isMountedRef = useRef(false);
|
|
16192
16192
|
var finalTranscriptRef = useRef("");
|
|
16193
16193
|
var lastEmittedFinalRef = useRef("");
|
|
16194
16194
|
var _useState = useState(false),
|
|
@@ -16205,7 +16205,7 @@ var SpeechToText = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
16205
16205
|
setError = _useState6[1];
|
|
16206
16206
|
useEffect(function () {
|
|
16207
16207
|
return function () {
|
|
16208
|
-
isMountedRef.current =
|
|
16208
|
+
isMountedRef.current = true;
|
|
16209
16209
|
if (recognitionRef.current) {
|
|
16210
16210
|
try {
|
|
16211
16211
|
recognitionRef.current.stop();
|
|
@@ -16214,7 +16214,9 @@ var SpeechToText = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
16214
16214
|
};
|
|
16215
16215
|
}, []);
|
|
16216
16216
|
useEffect(function () {
|
|
16217
|
-
var
|
|
16217
|
+
var isNotSupported = typeof window === "undefined";
|
|
16218
|
+
var hasSpeechRecognition = "SpeechRecognition" in window || "webkitSpeechRecognition" in window;
|
|
16219
|
+
var supported = !isNotSupported && hasSpeechRecognition;
|
|
16218
16220
|
setIsSupported(supported);
|
|
16219
16221
|
}, []);
|
|
16220
16222
|
useEffect(function () {
|
|
@@ -16239,13 +16241,19 @@ var SpeechToText = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
16239
16241
|
recognition.interimResults = interimResults;
|
|
16240
16242
|
recognition.lang = lang;
|
|
16241
16243
|
recognition.onstart = function () {
|
|
16244
|
+
console.log("recognition.onstart");
|
|
16242
16245
|
if (!isMountedRef.current) return;
|
|
16243
16246
|
setIsListening(true);
|
|
16244
16247
|
setError(null);
|
|
16245
16248
|
onStart();
|
|
16246
16249
|
};
|
|
16247
16250
|
recognition.onresult = function (event) {
|
|
16251
|
+
console.log("event", {
|
|
16252
|
+
event: event,
|
|
16253
|
+
isMountedRef: isMountedRef
|
|
16254
|
+
});
|
|
16248
16255
|
if (!isMountedRef.current) return;
|
|
16256
|
+
console.log("recognition.onresult");
|
|
16249
16257
|
var interim = "";
|
|
16250
16258
|
for (var i = event.resultIndex; i < event.results.length; i++) {
|
|
16251
16259
|
var _res$;
|
package/dist/index.js
CHANGED
|
@@ -16208,7 +16208,7 @@ var SpeechToText = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
16208
16208
|
_ref$resetOnStart = _ref.resetOnStart,
|
|
16209
16209
|
resetOnStart = _ref$resetOnStart === void 0 ? false : _ref$resetOnStart;
|
|
16210
16210
|
var recognitionRef = React.useRef(null);
|
|
16211
|
-
var isMountedRef = React.useRef(
|
|
16211
|
+
var isMountedRef = React.useRef(false);
|
|
16212
16212
|
var finalTranscriptRef = React.useRef("");
|
|
16213
16213
|
var lastEmittedFinalRef = React.useRef("");
|
|
16214
16214
|
var _useState = React.useState(false),
|
|
@@ -16225,7 +16225,7 @@ var SpeechToText = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
16225
16225
|
setError = _useState6[1];
|
|
16226
16226
|
React.useEffect(function () {
|
|
16227
16227
|
return function () {
|
|
16228
|
-
isMountedRef.current =
|
|
16228
|
+
isMountedRef.current = true;
|
|
16229
16229
|
if (recognitionRef.current) {
|
|
16230
16230
|
try {
|
|
16231
16231
|
recognitionRef.current.stop();
|
|
@@ -16234,7 +16234,9 @@ var SpeechToText = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
16234
16234
|
};
|
|
16235
16235
|
}, []);
|
|
16236
16236
|
React.useEffect(function () {
|
|
16237
|
-
var
|
|
16237
|
+
var isNotSupported = typeof window === "undefined";
|
|
16238
|
+
var hasSpeechRecognition = "SpeechRecognition" in window || "webkitSpeechRecognition" in window;
|
|
16239
|
+
var supported = !isNotSupported && hasSpeechRecognition;
|
|
16238
16240
|
setIsSupported(supported);
|
|
16239
16241
|
}, []);
|
|
16240
16242
|
React.useEffect(function () {
|
|
@@ -16259,13 +16261,19 @@ var SpeechToText = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
16259
16261
|
recognition.interimResults = interimResults;
|
|
16260
16262
|
recognition.lang = lang;
|
|
16261
16263
|
recognition.onstart = function () {
|
|
16264
|
+
console.log("recognition.onstart");
|
|
16262
16265
|
if (!isMountedRef.current) return;
|
|
16263
16266
|
setIsListening(true);
|
|
16264
16267
|
setError(null);
|
|
16265
16268
|
onStart();
|
|
16266
16269
|
};
|
|
16267
16270
|
recognition.onresult = function (event) {
|
|
16271
|
+
console.log("event", {
|
|
16272
|
+
event: event,
|
|
16273
|
+
isMountedRef: isMountedRef
|
|
16274
|
+
});
|
|
16268
16275
|
if (!isMountedRef.current) return;
|
|
16276
|
+
console.log("recognition.onresult");
|
|
16269
16277
|
var interim = "";
|
|
16270
16278
|
for (var i = event.resultIndex; i < event.results.length; i++) {
|
|
16271
16279
|
var _res$;
|