@nualang/nualang-ui-components 0.1.1420 → 0.1.1422
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 +31 -0
- package/dist/Chat/BottomBar/BottomBar.js +23 -10
- package/dist/Chat/Chat.js +2 -0
- package/dist/Exercises/Bot/Bot.js +6 -1
- package/dist/Exercises/ListenAndSpeak/ListenAndSpeak.js +18 -8
- package/dist/Exercises/Pronouncer/Pronouncer.js +18 -8
- package/dist/Exercises/Roleplay/Games/ActItOutGameListeningAndSpeaking/ActItOutGame.js +18 -8
- package/dist/Exercises/Roleplay/Games/ActItOutGameSpeaking/ActItOutGame.js +18 -9
- package/dist/Lists/CourseOutline/CourseOutline.js +232 -23
- package/dist/Lists/CourseOutline/CourseOutline.test.js +74 -8
- package/dist/hooks/useRecognition.js +208 -37
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -35,6 +35,37 @@ If webapp is caching previous versions (Add a character to the end of the .tgz,
|
|
|
35
35
|
pnpm add ../ui-components/nualang-ui-components-0.1.XXXa.tgz
|
|
36
36
|
```
|
|
37
37
|
|
|
38
|
+
## Local Development with `npm link`
|
|
39
|
+
Links this repo directly into `app`, so changes here show up instantly with no
|
|
40
|
+
repacking or reinstalling. Requires both repos cloned as sibling folders
|
|
41
|
+
(`ui-components` and `app` side by side, same parent directory).
|
|
42
|
+
|
|
43
|
+
1. **Here in `ui-components`**, start the watcher (it cleans `dist/` before its first
|
|
44
|
+
compile, so it's always safe to run - no separate build step needed):
|
|
45
|
+
```bash
|
|
46
|
+
pnpm run watch # leave this running
|
|
47
|
+
```
|
|
48
|
+
2. **In `app`**, link it in and start the dev server:
|
|
49
|
+
```bash
|
|
50
|
+
npm run link:ui-components
|
|
51
|
+
npm start
|
|
52
|
+
```
|
|
53
|
+
3. Edit a component here under `src/` and save - it recompiles automatically, `app`'s
|
|
54
|
+
dev server rebuilds, and a browser reload shows your change.
|
|
55
|
+
4. **In `app`** when you're done, switch back to the published version:
|
|
56
|
+
```bash
|
|
57
|
+
npm run unlink:ui-components
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
**If you delete or rename a file while the watcher is already running**, restart
|
|
61
|
+
`pnpm run watch`. Babel's `--watch` mode only ever adds/updates compiled output - it
|
|
62
|
+
never removes a stale file from `dist/` for a source file that's gone, which can leave
|
|
63
|
+
`app` resolving a module that no longer exists in `src/`. Restarting re-runs the clean
|
|
64
|
+
step and fixes it.
|
|
65
|
+
|
|
66
|
+
Heads up: an `npm install` in `app` will quietly replace the link with the published
|
|
67
|
+
version - just re-run `npm run link:ui-components` to relink.
|
|
68
|
+
|
|
38
69
|
## Publish to npm
|
|
39
70
|
Normall, you should just update the version number in package.json and commit
|
|
40
71
|
your updates. When you updated are merged to main, gitlab CI/CD will add a
|
|
@@ -9,6 +9,7 @@ import Tooltip from "@mui/material/Tooltip";
|
|
|
9
9
|
import Divider from "@mui/material/Divider";
|
|
10
10
|
import Paper from "@mui/material/Paper";
|
|
11
11
|
import Typography from "@mui/material/Typography";
|
|
12
|
+
import CircularProgress from "@mui/material/CircularProgress";
|
|
12
13
|
import MicIcon from "@mui/icons-material/Mic";
|
|
13
14
|
import MicOffIcon from "@mui/icons-material/MicOff";
|
|
14
15
|
import SendIcon from "@mui/icons-material/Send";
|
|
@@ -81,6 +82,7 @@ export default function BottomBar({
|
|
|
81
82
|
handleKeyPress,
|
|
82
83
|
handleUpdate,
|
|
83
84
|
isListening,
|
|
85
|
+
isMicBusy = false,
|
|
84
86
|
handleAttachFile,
|
|
85
87
|
handleRecord,
|
|
86
88
|
handleAdd,
|
|
@@ -131,6 +133,11 @@ export default function BottomBar({
|
|
|
131
133
|
const textInput = useRef(null);
|
|
132
134
|
const activeRef = inputRef ? inputRef : textInput;
|
|
133
135
|
const isSmallScreen = useMediaQuery(theme.breakpoints.down("md"));
|
|
136
|
+
|
|
137
|
+
// isMicBusy spans the async mic start/stop window (permission prompt,
|
|
138
|
+
// audio worklet setup, socket teardown) - without this the button just
|
|
139
|
+
// goes inert with no explanation.
|
|
140
|
+
const micButtonLabel = isMicBusy ? t("loading") : isListening ? t("click_to_stop") : t("click_to_speak");
|
|
134
141
|
const TextInput = /*#__PURE__*/_jsx("div", {
|
|
135
142
|
className: classes.input,
|
|
136
143
|
id: "keyboardInput",
|
|
@@ -236,7 +243,6 @@ export default function BottomBar({
|
|
|
236
243
|
children: isSmallScreen ? /*#__PURE__*/_jsx(_Fragment, {
|
|
237
244
|
children: /*#__PURE__*/_jsx(IconButton, {
|
|
238
245
|
sx: {
|
|
239
|
-
color: isListening ? "red" : "inherit",
|
|
240
246
|
animation: showMicReminder ? "reminder 1.6s ease-in-out infinite" : "none",
|
|
241
247
|
"@keyframes reminder": {
|
|
242
248
|
"0%": {
|
|
@@ -253,24 +259,27 @@ export default function BottomBar({
|
|
|
253
259
|
onClick: onClickRecord,
|
|
254
260
|
edge: "start",
|
|
255
261
|
id: "voiceInput",
|
|
262
|
+
color: isListening ? "error" : "inherit",
|
|
256
263
|
disabled: disableInput,
|
|
264
|
+
"aria-busy": isMicBusy,
|
|
265
|
+
"aria-label": micButtonLabel,
|
|
257
266
|
size: "large",
|
|
258
267
|
ref: buttonRef,
|
|
259
|
-
children:
|
|
268
|
+
children: isMicBusy ? /*#__PURE__*/_jsx(CircularProgress, {
|
|
269
|
+
size: 20,
|
|
270
|
+
color: "inherit"
|
|
271
|
+
}) : isListening ? /*#__PURE__*/_jsx(MicOffIcon, {}) : /*#__PURE__*/_jsx(MicIcon, {})
|
|
260
272
|
})
|
|
261
273
|
}) : /*#__PURE__*/_jsx(_Fragment, {
|
|
262
274
|
children: /*#__PURE__*/_jsx(Button, {
|
|
263
275
|
sx: {
|
|
264
|
-
color: "white",
|
|
265
|
-
backgroundColor: isListening ? "#d32f2f" : "#2d7b30",
|
|
266
276
|
padding: 1,
|
|
267
277
|
paddingLeft: 2,
|
|
268
278
|
paddingRight: 2,
|
|
269
279
|
borderRadius: 3,
|
|
270
|
-
border: "1.5px solid
|
|
280
|
+
border: "1.5px solid transparent",
|
|
271
281
|
"&:hover": {
|
|
272
|
-
|
|
273
|
-
border: "1.5px solid white"
|
|
282
|
+
border: "1.5px solid black"
|
|
274
283
|
},
|
|
275
284
|
animation: showMicReminder ? "reminder 1.6s ease-in-out infinite" : "none",
|
|
276
285
|
"@keyframes reminder": {
|
|
@@ -286,18 +295,22 @@ export default function BottomBar({
|
|
|
286
295
|
}
|
|
287
296
|
},
|
|
288
297
|
onClick: onClickRecord,
|
|
289
|
-
startIcon:
|
|
298
|
+
startIcon: isMicBusy ? /*#__PURE__*/_jsx(CircularProgress, {
|
|
299
|
+
size: 20,
|
|
300
|
+
color: "inherit"
|
|
301
|
+
}) : isListening ? /*#__PURE__*/_jsx(MicOffIcon, {}) : /*#__PURE__*/_jsx(MicIcon, {}),
|
|
290
302
|
color: isListening ? "error" : "success",
|
|
291
303
|
disabled: disableInput,
|
|
304
|
+
"aria-busy": isMicBusy,
|
|
292
305
|
variant: "contained",
|
|
293
306
|
id: "voiceInput",
|
|
294
307
|
ref: buttonRef,
|
|
295
|
-
children:
|
|
308
|
+
children: micButtonLabel
|
|
296
309
|
})
|
|
297
310
|
})
|
|
298
311
|
}), /*#__PURE__*/_jsx(Typography, {
|
|
299
312
|
sx: {
|
|
300
|
-
marginLeft: 1.5,
|
|
313
|
+
marginLeft: isSmallScreen ? 0.75 : 1.5,
|
|
301
314
|
marginRight: 1,
|
|
302
315
|
my: "auto",
|
|
303
316
|
fontWeight: "bold"
|
package/dist/Chat/Chat.js
CHANGED
|
@@ -23,6 +23,7 @@ function Chat({
|
|
|
23
23
|
handleBack,
|
|
24
24
|
handleClose,
|
|
25
25
|
handleRecord,
|
|
26
|
+
isMicBusy = false,
|
|
26
27
|
handleAdd,
|
|
27
28
|
handleSend,
|
|
28
29
|
handleUpdate,
|
|
@@ -178,6 +179,7 @@ function Chat({
|
|
|
178
179
|
focusInput: focusInput,
|
|
179
180
|
handleInputChange: handleInputChange,
|
|
180
181
|
isListening: isListening,
|
|
182
|
+
isMicBusy: isMicBusy,
|
|
181
183
|
handleRecord: handleRecord,
|
|
182
184
|
handleSend: handleSend,
|
|
183
185
|
handleAdd: handleAdd,
|
|
@@ -101,7 +101,8 @@ function Bot({
|
|
|
101
101
|
aiChatbotConversationHistory,
|
|
102
102
|
isUserInternal,
|
|
103
103
|
handleStudentMisuse,
|
|
104
|
-
username
|
|
104
|
+
username,
|
|
105
|
+
trackRecommendedEvent
|
|
105
106
|
}) {
|
|
106
107
|
const theme = useTheme();
|
|
107
108
|
const {
|
|
@@ -121,6 +122,9 @@ function Bot({
|
|
|
121
122
|
browserSupportsSpeechRecognition,
|
|
122
123
|
clearAttemptAudio
|
|
123
124
|
} = useRecognition({
|
|
125
|
+
trackRecommendedEvent,
|
|
126
|
+
exerciseName,
|
|
127
|
+
learnLang,
|
|
124
128
|
openSnackbar
|
|
125
129
|
});
|
|
126
130
|
const {
|
|
@@ -606,6 +610,7 @@ function Bot({
|
|
|
606
610
|
t: t,
|
|
607
611
|
authenticated: authenticated,
|
|
608
612
|
disableInput: !authenticated || isSpeaking || isRecognizingDisabled ? true : false,
|
|
613
|
+
isMicBusy: isRecognizingDisabled,
|
|
609
614
|
messages: botMessages,
|
|
610
615
|
placeholder: !recognizing ? placeholder : "",
|
|
611
616
|
translationEnabled: isTranslationEnabled,
|
|
@@ -2,7 +2,7 @@ import { useState, useEffect, useRef } from "react";
|
|
|
2
2
|
import { Joyride, STATUS } from "react-joyride";
|
|
3
3
|
import { makeStyles } from "tss-react/mui";
|
|
4
4
|
import { useTheme } from "@mui/material/styles";
|
|
5
|
-
import { Grid, Slide, IconButton, Button, Toolbar, AppBar, Dialog, Typography, Box, Tooltip } from "@mui/material";
|
|
5
|
+
import { Grid, Slide, IconButton, Button, Toolbar, AppBar, Dialog, Typography, Box, Tooltip, CircularProgress } from "@mui/material";
|
|
6
6
|
import { styled } from "@mui/system";
|
|
7
7
|
import LightbulbIcon from "@mui/icons-material/Lightbulb";
|
|
8
8
|
import Replay from "@mui/icons-material/Replay";
|
|
@@ -227,9 +227,12 @@ function ListenAndSpeak({
|
|
|
227
227
|
});
|
|
228
228
|
}
|
|
229
229
|
if (recognizing && interimTranscript === "" && finalTranscript === "") {
|
|
230
|
-
// Set a timer to stop listening if no audio is detected after 10 seconds
|
|
230
|
+
// Set a timer to stop listening if no audio is detected after 10 seconds.
|
|
231
|
+
// Without the snackbar here the mic just switches off with no
|
|
232
|
+
// explanation, indistinguishable from the student stopping it themselves.
|
|
231
233
|
timer = setTimeout(() => {
|
|
232
234
|
stopListening();
|
|
235
|
+
openSnackbar?.("We didn't hear anything, please try again.", "warning");
|
|
233
236
|
}, 10000);
|
|
234
237
|
}
|
|
235
238
|
return () => clearTimeout(timer);
|
|
@@ -455,6 +458,12 @@ function ListenAndSpeak({
|
|
|
455
458
|
}
|
|
456
459
|
};
|
|
457
460
|
const isListeningIndicatorTextVisible = recognizing && interimTranscript === "" && finalTranscript === "" ? true : false;
|
|
461
|
+
|
|
462
|
+
// isRecognizingDisabled spans the async mic start/stop window (permission
|
|
463
|
+
// prompt, audio worklet setup, socket teardown) - without a distinct label
|
|
464
|
+
// and icon here the button just goes inert with no explanation.
|
|
465
|
+
const isMicBusy = isRecognizingDisabled;
|
|
466
|
+
const micButtonLabel = isMicBusy ? t("loading") : recognizing ? t("click_to_stop") : t("click_to_speak");
|
|
458
467
|
const navigate = useNavigate();
|
|
459
468
|
const goBackToAssignment = () => {
|
|
460
469
|
navigate(`/classrooms/${classroomId}#Assignments`);
|
|
@@ -696,32 +705,33 @@ function ListenAndSpeak({
|
|
|
696
705
|
[theme.breakpoints.down("md")]: {
|
|
697
706
|
height: "50px",
|
|
698
707
|
width: "200px",
|
|
699
|
-
color: "white",
|
|
700
708
|
padding: 2,
|
|
701
709
|
fontSize: "16px",
|
|
702
710
|
borderRadius: 3
|
|
703
711
|
},
|
|
704
712
|
height: "70px",
|
|
705
713
|
width: "250px",
|
|
706
|
-
color: "white",
|
|
707
|
-
backgroundColor: recognizing ? "#d32f2f" : "#2d7b30",
|
|
708
714
|
padding: 1,
|
|
709
715
|
fontSize: "20px",
|
|
710
716
|
borderRadius: 5,
|
|
711
717
|
border: "1.5px solid transparent",
|
|
712
718
|
"&:hover": {
|
|
713
|
-
backgroundColor: recognizing ? "#d32f2f" : "#2d7b30",
|
|
714
719
|
border: "1.5px solid black"
|
|
715
720
|
}
|
|
716
721
|
}),
|
|
717
722
|
onClick: () => handleMic(currentPhrase ? currentPhrase.phrase : ""),
|
|
718
|
-
startIcon:
|
|
723
|
+
startIcon: isMicBusy ? /*#__PURE__*/_jsx(CircularProgress, {
|
|
724
|
+
size: 20,
|
|
725
|
+
color: "inherit"
|
|
726
|
+
}) : recognizing ? /*#__PURE__*/_jsx(MicOffIcon, {}) : /*#__PURE__*/_jsx(Mic, {}),
|
|
719
727
|
color: recognizing ? "error" : "success",
|
|
720
728
|
disabled: isSpeaking || !isSocketConnected || isRecognizingDisabled,
|
|
729
|
+
"aria-busy": isMicBusy,
|
|
730
|
+
"aria-label": micButtonLabel,
|
|
721
731
|
id: "voiceInput",
|
|
722
732
|
variant: "contained",
|
|
723
733
|
ref: btnRef,
|
|
724
|
-
children:
|
|
734
|
+
children: micButtonLabel
|
|
725
735
|
})
|
|
726
736
|
}), /*#__PURE__*/_jsx(Grid, {
|
|
727
737
|
children: /*#__PURE__*/_jsx(Typography, {
|
|
@@ -2,7 +2,7 @@ import { useState, useEffect, useRef } from "react";
|
|
|
2
2
|
import { Joyride, STATUS } from "react-joyride";
|
|
3
3
|
import { makeStyles } from "tss-react/mui";
|
|
4
4
|
import { useTheme } from "@mui/material/styles";
|
|
5
|
-
import { Grid, Slide, IconButton, Button, Toolbar, AppBar, Dialog, Typography, Box, Tooltip } from "@mui/material";
|
|
5
|
+
import { Grid, Slide, IconButton, Button, Toolbar, AppBar, Dialog, Typography, Box, Tooltip, CircularProgress } from "@mui/material";
|
|
6
6
|
import { styled } from "@mui/system";
|
|
7
7
|
import LightbulbIcon from "@mui/icons-material/Lightbulb";
|
|
8
8
|
import Replay from "@mui/icons-material/Replay";
|
|
@@ -228,9 +228,12 @@ function Pronouncer({
|
|
|
228
228
|
});
|
|
229
229
|
}
|
|
230
230
|
if (recognizing && interimTranscript === "" && finalTranscript === "") {
|
|
231
|
-
// Set a timer to stop listening if no audio is detected after 10 seconds
|
|
231
|
+
// Set a timer to stop listening if no audio is detected after 10 seconds.
|
|
232
|
+
// Without the snackbar here the mic just switches off with no
|
|
233
|
+
// explanation, indistinguishable from the student stopping it themselves.
|
|
232
234
|
timer = setTimeout(() => {
|
|
233
235
|
stopListening();
|
|
236
|
+
openSnackbar?.("We didn't hear anything, please try again.", "warning");
|
|
234
237
|
}, 10000);
|
|
235
238
|
}
|
|
236
239
|
return () => clearTimeout(timer);
|
|
@@ -467,6 +470,12 @@ function Pronouncer({
|
|
|
467
470
|
}
|
|
468
471
|
};
|
|
469
472
|
const isListeningIndicatorTextVisible = recognizing && interimTranscript === "" && finalTranscript === "" ? true : false;
|
|
473
|
+
|
|
474
|
+
// isRecognizingDisabled spans the async mic start/stop window (permission
|
|
475
|
+
// prompt, audio worklet setup, socket teardown) - without a distinct label
|
|
476
|
+
// and icon here the button just goes inert with no explanation.
|
|
477
|
+
const isMicBusy = isRecognizingDisabled;
|
|
478
|
+
const micButtonLabel = isMicBusy ? t("loading") : recognizing ? t("click_to_stop") : t("click_to_speak");
|
|
470
479
|
const navigate = useNavigate();
|
|
471
480
|
const goBackToAssignment = () => {
|
|
472
481
|
navigate(`/classrooms/${classroomId}#Assignments`);
|
|
@@ -751,32 +760,33 @@ function Pronouncer({
|
|
|
751
760
|
[theme.breakpoints.down("md")]: {
|
|
752
761
|
height: "50px",
|
|
753
762
|
width: "200px",
|
|
754
|
-
color: "white",
|
|
755
763
|
padding: 2,
|
|
756
764
|
fontSize: "16px",
|
|
757
765
|
borderRadius: 3
|
|
758
766
|
},
|
|
759
767
|
height: "70px",
|
|
760
768
|
width: "250px",
|
|
761
|
-
color: "white",
|
|
762
|
-
backgroundColor: recognizing ? "#d32f2f" : "#2d7b30",
|
|
763
769
|
padding: 1,
|
|
764
770
|
fontSize: "20px",
|
|
765
771
|
borderRadius: 5,
|
|
766
772
|
border: "1.5px solid transparent",
|
|
767
773
|
"&:hover": {
|
|
768
|
-
backgroundColor: recognizing ? "#d32f2f" : "#2d7b30",
|
|
769
774
|
border: "1.5px solid black"
|
|
770
775
|
}
|
|
771
776
|
}),
|
|
772
777
|
onClick: () => handleMic(currentPhrase ? currentPhrase.phrase : ""),
|
|
773
|
-
startIcon:
|
|
778
|
+
startIcon: isMicBusy ? /*#__PURE__*/_jsx(CircularProgress, {
|
|
779
|
+
size: 20,
|
|
780
|
+
color: "inherit"
|
|
781
|
+
}) : recognizing ? /*#__PURE__*/_jsx(MicOffIcon, {}) : /*#__PURE__*/_jsx(Mic, {}),
|
|
774
782
|
color: recognizing ? "error" : "success",
|
|
775
783
|
disabled: isSpeaking || !isSocketConnected || isRecognizingDisabled,
|
|
784
|
+
"aria-busy": isMicBusy,
|
|
785
|
+
"aria-label": micButtonLabel,
|
|
776
786
|
id: "voiceInput",
|
|
777
787
|
variant: "contained",
|
|
778
788
|
ref: btnRef,
|
|
779
|
-
children:
|
|
789
|
+
children: micButtonLabel
|
|
780
790
|
})
|
|
781
791
|
}), /*#__PURE__*/_jsx(Grid, {
|
|
782
792
|
children: /*#__PURE__*/_jsx(Typography, {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useState, useEffect, useRef } from "react";
|
|
2
|
-
import { Box, Button, Typography, Grid, Avatar, Dialog } from "@mui/material";
|
|
2
|
+
import { Box, Button, Typography, Grid, Avatar, Dialog, CircularProgress } from "@mui/material";
|
|
3
3
|
import { makeStyles } from "tss-react/mui";
|
|
4
4
|
import Person from "@mui/icons-material/Person";
|
|
5
5
|
import Mic from "@mui/icons-material/Mic";
|
|
@@ -101,6 +101,12 @@ function AnswerOptions({
|
|
|
101
101
|
buttonRef.current.focus();
|
|
102
102
|
}
|
|
103
103
|
}, [isSpeaking, isSocketConnected]);
|
|
104
|
+
|
|
105
|
+
// isRecognizingDisabled spans the async mic start/stop window (permission
|
|
106
|
+
// prompt, audio worklet setup, socket teardown) - without a distinct label
|
|
107
|
+
// and icon here the button just goes inert with no explanation.
|
|
108
|
+
const isMicBusy = isRecognizingDisabled;
|
|
109
|
+
const micButtonLabel = isMicBusy ? t("loading") : recognizing ? t("click_to_stop") : t("click_to_speak");
|
|
104
110
|
return /*#__PURE__*/_jsxs(Box, {
|
|
105
111
|
sx: theme => ({
|
|
106
112
|
display: "flex",
|
|
@@ -176,27 +182,28 @@ function AnswerOptions({
|
|
|
176
182
|
children: [/*#__PURE__*/_jsx(Button, {
|
|
177
183
|
sx: theme => ({
|
|
178
184
|
[theme.breakpoints.down("md")]: {
|
|
179
|
-
color: "white",
|
|
180
185
|
borderRadius: 3
|
|
181
186
|
},
|
|
182
|
-
color: "white",
|
|
183
|
-
backgroundColor: recognizing ? "#d32f2f" : "#2d7b30",
|
|
184
187
|
mb: theme.spacing(2),
|
|
185
188
|
border: "1.5px solid transparent",
|
|
186
189
|
"&:hover": {
|
|
187
|
-
backgroundColor: recognizing ? "#d32f2f" : "#2d7b30",
|
|
188
190
|
border: "1.5px solid black"
|
|
189
191
|
}
|
|
190
192
|
}),
|
|
191
193
|
onClick: () => handleMic(text),
|
|
192
|
-
startIcon:
|
|
194
|
+
startIcon: isMicBusy ? /*#__PURE__*/_jsx(CircularProgress, {
|
|
195
|
+
size: 20,
|
|
196
|
+
color: "inherit"
|
|
197
|
+
}) : recognizing ? /*#__PURE__*/_jsx(MicOffIcon, {}) : /*#__PURE__*/_jsx(Mic, {}),
|
|
193
198
|
color: recognizing ? "error" : "success",
|
|
194
199
|
disabled: isSpeaking || !isSocketConnected || isRecognizingDisabled,
|
|
195
200
|
id: "voiceInput",
|
|
196
201
|
variant: "contained",
|
|
197
202
|
size: "large",
|
|
198
203
|
ref: buttonRef,
|
|
199
|
-
|
|
204
|
+
"aria-busy": isMicBusy,
|
|
205
|
+
"aria-label": micButtonLabel,
|
|
206
|
+
children: micButtonLabel
|
|
200
207
|
}), /*#__PURE__*/_jsx(Typography, {
|
|
201
208
|
role: "status",
|
|
202
209
|
variant: "h6",
|
|
@@ -434,9 +441,12 @@ function RoleplayGame({
|
|
|
434
441
|
useEffect(() => {
|
|
435
442
|
let timer;
|
|
436
443
|
if (recognizing && interimTranscript === "" && finalTranscript === "") {
|
|
437
|
-
// Set a timer to stop listening if no audio is detected after 10 seconds
|
|
444
|
+
// Set a timer to stop listening if no audio is detected after 10 seconds.
|
|
445
|
+
// Without the snackbar here the mic just switches off with no
|
|
446
|
+
// explanation, indistinguishable from the student stopping it themselves.
|
|
438
447
|
timer = setTimeout(() => {
|
|
439
448
|
stopListening();
|
|
449
|
+
openSnackbar?.("We didn't hear anything, please try again.", "warning");
|
|
440
450
|
}, 10000);
|
|
441
451
|
}
|
|
442
452
|
return () => clearTimeout(timer);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useState, useEffect, useRef } from "react";
|
|
2
|
-
import { Box, Button, Typography, Grid, Avatar, Dialog } from "@mui/material";
|
|
2
|
+
import { Box, Button, Typography, Grid, Avatar, Dialog, CircularProgress } from "@mui/material";
|
|
3
3
|
import { makeStyles } from "tss-react/mui";
|
|
4
4
|
import Person from "@mui/icons-material/Person";
|
|
5
5
|
import RecordVoiceOverIcon from "@mui/icons-material/RecordVoiceOver";
|
|
@@ -92,6 +92,12 @@ function AnswerOptions({
|
|
|
92
92
|
buttonRef.current.focus();
|
|
93
93
|
}
|
|
94
94
|
}, [isSpeaking, isSocketConnected]);
|
|
95
|
+
|
|
96
|
+
// isRecognizingDisabled spans the async mic start/stop window (permission
|
|
97
|
+
// prompt, audio worklet setup, socket teardown) - without a distinct label
|
|
98
|
+
// and icon here the button just goes inert with no explanation.
|
|
99
|
+
const isMicBusy = isRecognizingDisabled;
|
|
100
|
+
const micButtonLabel = isMicBusy ? t("loading") : recognizing ? t("click_to_stop") : t("click_to_speak");
|
|
95
101
|
return /*#__PURE__*/_jsxs(Box, {
|
|
96
102
|
sx: theme => ({
|
|
97
103
|
display: "flex",
|
|
@@ -167,28 +173,28 @@ function AnswerOptions({
|
|
|
167
173
|
children: [/*#__PURE__*/_jsx(Button, {
|
|
168
174
|
sx: theme => ({
|
|
169
175
|
[theme.breakpoints.down("md")]: {
|
|
170
|
-
color: "white",
|
|
171
176
|
borderRadius: 3
|
|
172
177
|
},
|
|
173
|
-
color: "white",
|
|
174
|
-
backgroundColor: recognizing ? "#d32f2f" : "#2d7b30",
|
|
175
178
|
mb: theme.spacing(2),
|
|
176
179
|
border: "1.5px solid transparent",
|
|
177
180
|
"&:hover": {
|
|
178
|
-
backgroundColor: recognizing ? "#d32f2f" : "#2d7b30",
|
|
179
181
|
border: "1.5px solid black"
|
|
180
182
|
}
|
|
181
183
|
}),
|
|
182
184
|
onClick: () => handleMic(text),
|
|
183
|
-
startIcon:
|
|
185
|
+
startIcon: isMicBusy ? /*#__PURE__*/_jsx(CircularProgress, {
|
|
186
|
+
size: 20,
|
|
187
|
+
color: "inherit"
|
|
188
|
+
}) : recognizing ? /*#__PURE__*/_jsx(MicOffIcon, {}) : /*#__PURE__*/_jsx(Mic, {}),
|
|
184
189
|
color: recognizing ? "error" : "success",
|
|
185
190
|
disabled: isSpeaking || !isSocketConnected || isRecognizingDisabled,
|
|
186
191
|
id: "voiceInput",
|
|
187
192
|
variant: "contained",
|
|
188
193
|
size: "large",
|
|
189
194
|
ref: buttonRef,
|
|
190
|
-
"aria-
|
|
191
|
-
|
|
195
|
+
"aria-busy": isMicBusy,
|
|
196
|
+
"aria-label": ariaLiveText || micButtonLabel,
|
|
197
|
+
children: micButtonLabel
|
|
192
198
|
}), /*#__PURE__*/_jsx(Typography, {
|
|
193
199
|
role: "status",
|
|
194
200
|
variant: "h6",
|
|
@@ -427,9 +433,12 @@ function RoleplayGame({
|
|
|
427
433
|
useEffect(() => {
|
|
428
434
|
let timer;
|
|
429
435
|
if (recognizing && interimTranscript === "" && finalTranscript === "") {
|
|
430
|
-
// Set a timer to stop listening if no audio is detected after 10 seconds
|
|
436
|
+
// Set a timer to stop listening if no audio is detected after 10 seconds.
|
|
437
|
+
// Without the snackbar here the mic just switches off with no
|
|
438
|
+
// explanation, indistinguishable from the student stopping it themselves.
|
|
431
439
|
timer = setTimeout(() => {
|
|
432
440
|
stopListening();
|
|
441
|
+
openSnackbar?.("We didn't hear anything, please try again.", "warning");
|
|
433
442
|
}, 10000);
|
|
434
443
|
}
|
|
435
444
|
return () => clearTimeout(timer);
|