@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
|
@@ -157,7 +157,7 @@ let speakerMuted = false;
|
|
|
157
157
|
let memoriSpeaking = false;
|
|
158
158
|
let userToken;
|
|
159
159
|
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, }) => {
|
|
160
|
-
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
|
|
160
|
+
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;
|
|
161
161
|
const { t, i18n } = (0, react_i18next_1.useTranslation)();
|
|
162
162
|
const [isClient, setIsClient] = (0, react_1.useState)(false);
|
|
163
163
|
(0, react_1.useEffect)(() => {
|
|
@@ -1179,7 +1179,9 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1179
1179
|
return text;
|
|
1180
1180
|
const phonemes = {
|
|
1181
1181
|
...((_a = phonemesMap.common) !== null && _a !== void 0 ? _a : {}),
|
|
1182
|
-
...((tenant === null || tenant === void 0 ? void 0 : tenant.
|
|
1182
|
+
...((tenant === null || tenant === void 0 ? void 0 : tenant.name) && phonemesMap[tenant.name]
|
|
1183
|
+
? phonemesMap[tenant.name]
|
|
1184
|
+
: {}),
|
|
1183
1185
|
};
|
|
1184
1186
|
const phonemesPairs = Object.keys(phonemes).map(word => {
|
|
1185
1187
|
var _a;
|
|
@@ -1339,23 +1341,17 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1339
1341
|
cleanup();
|
|
1340
1342
|
};
|
|
1341
1343
|
const cleanup = () => {
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
try {
|
|
1347
|
-
if (speechSynthesizer) {
|
|
1348
|
-
const currentSynthesizer = speechSynthesizer;
|
|
1349
|
-
speechSynthesizer = null;
|
|
1350
|
-
console.debug('Closing speech synthesizer');
|
|
1351
|
-
currentSynthesizer.close();
|
|
1352
|
-
}
|
|
1344
|
+
if (recognizer) {
|
|
1345
|
+
recognizer.stopContinuousRecognitionAsync();
|
|
1346
|
+
recognizer.close();
|
|
1347
|
+
recognizer = null;
|
|
1353
1348
|
}
|
|
1354
|
-
|
|
1355
|
-
|
|
1349
|
+
if (speechSynthesizer) {
|
|
1350
|
+
speechSynthesizer.close();
|
|
1356
1351
|
speechSynthesizer = null;
|
|
1357
1352
|
}
|
|
1358
|
-
|
|
1353
|
+
setListening(false);
|
|
1354
|
+
clearListeningTimeout();
|
|
1359
1355
|
};
|
|
1360
1356
|
const stopAudio = async () => {
|
|
1361
1357
|
setIsPlayingAudio(false);
|
|
@@ -1405,23 +1401,30 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1405
1401
|
};
|
|
1406
1402
|
const setListeningTimeout = () => {
|
|
1407
1403
|
clearListeningTimeout();
|
|
1408
|
-
|
|
1404
|
+
console.debug('Setting speech processing timeout');
|
|
1405
|
+
const timeout = setTimeout(() => {
|
|
1406
|
+
console.debug('Speech timeout triggered, processing transcript');
|
|
1407
|
+
handleTranscriptProcessing();
|
|
1408
|
+
}, continuousSpeechTimeout * 1000 + 300);
|
|
1409
1409
|
setTranscriptTimeout(timeout);
|
|
1410
1410
|
};
|
|
1411
1411
|
const clearListeningTimeout = () => {
|
|
1412
1412
|
if (transcriptTimeout) {
|
|
1413
|
+
console.debug('Clearing transcript timeout');
|
|
1413
1414
|
clearTimeout(transcriptTimeout);
|
|
1414
1415
|
setTranscriptTimeout(null);
|
|
1415
1416
|
}
|
|
1416
1417
|
};
|
|
1417
1418
|
const resetListeningTimeout = () => {
|
|
1418
1419
|
clearListeningTimeout();
|
|
1419
|
-
if (continuousSpeech) {
|
|
1420
|
+
if (continuousSpeech && !isProcessingSTT) {
|
|
1421
|
+
console.debug('Setting new listening timeout');
|
|
1420
1422
|
setListeningTimeout();
|
|
1421
1423
|
}
|
|
1422
1424
|
};
|
|
1423
1425
|
(0, react_1.useEffect)(() => {
|
|
1424
|
-
if (!isSpeaking) {
|
|
1426
|
+
if (!isSpeaking && transcript && transcript.length > 0) {
|
|
1427
|
+
console.debug('Transcript updated while not speaking, resetting timeout');
|
|
1425
1428
|
resetListeningTimeout();
|
|
1426
1429
|
resetInteractionTimeout();
|
|
1427
1430
|
}
|
|
@@ -1431,95 +1434,162 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1431
1434
|
clearListeningTimeout();
|
|
1432
1435
|
};
|
|
1433
1436
|
}, []);
|
|
1437
|
+
let microphoneStream = null;
|
|
1434
1438
|
const startListening = async () => {
|
|
1439
|
+
console.debug('Starting speech recognition...');
|
|
1435
1440
|
if (!AZURE_COGNITIVE_SERVICES_TTS_KEY) {
|
|
1441
|
+
console.error('No TTS key available');
|
|
1436
1442
|
throw new Error('No TTS key available');
|
|
1437
1443
|
}
|
|
1438
1444
|
if (!sessionId) {
|
|
1445
|
+
console.error('No session ID available');
|
|
1439
1446
|
throw new Error('No session ID available');
|
|
1440
1447
|
}
|
|
1441
|
-
|
|
1448
|
+
if (recognizer) {
|
|
1449
|
+
console.debug('Cleaning up existing recognizer...');
|
|
1450
|
+
try {
|
|
1451
|
+
await new Promise((resolve, _) => {
|
|
1452
|
+
recognizer === null || recognizer === void 0 ? void 0 : recognizer.stopContinuousRecognitionAsync(resolve, error => {
|
|
1453
|
+
console.error('Error stopping recognition:', error);
|
|
1454
|
+
resolve();
|
|
1455
|
+
});
|
|
1456
|
+
});
|
|
1457
|
+
console.debug('Closing existing recognizer...');
|
|
1458
|
+
recognizer.close();
|
|
1459
|
+
recognizer = null;
|
|
1460
|
+
}
|
|
1461
|
+
catch (error) {
|
|
1462
|
+
console.error('Error during recognizer cleanup:', error);
|
|
1463
|
+
}
|
|
1464
|
+
}
|
|
1465
|
+
console.debug('Resetting transcript and STT state...');
|
|
1442
1466
|
resetTranscript();
|
|
1467
|
+
setIsProcessingSTT(false);
|
|
1468
|
+
console.debug('Adding delay for Azure services cleanup...');
|
|
1469
|
+
await new Promise(resolve => setTimeout(resolve, 500));
|
|
1443
1470
|
try {
|
|
1444
|
-
|
|
1471
|
+
console.debug('Requesting microphone access...');
|
|
1472
|
+
if (microphoneStream) {
|
|
1473
|
+
microphoneStream.getTracks().forEach(track => track.stop());
|
|
1474
|
+
microphoneStream = null;
|
|
1475
|
+
}
|
|
1476
|
+
const stream = await navigator.mediaDevices.getUserMedia({
|
|
1477
|
+
audio: true,
|
|
1478
|
+
});
|
|
1445
1479
|
setHasUserActivatedListening(true);
|
|
1480
|
+
console.debug('Setting up speech config...');
|
|
1446
1481
|
speechConfig = setupSpeechConfig(AZURE_COGNITIVE_SERVICES_TTS_KEY);
|
|
1482
|
+
console.debug('Creating audio config and recognizer...');
|
|
1447
1483
|
const audioConfig = speechSdk.AudioConfig.fromDefaultMicrophoneInput();
|
|
1448
1484
|
recognizer = new speechSdk.SpeechRecognizer(speechConfig, audioConfig);
|
|
1485
|
+
console.debug('Setting up recognizer handlers...');
|
|
1449
1486
|
setupRecognizerHandlers(recognizer);
|
|
1487
|
+
console.debug('Starting continuous recognition...');
|
|
1488
|
+
await new Promise((resolve, reject) => {
|
|
1489
|
+
recognizer === null || recognizer === void 0 ? void 0 : recognizer.startContinuousRecognitionAsync(resolve, error => {
|
|
1490
|
+
console.error('Failed to start recognition:', error);
|
|
1491
|
+
reject(error);
|
|
1492
|
+
});
|
|
1493
|
+
});
|
|
1494
|
+
console.debug('Speech recognition started successfully');
|
|
1450
1495
|
setListening(true);
|
|
1451
|
-
recognizer.startContinuousRecognitionAsync();
|
|
1452
|
-
recognizer.canceled = (_s, e) => {
|
|
1453
|
-
if (e.reason === speechSdk.CancellationReason.Error) {
|
|
1454
|
-
console.debug(`"CANCELED: ErrorCode=${e.errorCode}`);
|
|
1455
|
-
console.debug(`"CANCELED: ErrorDetails=${e.errorDetails}`);
|
|
1456
|
-
console.debug('CANCELED: Did you set the speech resource key and region values?');
|
|
1457
|
-
stopListening();
|
|
1458
|
-
cleanup();
|
|
1459
|
-
}
|
|
1460
|
-
stopListening();
|
|
1461
|
-
};
|
|
1462
|
-
recognizer.sessionStopped = (_s, _e) => {
|
|
1463
|
-
stopListening();
|
|
1464
|
-
resetTranscript();
|
|
1465
|
-
};
|
|
1466
1496
|
}
|
|
1467
1497
|
catch (error) {
|
|
1468
1498
|
console.error('Error in startListening:', error);
|
|
1469
|
-
|
|
1499
|
+
if (recognizer) {
|
|
1500
|
+
console.debug('Cleaning up recognizer after error...');
|
|
1501
|
+
recognizer.close();
|
|
1502
|
+
recognizer = null;
|
|
1503
|
+
}
|
|
1504
|
+
setListening(false);
|
|
1470
1505
|
throw error;
|
|
1471
1506
|
}
|
|
1472
1507
|
};
|
|
1473
1508
|
const setupSpeechConfig = (AZURE_COGNITIVE_SERVICES_TTS_KEY) => {
|
|
1509
|
+
console.debug('Creating speech config...');
|
|
1474
1510
|
speechConfig = speechSdk.SpeechConfig.fromSubscription(AZURE_COGNITIVE_SERVICES_TTS_KEY, 'westeurope');
|
|
1511
|
+
console.debug('Setting speech recognition language:', userLang);
|
|
1475
1512
|
speechConfig.speechRecognitionLanguage = getCultureCodeByLanguage(userLang);
|
|
1476
1513
|
speechConfig.speechSynthesisLanguage = getCultureCodeByLanguage(userLang);
|
|
1477
1514
|
speechConfig.speechSynthesisVoiceName = getTTSVoice(userLang);
|
|
1478
1515
|
return speechConfig;
|
|
1479
1516
|
};
|
|
1517
|
+
const [isProcessingSTT, setIsProcessingSTT] = (0, react_1.useState)(false);
|
|
1480
1518
|
const setupRecognizerHandlers = (recognizer) => {
|
|
1481
1519
|
if (recognizer) {
|
|
1520
|
+
console.debug('Setting up recognizer event handlers...');
|
|
1482
1521
|
recognizer.recognized = (_, event) => {
|
|
1522
|
+
console.debug('Recognition event received');
|
|
1483
1523
|
handleRecognizedSpeech(event.result.text);
|
|
1484
1524
|
};
|
|
1525
|
+
console.debug('Configuring recognizer properties...');
|
|
1485
1526
|
recognizer.properties.setProperty('SpeechServiceResponse_JsonResult', 'true');
|
|
1486
1527
|
recognizer.properties.setProperty('SpeechServiceConnection_NoiseSuppression', 'true');
|
|
1487
1528
|
recognizer.properties.setProperty('SpeechServiceConnection_SNRThresholdDb', '10.0');
|
|
1488
1529
|
}
|
|
1489
1530
|
};
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
if (!text || text.trim().length === 0) {
|
|
1493
|
-
console.debug('
|
|
1531
|
+
let isProcessingSpeech = false;
|
|
1532
|
+
const processSpeechAndSendMessage = (text) => {
|
|
1533
|
+
if (isProcessingSpeech || !text || text.trim().length === 0) {
|
|
1534
|
+
console.debug('Skipping speech processing: already processing or empty text');
|
|
1494
1535
|
return;
|
|
1495
1536
|
}
|
|
1537
|
+
try {
|
|
1538
|
+
isProcessingSpeech = true;
|
|
1539
|
+
const message = (0, utils_1.stripDuplicates)(text);
|
|
1540
|
+
console.debug('Processing speech message:', message);
|
|
1541
|
+
if (message.length > 0) {
|
|
1542
|
+
setIsProcessingSTT(true);
|
|
1543
|
+
setUserMessage('');
|
|
1544
|
+
console.debug('Sending message:', message);
|
|
1545
|
+
sendMessage(message);
|
|
1546
|
+
resetTranscript();
|
|
1547
|
+
clearListening();
|
|
1548
|
+
}
|
|
1549
|
+
}
|
|
1550
|
+
finally {
|
|
1551
|
+
setTimeout(() => {
|
|
1552
|
+
isProcessingSpeech = false;
|
|
1553
|
+
}, 1000);
|
|
1554
|
+
}
|
|
1555
|
+
};
|
|
1556
|
+
const handleRecognizedSpeech = (text) => {
|
|
1557
|
+
console.debug('Speech recognized:', text);
|
|
1496
1558
|
setTranscript(text);
|
|
1497
1559
|
setIsSpeaking(false);
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
if (message.length > 0) {
|
|
1501
|
-
setUserMessage(message);
|
|
1560
|
+
if (!continuousSpeech) {
|
|
1561
|
+
processSpeechAndSendMessage(text);
|
|
1502
1562
|
}
|
|
1503
1563
|
};
|
|
1504
1564
|
const handleTranscriptProcessing = () => {
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
sendMessage(message);
|
|
1508
|
-
resetTranscript();
|
|
1509
|
-
setUserMessage('');
|
|
1510
|
-
clearListening();
|
|
1565
|
+
if (transcript && transcript.length > 0 && listening) {
|
|
1566
|
+
processSpeechAndSendMessage(transcript);
|
|
1511
1567
|
}
|
|
1512
1568
|
else if (listening) {
|
|
1513
1569
|
resetInteractionTimeout();
|
|
1514
1570
|
}
|
|
1515
1571
|
};
|
|
1516
|
-
const stopListening = () => {
|
|
1572
|
+
const stopListening = async () => {
|
|
1517
1573
|
console.debug('Stopping speech recognition');
|
|
1518
1574
|
if (recognizer) {
|
|
1519
|
-
|
|
1520
|
-
|
|
1575
|
+
try {
|
|
1576
|
+
recognizer.stopContinuousRecognitionAsync();
|
|
1577
|
+
recognizer.close();
|
|
1578
|
+
}
|
|
1579
|
+
catch (error) {
|
|
1580
|
+
console.error('Error stopping recognizer:', error);
|
|
1581
|
+
}
|
|
1521
1582
|
recognizer = null;
|
|
1522
1583
|
}
|
|
1584
|
+
if (microphoneStream) {
|
|
1585
|
+
try {
|
|
1586
|
+
microphoneStream.getTracks().forEach(track => track.stop());
|
|
1587
|
+
}
|
|
1588
|
+
catch (error) {
|
|
1589
|
+
console.error('Error stopping microphone stream:', error);
|
|
1590
|
+
}
|
|
1591
|
+
microphoneStream = null;
|
|
1592
|
+
}
|
|
1523
1593
|
setListening(false);
|
|
1524
1594
|
};
|
|
1525
1595
|
const clearListening = () => {
|
|
@@ -1633,7 +1703,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1633
1703
|
'--memori-nav-bg-image': 'none',
|
|
1634
1704
|
'--memori-nav-bg': `rgba(${integrationConfig.innerBgColor === 'dark'
|
|
1635
1705
|
? '0, 0, 0'
|
|
1636
|
-
: '255, 255, 255'}, ${(
|
|
1706
|
+
: '255, 255, 255'}, ${(_s = integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.innerBgAlpha) !== null && _s !== void 0 ? _s : 0.4})`,
|
|
1637
1707
|
}
|
|
1638
1708
|
: {
|
|
1639
1709
|
'--memori-inner-content-pad': '0px',
|
|
@@ -1730,7 +1800,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1730
1800
|
};
|
|
1731
1801
|
}, [sessionId, userLang, disableTextEnteredEvents]);
|
|
1732
1802
|
const onClickStart = (0, react_1.useCallback)(async (session, initialSessionExpired = false) => {
|
|
1733
|
-
var _a, _b, _c, _d, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r,
|
|
1803
|
+
var _a, _b, _c, _d, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
|
1734
1804
|
const sessionID = (session === null || session === void 0 ? void 0 : session.sessionID) || sessionId;
|
|
1735
1805
|
const dialogState = (session === null || session === void 0 ? void 0 : session.dialogState) || currentDialogState;
|
|
1736
1806
|
setClickedStart(true);
|
|
@@ -1748,6 +1818,12 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1748
1818
|
let birth = birthDate || storageBirthDate || (user === null || user === void 0 ? void 0 : user.birthDate);
|
|
1749
1819
|
if (!birth && autoStart && initialSessionID)
|
|
1750
1820
|
birth = '1970-01-01T10:24:03.845Z';
|
|
1821
|
+
const localPosition = (0, configuration_1.getLocalConfig)('position', undefined);
|
|
1822
|
+
if (autoStart && !localPosition && memori.needsPosition) {
|
|
1823
|
+
console.log('position required', localPosition);
|
|
1824
|
+
setShowPositionDrawer(true);
|
|
1825
|
+
return;
|
|
1826
|
+
}
|
|
1751
1827
|
if (!sessionID && !!minAge && !birth) {
|
|
1752
1828
|
setShowAgeVerification(true);
|
|
1753
1829
|
setClickedStart(false);
|
|
@@ -1954,7 +2030,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1954
2030
|
sessionId: sessionID,
|
|
1955
2031
|
text: initialQuestion,
|
|
1956
2032
|
});
|
|
1957
|
-
translateDialogState((
|
|
2033
|
+
translateDialogState((_s = response.currentState) !== null && _s !== void 0 ? _s : currentState, userLang, undefined, false)
|
|
1958
2034
|
.then(ts => {
|
|
1959
2035
|
let text = ts.translatedEmission || ts.emission;
|
|
1960
2036
|
if (text) {
|
|
@@ -2092,13 +2168,13 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
2092
2168
|
memori,
|
|
2093
2169
|
tenant,
|
|
2094
2170
|
history,
|
|
2095
|
-
showShare: (
|
|
2171
|
+
showShare: (_t = showShare !== null && showShare !== void 0 ? showShare : integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.showShare) !== null && _t !== void 0 ? _t : true,
|
|
2096
2172
|
position,
|
|
2097
2173
|
setShowPositionDrawer,
|
|
2098
2174
|
setShowSettingsDrawer,
|
|
2099
2175
|
setShowKnownFactsDrawer,
|
|
2100
2176
|
setShowExpertsDrawer,
|
|
2101
|
-
enableAudio: (
|
|
2177
|
+
enableAudio: (_u = enableAudio !== null && enableAudio !== void 0 ? enableAudio : integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.enableAudio) !== null && _u !== void 0 ? _u : true,
|
|
2102
2178
|
showSpeaker: !!AZURE_COGNITIVE_SERVICES_TTS_KEY,
|
|
2103
2179
|
speakerMuted: muteSpeaker || speakerMuted,
|
|
2104
2180
|
setSpeakerMuted: mute => {
|
|
@@ -2121,7 +2197,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
2121
2197
|
source.connect(audioContext.destination);
|
|
2122
2198
|
}
|
|
2123
2199
|
},
|
|
2124
|
-
showSettings: (
|
|
2200
|
+
showSettings: (_v = showSettings !== null && showSettings !== void 0 ? showSettings : integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.showSettings) !== null && _v !== void 0 ? _v : true,
|
|
2125
2201
|
hasUserActivatedSpeak,
|
|
2126
2202
|
showReload: selectedLayout === 'TOTEM',
|
|
2127
2203
|
showClear,
|
|
@@ -2179,7 +2255,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
2179
2255
|
tenant,
|
|
2180
2256
|
translateTo: isMultilanguageEnabled &&
|
|
2181
2257
|
userLang.toUpperCase() !==
|
|
2182
|
-
((
|
|
2258
|
+
((_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())
|
|
2183
2259
|
? userLang
|
|
2184
2260
|
: undefined,
|
|
2185
2261
|
baseUrl,
|
|
@@ -2189,7 +2265,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
2189
2265
|
typingText,
|
|
2190
2266
|
showTypingText,
|
|
2191
2267
|
history: showFullHistory ? history : history.slice(-2),
|
|
2192
|
-
authToken: (
|
|
2268
|
+
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,
|
|
2193
2269
|
dialogState: currentDialogState,
|
|
2194
2270
|
setDialogState: setCurrentDialogState,
|
|
2195
2271
|
pushMessage,
|
|
@@ -2295,7 +2371,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
2295
2371
|
setAuthModalState(null);
|
|
2296
2372
|
setGotErrorInOpening(true);
|
|
2297
2373
|
});
|
|
2298
|
-
}, minimumNumberOfRecoveryTokens: (
|
|
2374
|
+
}, minimumNumberOfRecoveryTokens: (_3 = memori === null || memori === void 0 ? void 0 : memori.minimumNumberOfRecoveryTokens) !== null && _3 !== void 0 ? _3 : 1 })), isClient && ((0, jsx_runtime_1.jsx)(AgeVerificationModal_1.default, { visible: showAgeVerification, minAge: minAge, onClose: birthDate => {
|
|
2299
2375
|
var _a, _b, _c, _d;
|
|
2300
2376
|
if (birthDate) {
|
|
2301
2377
|
setBirthDate(birthDate);
|
|
@@ -2323,7 +2399,10 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
2323
2399
|
if (position)
|
|
2324
2400
|
applyPosition(position);
|
|
2325
2401
|
setShowPositionDrawer(false);
|
|
2326
|
-
|
|
2402
|
+
if (autoStart) {
|
|
2403
|
+
onClickStart();
|
|
2404
|
+
}
|
|
2405
|
+
} })), showKnownFactsDrawer && sessionId && ((0, jsx_runtime_1.jsx)(KnownFacts_1.default, { apiClient: client, memori: memori, sessionID: sessionId, visible: showKnownFactsDrawer, closeDrawer: () => setShowKnownFactsDrawer(false) })), showExpertsDrawer && !!experts && ((0, jsx_runtime_1.jsx)(ExpertsDrawer_1.default, { 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) && ((0, jsx_runtime_1.jsx)(LoginDrawer_1.default, { tenant: tenant, apiClient: client, open: !!showLoginDrawer, user: user, loginToken: loginToken, onClose: () => setShowLoginDrawer(false), onLogin: (user, token) => {
|
|
2327
2406
|
setUser(user);
|
|
2328
2407
|
setLoginToken(token);
|
|
2329
2408
|
userToken = token;
|