@memori.ai/memori-react 7.19.1 → 7.21.0
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/CHANGELOG.md +57 -0
- package/dist/components/Avatar/Avatar.js +3 -3
- package/dist/components/Avatar/Avatar.js.map +1 -1
- package/dist/components/Avatar/AvatarView/AvatarComponent/Shadow/DynamicShadow.d.ts +3 -2
- package/dist/components/Avatar/AvatarView/AvatarComponent/Shadow/DynamicShadow.js +13 -6
- package/dist/components/Avatar/AvatarView/AvatarComponent/Shadow/DynamicShadow.js.map +1 -1
- package/dist/components/Avatar/AvatarView/AvatarComponent/avatarComponent.d.ts +14 -18
- package/dist/components/Avatar/AvatarView/AvatarComponent/avatarComponent.js +19 -77
- package/dist/components/Avatar/AvatarView/AvatarComponent/avatarComponent.js.map +1 -1
- package/dist/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/fullbodyAvatar.d.ts +17 -2
- package/dist/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/fullbodyAvatar.js +95 -70
- package/dist/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/fullbodyAvatar.js.map +1 -1
- package/dist/components/Avatar/AvatarView/AvatarComponent/components/controllers/AvatarAnimator.d.ts +65 -0
- package/dist/components/Avatar/AvatarView/AvatarComponent/components/controllers/AvatarAnimator.js +747 -0
- package/dist/components/Avatar/AvatarView/AvatarComponent/components/controllers/AvatarAnimator.js.map +1 -0
- package/dist/components/Avatar/AvatarView/AvatarComponent/components/controllers/MorphTargetController.d.ts +9 -2
- package/dist/components/Avatar/AvatarView/AvatarComponent/components/controllers/MorphTargetController.js +60 -2
- package/dist/components/Avatar/AvatarView/AvatarComponent/components/controllers/MorphTargetController.js.map +1 -1
- package/dist/components/Avatar/AvatarView/AvatarComponent/components/halfbodyAvatar.d.ts +3 -4
- package/dist/components/Avatar/AvatarView/AvatarComponent/components/halfbodyAvatar.js +5 -11
- package/dist/components/Avatar/AvatarView/AvatarComponent/components/halfbodyAvatar.js.map +1 -1
- package/dist/components/Avatar/AvatarView/AvatarComponent/constants.d.ts +13 -52
- package/dist/components/Avatar/AvatarView/AvatarComponent/constants.js +68 -70
- package/dist/components/Avatar/AvatarView/AvatarComponent/constants.js.map +1 -1
- package/dist/components/Avatar/AvatarView/index.d.ts +1 -1
- package/dist/components/Avatar/AvatarView/index.js +2 -2
- package/dist/components/Avatar/AvatarView/index.js.map +1 -1
- package/dist/components/Chat/Chat.js +2 -2
- package/dist/components/Chat/Chat.js.map +1 -1
- package/dist/components/ChatBubble/ChatBubble.js +12 -9
- package/dist/components/ChatBubble/ChatBubble.js.map +1 -1
- package/dist/components/ExpertsDrawer/ExpertsDrawer.js +1 -1
- package/dist/components/ExpertsDrawer/ExpertsDrawer.js.map +1 -1
- package/dist/components/LoginDrawer/LoginDrawer.js +6 -6
- package/dist/components/LoginDrawer/LoginDrawer.js.map +1 -1
- package/dist/components/MemoriWidget/MemoriWidget.js +143 -64
- package/dist/components/MemoriWidget/MemoriWidget.js.map +1 -1
- package/dist/components/SignupForm/SignupForm.js +4 -4
- package/dist/components/SignupForm/SignupForm.js.map +1 -1
- package/dist/components/StartPanel/StartPanel.js +5 -5
- package/dist/components/StartPanel/StartPanel.js.map +1 -1
- package/dist/components/UploadButton/UploadButton.js +2 -2
- package/dist/components/UploadButton/UploadButton.js.map +1 -1
- package/dist/components/WhyThisAnswer/WhyThisAnswer.css +43 -0
- package/dist/components/WhyThisAnswer/WhyThisAnswer.js +2 -1
- package/dist/components/WhyThisAnswer/WhyThisAnswer.js.map +1 -1
- package/dist/context/visemeContext.js +0 -39
- package/dist/context/visemeContext.js.map +1 -1
- package/dist/index.js +4 -3
- package/dist/index.js.map +1 -1
- package/dist/locales/de.json +1 -0
- package/dist/locales/en.json +1 -0
- package/dist/locales/es.json +1 -0
- package/dist/locales/fr.json +1 -0
- package/dist/locales/it.json +1 -0
- package/esm/components/Avatar/Avatar.js +3 -3
- package/esm/components/Avatar/Avatar.js.map +1 -1
- package/esm/components/Avatar/AvatarView/AvatarComponent/Shadow/DynamicShadow.d.ts +3 -2
- package/esm/components/Avatar/AvatarView/AvatarComponent/Shadow/DynamicShadow.js +13 -6
- package/esm/components/Avatar/AvatarView/AvatarComponent/Shadow/DynamicShadow.js.map +1 -1
- package/esm/components/Avatar/AvatarView/AvatarComponent/avatarComponent.d.ts +14 -18
- package/esm/components/Avatar/AvatarView/AvatarComponent/avatarComponent.js +20 -78
- package/esm/components/Avatar/AvatarView/AvatarComponent/avatarComponent.js.map +1 -1
- package/esm/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/fullbodyAvatar.d.ts +17 -2
- package/esm/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/fullbodyAvatar.js +99 -74
- package/esm/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/fullbodyAvatar.js.map +1 -1
- package/esm/components/Avatar/AvatarView/AvatarComponent/components/controllers/AvatarAnimator.d.ts +65 -0
- package/esm/components/Avatar/AvatarView/AvatarComponent/components/controllers/AvatarAnimator.js +743 -0
- package/esm/components/Avatar/AvatarView/AvatarComponent/components/controllers/AvatarAnimator.js.map +1 -0
- package/esm/components/Avatar/AvatarView/AvatarComponent/components/controllers/MorphTargetController.d.ts +9 -2
- package/esm/components/Avatar/AvatarView/AvatarComponent/components/controllers/MorphTargetController.js +61 -3
- package/esm/components/Avatar/AvatarView/AvatarComponent/components/controllers/MorphTargetController.js.map +1 -1
- package/esm/components/Avatar/AvatarView/AvatarComponent/components/halfbodyAvatar.d.ts +3 -4
- package/esm/components/Avatar/AvatarView/AvatarComponent/components/halfbodyAvatar.js +5 -11
- package/esm/components/Avatar/AvatarView/AvatarComponent/components/halfbodyAvatar.js.map +1 -1
- package/esm/components/Avatar/AvatarView/AvatarComponent/constants.d.ts +13 -52
- package/esm/components/Avatar/AvatarView/AvatarComponent/constants.js +67 -69
- package/esm/components/Avatar/AvatarView/AvatarComponent/constants.js.map +1 -1
- package/esm/components/Avatar/AvatarView/index.d.ts +1 -1
- package/esm/components/Avatar/AvatarView/index.js +2 -2
- package/esm/components/Avatar/AvatarView/index.js.map +1 -1
- package/esm/components/Chat/Chat.js +2 -2
- package/esm/components/Chat/Chat.js.map +1 -1
- package/esm/components/ChatBubble/ChatBubble.js +12 -9
- package/esm/components/ChatBubble/ChatBubble.js.map +1 -1
- package/esm/components/ExpertsDrawer/ExpertsDrawer.js +1 -1
- package/esm/components/ExpertsDrawer/ExpertsDrawer.js.map +1 -1
- package/esm/components/LoginDrawer/LoginDrawer.js +6 -6
- package/esm/components/LoginDrawer/LoginDrawer.js.map +1 -1
- package/esm/components/MemoriWidget/MemoriWidget.js +143 -64
- package/esm/components/MemoriWidget/MemoriWidget.js.map +1 -1
- package/esm/components/SignupForm/SignupForm.js +4 -4
- package/esm/components/SignupForm/SignupForm.js.map +1 -1
- package/esm/components/StartPanel/StartPanel.js +5 -5
- package/esm/components/StartPanel/StartPanel.js.map +1 -1
- package/esm/components/UploadButton/UploadButton.js +2 -2
- package/esm/components/UploadButton/UploadButton.js.map +1 -1
- package/esm/components/WhyThisAnswer/WhyThisAnswer.css +43 -0
- package/esm/components/WhyThisAnswer/WhyThisAnswer.js +2 -1
- package/esm/components/WhyThisAnswer/WhyThisAnswer.js.map +1 -1
- package/esm/context/visemeContext.js +0 -39
- package/esm/context/visemeContext.js.map +1 -1
- package/esm/index.js +4 -3
- package/esm/index.js.map +1 -1
- package/esm/locales/de.json +1 -0
- package/esm/locales/en.json +1 -0
- package/esm/locales/es.json +1 -0
- package/esm/locales/fr.json +1 -0
- package/esm/locales/it.json +1 -0
- package/package.json +2 -2
- package/src/components/Avatar/Avatar.tsx +3 -3
- package/src/components/Avatar/AvatarView/AvatarComponent/Shadow/DynamicShadow.tsx +15 -8
- package/src/components/Avatar/AvatarView/AvatarComponent/avatarComponent.tsx +64 -219
- package/src/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/fullbodyAvatar.tsx +221 -124
- package/src/components/Avatar/AvatarView/AvatarComponent/components/controllers/AvatarAnimator.ts +1250 -0
- package/src/components/Avatar/AvatarView/AvatarComponent/components/controllers/MorphTargetController.ts +164 -8
- package/src/components/Avatar/AvatarView/AvatarComponent/components/halfbodyAvatar.tsx +19 -17
- package/src/components/Avatar/AvatarView/AvatarComponent/constants.ts +80 -79
- package/src/components/Avatar/AvatarView/index.tsx +1 -7
- package/src/components/Chat/Chat.tsx +2 -2
- package/src/components/ChatBubble/ChatBubble.tsx +37 -26
- package/src/components/ExpertsDrawer/ExpertsDrawer.tsx +1 -1
- package/src/components/LoginDrawer/LoginDrawer.tsx +6 -6
- package/src/components/MemoriWidget/MemoriWidget.tsx +184 -78
- package/src/components/SignupForm/SignupForm.tsx +5 -5
- package/src/components/StartPanel/StartPanel.tsx +5 -5
- package/src/components/UploadButton/UploadButton.tsx +4 -4
- package/src/components/UploadButton/__snapshots__/UploadButton.test.tsx.snap +1 -1
- package/src/components/WhyThisAnswer/WhyThisAnswer.css +43 -0
- package/src/components/WhyThisAnswer/WhyThisAnswer.stories.tsx +44 -3
- package/src/components/WhyThisAnswer/WhyThisAnswer.test.tsx +128 -8
- package/src/components/WhyThisAnswer/WhyThisAnswer.tsx +28 -3
- package/src/components/WhyThisAnswer/__snapshots__/WhyThisAnswer.test.tsx.snap +15 -1
- package/src/components/layouts/layouts.stories.tsx +0 -8
- package/src/context/visemeContext.tsx +40 -41
- package/src/index.stories.tsx +63 -65
- package/src/index.tsx +5 -3
- package/src/locales/de.json +1 -0
- package/src/locales/en.json +1 -0
- package/src/locales/es.json +1 -0
- package/src/locales/fr.json +1 -0
- package/src/locales/it.json +1 -0
- package/src/mocks/data.ts +3 -9
- package/src/components/Avatar/AvatarView/AvatarComponent/components/controllers/AnimationController.ts +0 -308
- package/src/helpers/tenant.ts +0 -47
|
@@ -154,7 +154,7 @@ let speakerMuted = false;
|
|
|
154
154
|
let memoriSpeaking = false;
|
|
155
155
|
let userToken;
|
|
156
156
|
const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenantID, memoriLang, multilingual, integration, layout, customLayout, showShare, preview = false, embed = false, showCopyButton = true, showTranslationOriginal = false, showInputs = true, showDates = false, showContextPerLine = false, showSettings, showTypingText = false, showClear = false, showLogin = false, showUpload, showOnlyLastMessages, height = '100vh', secret, baseUrl = 'https://aisuru.com', apiURL = 'https://backend.memori.ai', engineURL = 'https://engine.memori.ai', initialContextVars, initialQuestion, ogImage, sessionID: initialSessionID, tenant, personification, authToken, AZURE_COGNITIVE_SERVICES_TTS_KEY, enableAudio, defaultSpeakerActive = true, disableTextEnteredEvents = false, onStateChange, additionalInfo, additionalSettings, customMediaRenderer, userAvatar, useMathFormatting = false, autoStart = false, applyVarsToRoot = false, }) => {
|
|
157
|
-
var _a, _b, _c, _d, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3
|
|
157
|
+
var _a, _b, _c, _d, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3;
|
|
158
158
|
const { t, i18n } = useTranslation();
|
|
159
159
|
const [isClient, setIsClient] = useState(false);
|
|
160
160
|
useEffect(() => {
|
|
@@ -1176,7 +1176,9 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1176
1176
|
return text;
|
|
1177
1177
|
const phonemes = {
|
|
1178
1178
|
...((_a = phonemesMap.common) !== null && _a !== void 0 ? _a : {}),
|
|
1179
|
-
...((tenant === null || tenant === void 0 ? void 0 : tenant.
|
|
1179
|
+
...((tenant === null || tenant === void 0 ? void 0 : tenant.name) && phonemesMap[tenant.name]
|
|
1180
|
+
? phonemesMap[tenant.name]
|
|
1181
|
+
: {}),
|
|
1180
1182
|
};
|
|
1181
1183
|
const phonemesPairs = Object.keys(phonemes).map(word => {
|
|
1182
1184
|
var _a;
|
|
@@ -1336,23 +1338,17 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1336
1338
|
cleanup();
|
|
1337
1339
|
};
|
|
1338
1340
|
const cleanup = () => {
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
try {
|
|
1344
|
-
if (speechSynthesizer) {
|
|
1345
|
-
const currentSynthesizer = speechSynthesizer;
|
|
1346
|
-
speechSynthesizer = null;
|
|
1347
|
-
console.debug('Closing speech synthesizer');
|
|
1348
|
-
currentSynthesizer.close();
|
|
1349
|
-
}
|
|
1341
|
+
if (recognizer) {
|
|
1342
|
+
recognizer.stopContinuousRecognitionAsync();
|
|
1343
|
+
recognizer.close();
|
|
1344
|
+
recognizer = null;
|
|
1350
1345
|
}
|
|
1351
|
-
|
|
1352
|
-
|
|
1346
|
+
if (speechSynthesizer) {
|
|
1347
|
+
speechSynthesizer.close();
|
|
1353
1348
|
speechSynthesizer = null;
|
|
1354
1349
|
}
|
|
1355
|
-
|
|
1350
|
+
setListening(false);
|
|
1351
|
+
clearListeningTimeout();
|
|
1356
1352
|
};
|
|
1357
1353
|
const stopAudio = async () => {
|
|
1358
1354
|
setIsPlayingAudio(false);
|
|
@@ -1402,23 +1398,30 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1402
1398
|
};
|
|
1403
1399
|
const setListeningTimeout = () => {
|
|
1404
1400
|
clearListeningTimeout();
|
|
1405
|
-
|
|
1401
|
+
console.debug('Setting speech processing timeout');
|
|
1402
|
+
const timeout = setTimeout(() => {
|
|
1403
|
+
console.debug('Speech timeout triggered, processing transcript');
|
|
1404
|
+
handleTranscriptProcessing();
|
|
1405
|
+
}, continuousSpeechTimeout * 1000 + 300);
|
|
1406
1406
|
setTranscriptTimeout(timeout);
|
|
1407
1407
|
};
|
|
1408
1408
|
const clearListeningTimeout = () => {
|
|
1409
1409
|
if (transcriptTimeout) {
|
|
1410
|
+
console.debug('Clearing transcript timeout');
|
|
1410
1411
|
clearTimeout(transcriptTimeout);
|
|
1411
1412
|
setTranscriptTimeout(null);
|
|
1412
1413
|
}
|
|
1413
1414
|
};
|
|
1414
1415
|
const resetListeningTimeout = () => {
|
|
1415
1416
|
clearListeningTimeout();
|
|
1416
|
-
if (continuousSpeech) {
|
|
1417
|
+
if (continuousSpeech && !isProcessingSTT) {
|
|
1418
|
+
console.debug('Setting new listening timeout');
|
|
1417
1419
|
setListeningTimeout();
|
|
1418
1420
|
}
|
|
1419
1421
|
};
|
|
1420
1422
|
useEffect(() => {
|
|
1421
|
-
if (!isSpeaking) {
|
|
1423
|
+
if (!isSpeaking && transcript && transcript.length > 0) {
|
|
1424
|
+
console.debug('Transcript updated while not speaking, resetting timeout');
|
|
1422
1425
|
resetListeningTimeout();
|
|
1423
1426
|
resetInteractionTimeout();
|
|
1424
1427
|
}
|
|
@@ -1428,95 +1431,162 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1428
1431
|
clearListeningTimeout();
|
|
1429
1432
|
};
|
|
1430
1433
|
}, []);
|
|
1434
|
+
let microphoneStream = null;
|
|
1431
1435
|
const startListening = async () => {
|
|
1436
|
+
console.debug('Starting speech recognition...');
|
|
1432
1437
|
if (!AZURE_COGNITIVE_SERVICES_TTS_KEY) {
|
|
1438
|
+
console.error('No TTS key available');
|
|
1433
1439
|
throw new Error('No TTS key available');
|
|
1434
1440
|
}
|
|
1435
1441
|
if (!sessionId) {
|
|
1442
|
+
console.error('No session ID available');
|
|
1436
1443
|
throw new Error('No session ID available');
|
|
1437
1444
|
}
|
|
1438
|
-
|
|
1445
|
+
if (recognizer) {
|
|
1446
|
+
console.debug('Cleaning up existing recognizer...');
|
|
1447
|
+
try {
|
|
1448
|
+
await new Promise((resolve, _) => {
|
|
1449
|
+
recognizer === null || recognizer === void 0 ? void 0 : recognizer.stopContinuousRecognitionAsync(resolve, error => {
|
|
1450
|
+
console.error('Error stopping recognition:', error);
|
|
1451
|
+
resolve();
|
|
1452
|
+
});
|
|
1453
|
+
});
|
|
1454
|
+
console.debug('Closing existing recognizer...');
|
|
1455
|
+
recognizer.close();
|
|
1456
|
+
recognizer = null;
|
|
1457
|
+
}
|
|
1458
|
+
catch (error) {
|
|
1459
|
+
console.error('Error during recognizer cleanup:', error);
|
|
1460
|
+
}
|
|
1461
|
+
}
|
|
1462
|
+
console.debug('Resetting transcript and STT state...');
|
|
1439
1463
|
resetTranscript();
|
|
1464
|
+
setIsProcessingSTT(false);
|
|
1465
|
+
console.debug('Adding delay for Azure services cleanup...');
|
|
1466
|
+
await new Promise(resolve => setTimeout(resolve, 500));
|
|
1440
1467
|
try {
|
|
1441
|
-
|
|
1468
|
+
console.debug('Requesting microphone access...');
|
|
1469
|
+
if (microphoneStream) {
|
|
1470
|
+
microphoneStream.getTracks().forEach(track => track.stop());
|
|
1471
|
+
microphoneStream = null;
|
|
1472
|
+
}
|
|
1473
|
+
const stream = await navigator.mediaDevices.getUserMedia({
|
|
1474
|
+
audio: true,
|
|
1475
|
+
});
|
|
1442
1476
|
setHasUserActivatedListening(true);
|
|
1477
|
+
console.debug('Setting up speech config...');
|
|
1443
1478
|
speechConfig = setupSpeechConfig(AZURE_COGNITIVE_SERVICES_TTS_KEY);
|
|
1479
|
+
console.debug('Creating audio config and recognizer...');
|
|
1444
1480
|
const audioConfig = speechSdk.AudioConfig.fromDefaultMicrophoneInput();
|
|
1445
1481
|
recognizer = new speechSdk.SpeechRecognizer(speechConfig, audioConfig);
|
|
1482
|
+
console.debug('Setting up recognizer handlers...');
|
|
1446
1483
|
setupRecognizerHandlers(recognizer);
|
|
1484
|
+
console.debug('Starting continuous recognition...');
|
|
1485
|
+
await new Promise((resolve, reject) => {
|
|
1486
|
+
recognizer === null || recognizer === void 0 ? void 0 : recognizer.startContinuousRecognitionAsync(resolve, error => {
|
|
1487
|
+
console.error('Failed to start recognition:', error);
|
|
1488
|
+
reject(error);
|
|
1489
|
+
});
|
|
1490
|
+
});
|
|
1491
|
+
console.debug('Speech recognition started successfully');
|
|
1447
1492
|
setListening(true);
|
|
1448
|
-
recognizer.startContinuousRecognitionAsync();
|
|
1449
|
-
recognizer.canceled = (_s, e) => {
|
|
1450
|
-
if (e.reason === speechSdk.CancellationReason.Error) {
|
|
1451
|
-
console.debug(`"CANCELED: ErrorCode=${e.errorCode}`);
|
|
1452
|
-
console.debug(`"CANCELED: ErrorDetails=${e.errorDetails}`);
|
|
1453
|
-
console.debug('CANCELED: Did you set the speech resource key and region values?');
|
|
1454
|
-
stopListening();
|
|
1455
|
-
cleanup();
|
|
1456
|
-
}
|
|
1457
|
-
stopListening();
|
|
1458
|
-
};
|
|
1459
|
-
recognizer.sessionStopped = (_s, _e) => {
|
|
1460
|
-
stopListening();
|
|
1461
|
-
resetTranscript();
|
|
1462
|
-
};
|
|
1463
1493
|
}
|
|
1464
1494
|
catch (error) {
|
|
1465
1495
|
console.error('Error in startListening:', error);
|
|
1466
|
-
|
|
1496
|
+
if (recognizer) {
|
|
1497
|
+
console.debug('Cleaning up recognizer after error...');
|
|
1498
|
+
recognizer.close();
|
|
1499
|
+
recognizer = null;
|
|
1500
|
+
}
|
|
1501
|
+
setListening(false);
|
|
1467
1502
|
throw error;
|
|
1468
1503
|
}
|
|
1469
1504
|
};
|
|
1470
1505
|
const setupSpeechConfig = (AZURE_COGNITIVE_SERVICES_TTS_KEY) => {
|
|
1506
|
+
console.debug('Creating speech config...');
|
|
1471
1507
|
speechConfig = speechSdk.SpeechConfig.fromSubscription(AZURE_COGNITIVE_SERVICES_TTS_KEY, 'westeurope');
|
|
1508
|
+
console.debug('Setting speech recognition language:', userLang);
|
|
1472
1509
|
speechConfig.speechRecognitionLanguage = getCultureCodeByLanguage(userLang);
|
|
1473
1510
|
speechConfig.speechSynthesisLanguage = getCultureCodeByLanguage(userLang);
|
|
1474
1511
|
speechConfig.speechSynthesisVoiceName = getTTSVoice(userLang);
|
|
1475
1512
|
return speechConfig;
|
|
1476
1513
|
};
|
|
1514
|
+
const [isProcessingSTT, setIsProcessingSTT] = useState(false);
|
|
1477
1515
|
const setupRecognizerHandlers = (recognizer) => {
|
|
1478
1516
|
if (recognizer) {
|
|
1517
|
+
console.debug('Setting up recognizer event handlers...');
|
|
1479
1518
|
recognizer.recognized = (_, event) => {
|
|
1519
|
+
console.debug('Recognition event received');
|
|
1480
1520
|
handleRecognizedSpeech(event.result.text);
|
|
1481
1521
|
};
|
|
1522
|
+
console.debug('Configuring recognizer properties...');
|
|
1482
1523
|
recognizer.properties.setProperty('SpeechServiceResponse_JsonResult', 'true');
|
|
1483
1524
|
recognizer.properties.setProperty('SpeechServiceConnection_NoiseSuppression', 'true');
|
|
1484
1525
|
recognizer.properties.setProperty('SpeechServiceConnection_SNRThresholdDb', '10.0');
|
|
1485
1526
|
}
|
|
1486
1527
|
};
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
if (!text || text.trim().length === 0) {
|
|
1490
|
-
console.debug('
|
|
1528
|
+
let isProcessingSpeech = false;
|
|
1529
|
+
const processSpeechAndSendMessage = (text) => {
|
|
1530
|
+
if (isProcessingSpeech || !text || text.trim().length === 0) {
|
|
1531
|
+
console.debug('Skipping speech processing: already processing or empty text');
|
|
1491
1532
|
return;
|
|
1492
1533
|
}
|
|
1534
|
+
try {
|
|
1535
|
+
isProcessingSpeech = true;
|
|
1536
|
+
const message = stripDuplicates(text);
|
|
1537
|
+
console.debug('Processing speech message:', message);
|
|
1538
|
+
if (message.length > 0) {
|
|
1539
|
+
setIsProcessingSTT(true);
|
|
1540
|
+
setUserMessage('');
|
|
1541
|
+
console.debug('Sending message:', message);
|
|
1542
|
+
sendMessage(message);
|
|
1543
|
+
resetTranscript();
|
|
1544
|
+
clearListening();
|
|
1545
|
+
}
|
|
1546
|
+
}
|
|
1547
|
+
finally {
|
|
1548
|
+
setTimeout(() => {
|
|
1549
|
+
isProcessingSpeech = false;
|
|
1550
|
+
}, 1000);
|
|
1551
|
+
}
|
|
1552
|
+
};
|
|
1553
|
+
const handleRecognizedSpeech = (text) => {
|
|
1554
|
+
console.debug('Speech recognized:', text);
|
|
1493
1555
|
setTranscript(text);
|
|
1494
1556
|
setIsSpeaking(false);
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
if (message.length > 0) {
|
|
1498
|
-
setUserMessage(message);
|
|
1557
|
+
if (!continuousSpeech) {
|
|
1558
|
+
processSpeechAndSendMessage(text);
|
|
1499
1559
|
}
|
|
1500
1560
|
};
|
|
1501
1561
|
const handleTranscriptProcessing = () => {
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
sendMessage(message);
|
|
1505
|
-
resetTranscript();
|
|
1506
|
-
setUserMessage('');
|
|
1507
|
-
clearListening();
|
|
1562
|
+
if (transcript && transcript.length > 0 && listening) {
|
|
1563
|
+
processSpeechAndSendMessage(transcript);
|
|
1508
1564
|
}
|
|
1509
1565
|
else if (listening) {
|
|
1510
1566
|
resetInteractionTimeout();
|
|
1511
1567
|
}
|
|
1512
1568
|
};
|
|
1513
|
-
const stopListening = () => {
|
|
1569
|
+
const stopListening = async () => {
|
|
1514
1570
|
console.debug('Stopping speech recognition');
|
|
1515
1571
|
if (recognizer) {
|
|
1516
|
-
|
|
1517
|
-
|
|
1572
|
+
try {
|
|
1573
|
+
recognizer.stopContinuousRecognitionAsync();
|
|
1574
|
+
recognizer.close();
|
|
1575
|
+
}
|
|
1576
|
+
catch (error) {
|
|
1577
|
+
console.error('Error stopping recognizer:', error);
|
|
1578
|
+
}
|
|
1518
1579
|
recognizer = null;
|
|
1519
1580
|
}
|
|
1581
|
+
if (microphoneStream) {
|
|
1582
|
+
try {
|
|
1583
|
+
microphoneStream.getTracks().forEach(track => track.stop());
|
|
1584
|
+
}
|
|
1585
|
+
catch (error) {
|
|
1586
|
+
console.error('Error stopping microphone stream:', error);
|
|
1587
|
+
}
|
|
1588
|
+
microphoneStream = null;
|
|
1589
|
+
}
|
|
1520
1590
|
setListening(false);
|
|
1521
1591
|
};
|
|
1522
1592
|
const clearListening = () => {
|
|
@@ -1630,7 +1700,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1630
1700
|
'--memori-nav-bg-image': 'none',
|
|
1631
1701
|
'--memori-nav-bg': `rgba(${integrationConfig.innerBgColor === 'dark'
|
|
1632
1702
|
? '0, 0, 0'
|
|
1633
|
-
: '255, 255, 255'}, ${(
|
|
1703
|
+
: '255, 255, 255'}, ${(_s = integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.innerBgAlpha) !== null && _s !== void 0 ? _s : 0.4})`,
|
|
1634
1704
|
}
|
|
1635
1705
|
: {
|
|
1636
1706
|
'--memori-inner-content-pad': '0px',
|
|
@@ -1727,7 +1797,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1727
1797
|
};
|
|
1728
1798
|
}, [sessionId, userLang, disableTextEnteredEvents]);
|
|
1729
1799
|
const onClickStart = useCallback(async (session, initialSessionExpired = false) => {
|
|
1730
|
-
var _a, _b, _c, _d, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r,
|
|
1800
|
+
var _a, _b, _c, _d, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
|
1731
1801
|
const sessionID = (session === null || session === void 0 ? void 0 : session.sessionID) || sessionId;
|
|
1732
1802
|
const dialogState = (session === null || session === void 0 ? void 0 : session.dialogState) || currentDialogState;
|
|
1733
1803
|
setClickedStart(true);
|
|
@@ -1745,6 +1815,12 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1745
1815
|
let birth = birthDate || storageBirthDate || (user === null || user === void 0 ? void 0 : user.birthDate);
|
|
1746
1816
|
if (!birth && autoStart && initialSessionID)
|
|
1747
1817
|
birth = '1970-01-01T10:24:03.845Z';
|
|
1818
|
+
const localPosition = getLocalConfig('position', undefined);
|
|
1819
|
+
if (autoStart && !localPosition && memori.needsPosition) {
|
|
1820
|
+
console.log('position required', localPosition);
|
|
1821
|
+
setShowPositionDrawer(true);
|
|
1822
|
+
return;
|
|
1823
|
+
}
|
|
1748
1824
|
if (!sessionID && !!minAge && !birth) {
|
|
1749
1825
|
setShowAgeVerification(true);
|
|
1750
1826
|
setClickedStart(false);
|
|
@@ -1951,7 +2027,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1951
2027
|
sessionId: sessionID,
|
|
1952
2028
|
text: initialQuestion,
|
|
1953
2029
|
});
|
|
1954
|
-
translateDialogState((
|
|
2030
|
+
translateDialogState((_s = response.currentState) !== null && _s !== void 0 ? _s : currentState, userLang, undefined, false)
|
|
1955
2031
|
.then(ts => {
|
|
1956
2032
|
let text = ts.translatedEmission || ts.emission;
|
|
1957
2033
|
if (text) {
|
|
@@ -2089,13 +2165,13 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
2089
2165
|
memori,
|
|
2090
2166
|
tenant,
|
|
2091
2167
|
history,
|
|
2092
|
-
showShare: (
|
|
2168
|
+
showShare: (_t = showShare !== null && showShare !== void 0 ? showShare : integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.showShare) !== null && _t !== void 0 ? _t : true,
|
|
2093
2169
|
position,
|
|
2094
2170
|
setShowPositionDrawer,
|
|
2095
2171
|
setShowSettingsDrawer,
|
|
2096
2172
|
setShowKnownFactsDrawer,
|
|
2097
2173
|
setShowExpertsDrawer,
|
|
2098
|
-
enableAudio: (
|
|
2174
|
+
enableAudio: (_u = enableAudio !== null && enableAudio !== void 0 ? enableAudio : integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.enableAudio) !== null && _u !== void 0 ? _u : true,
|
|
2099
2175
|
showSpeaker: !!AZURE_COGNITIVE_SERVICES_TTS_KEY,
|
|
2100
2176
|
speakerMuted: muteSpeaker || speakerMuted,
|
|
2101
2177
|
setSpeakerMuted: mute => {
|
|
@@ -2118,7 +2194,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
2118
2194
|
source.connect(audioContext.destination);
|
|
2119
2195
|
}
|
|
2120
2196
|
},
|
|
2121
|
-
showSettings: (
|
|
2197
|
+
showSettings: (_v = showSettings !== null && showSettings !== void 0 ? showSettings : integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.showSettings) !== null && _v !== void 0 ? _v : true,
|
|
2122
2198
|
hasUserActivatedSpeak,
|
|
2123
2199
|
showReload: selectedLayout === 'TOTEM',
|
|
2124
2200
|
showClear,
|
|
@@ -2176,7 +2252,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
2176
2252
|
tenant,
|
|
2177
2253
|
translateTo: isMultilanguageEnabled &&
|
|
2178
2254
|
userLang.toUpperCase() !==
|
|
2179
|
-
((
|
|
2255
|
+
((_0 = ((_z = (_y = (_x = (_w = memori.culture) === null || _w === void 0 ? void 0 : _w.split('-')) === null || _x === void 0 ? void 0 : _x[0]) !== null && _y !== void 0 ? _y : i18n.language) !== null && _z !== void 0 ? _z : 'IT')) === null || _0 === void 0 ? void 0 : _0.toUpperCase())
|
|
2180
2256
|
? userLang
|
|
2181
2257
|
: undefined,
|
|
2182
2258
|
baseUrl,
|
|
@@ -2186,7 +2262,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
2186
2262
|
typingText,
|
|
2187
2263
|
showTypingText,
|
|
2188
2264
|
history: showFullHistory ? history : history.slice(-2),
|
|
2189
|
-
authToken: (
|
|
2265
|
+
authToken: (_2 = (_1 = loginToken !== null && loginToken !== void 0 ? loginToken : userToken) !== null && _1 !== void 0 ? _1 : additionalInfo === null || additionalInfo === void 0 ? void 0 : additionalInfo.loginToken) !== null && _2 !== void 0 ? _2 : authToken,
|
|
2190
2266
|
dialogState: currentDialogState,
|
|
2191
2267
|
setDialogState: setCurrentDialogState,
|
|
2192
2268
|
pushMessage,
|
|
@@ -2292,7 +2368,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
2292
2368
|
setAuthModalState(null);
|
|
2293
2369
|
setGotErrorInOpening(true);
|
|
2294
2370
|
});
|
|
2295
|
-
}, minimumNumberOfRecoveryTokens: (
|
|
2371
|
+
}, minimumNumberOfRecoveryTokens: (_3 = memori === null || memori === void 0 ? void 0 : memori.minimumNumberOfRecoveryTokens) !== null && _3 !== void 0 ? _3 : 1 })), isClient && (_jsx(AgeVerificationModal, { visible: showAgeVerification, minAge: minAge, onClose: birthDate => {
|
|
2296
2372
|
var _a, _b, _c, _d;
|
|
2297
2373
|
if (birthDate) {
|
|
2298
2374
|
setBirthDate(birthDate);
|
|
@@ -2320,7 +2396,10 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
2320
2396
|
if (position)
|
|
2321
2397
|
applyPosition(position);
|
|
2322
2398
|
setShowPositionDrawer(false);
|
|
2323
|
-
|
|
2399
|
+
if (autoStart) {
|
|
2400
|
+
onClickStart();
|
|
2401
|
+
}
|
|
2402
|
+
} })), showKnownFactsDrawer && sessionId && (_jsx(KnownFacts, { apiClient: client, memori: memori, sessionID: sessionId, visible: showKnownFactsDrawer, closeDrawer: () => setShowKnownFactsDrawer(false) })), showExpertsDrawer && !!experts && (_jsx(ExpertsDrawer, { apiUrl: client.constants.BACKEND_URL, baseUrl: baseUrl, tenant: tenant, experts: experts, open: showExpertsDrawer, onClose: () => setShowExpertsDrawer(false) })), showLoginDrawer && (tenant === null || tenant === void 0 ? void 0 : tenant.name) && (_jsx(LoginDrawer, { tenant: tenant, apiClient: client, open: !!showLoginDrawer, user: user, loginToken: loginToken, onClose: () => setShowLoginDrawer(false), onLogin: (user, token) => {
|
|
2324
2403
|
setUser(user);
|
|
2325
2404
|
setLoginToken(token);
|
|
2326
2405
|
userToken = token;
|