l-min-components 1.7.1316 → 1.7.1317

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "l-min-components",
3
- "version": "1.7.1316",
3
+ "version": "1.7.1317",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "src/assets",
@@ -58,6 +58,7 @@ export { default as useAudioPlayer } from "./useAudioPlayer";
58
58
  export { default as AudioWaveComponent } from "./useAudioPlayer/audioWave";
59
59
  export { default as InputEmoji } from "./InputEmoji";
60
60
  export { default as AIAnalysis } from "./AIAnalysis";
61
+ export { default as AIAnalysisUtils } from "../utils/AIAnalysisUtils";
61
62
  export { default as useAudioRecorder } from "../hooks/recorder-kit";
62
63
  export { default as useCookiePolling } from "../hooks/utils/cookiePolling";
63
64
  export { default as convertBlobToWav } from "../utils/webm2wav";
@@ -0,0 +1,46 @@
1
+ const getResponse = (model) => {
2
+ const referenceText = model?.Reference;
3
+
4
+ if (referenceText) {
5
+ const evalution = Object.values(model["Word Phonetic Evaluation"]);
6
+
7
+ const valueMapped = referenceText?.split(/\s+/)?.map((word, idx) => {
8
+ const evalutionValue = evalution[idx];
9
+ const evalationScore = evalutionValue["Word Score"];
10
+ if (word?.toLowerCase() === evalutionValue["Word"]?.toLowerCase()) {
11
+ return { text: word, highlight: evalationScore <= 45 };
12
+ }
13
+ return { text: word };
14
+ });
15
+ let paragraph = "<p>";
16
+ valueMapped?.forEach((item) => {
17
+ if (item?.highlight) {
18
+ paragraph += `<span>${item?.text}</span> `;
19
+ } else {
20
+ paragraph += `${item?.text} `;
21
+ }
22
+ });
23
+ paragraph = paragraph?.trim() + "</p>";
24
+ return paragraph;
25
+ }
26
+ return "";
27
+ };
28
+ const setupAnalysis = (data, otherValues = {}) => {
29
+ if (data) {
30
+ const options = [];
31
+ if (data?.relevance) {
32
+ options.push({ value: "relevance", label: "Relevance" });
33
+ }
34
+ if (data?.speech_analysis) {
35
+ options.push({ value: "speech", label: "Speech analysis" });
36
+ }
37
+ if (data?.grammar) {
38
+ options.push({ value: "grammar", label: "Grammar" });
39
+ }
40
+
41
+ return { options, data: { ...data, ...otherValues } };
42
+ }
43
+ return null;
44
+ };
45
+
46
+ export { getResponse, setupAnalysis };