@eeplatform/core 1.5.1 → 1.6.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 +12 -0
- package/demo-transcription.js +145 -0
- package/dist/index.d.ts +394 -1
- package/dist/index.js +5152 -1709
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5233 -1769
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -1
- package/test-first-phoneme.js +92 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eeplatform/core",
|
|
3
3
|
"license": "MIT",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.6.0",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
"@types/libsodium-wrappers": "^0.7.14",
|
|
20
20
|
"@types/multer": "^1.4.12",
|
|
21
21
|
"@types/node-cron": "^3.0.11",
|
|
22
|
+
"@types/node-fetch": "^2.6.13",
|
|
22
23
|
"@types/nodemailer": "^6.4.15",
|
|
23
24
|
"tsup": "^6.5.0",
|
|
24
25
|
"typescript": "^4.9.4"
|
|
@@ -26,9 +27,13 @@
|
|
|
26
27
|
"dependencies": {
|
|
27
28
|
"@aws-sdk/client-s3": "^3.666.0",
|
|
28
29
|
"@eeplatform/nodejs-utils": "^1.1.0",
|
|
30
|
+
"@google/generative-ai": "^0.24.1",
|
|
31
|
+
"@grpc/grpc-js": "^1.14.0",
|
|
29
32
|
"@octokit/rest": "^22.0.0",
|
|
33
|
+
"@stdlib/datasets-cmudict": "^0.2.2",
|
|
30
34
|
"@types/express-session": "^1.18.2",
|
|
31
35
|
"@types/papaparse": "^5.3.16",
|
|
36
|
+
"assemblyai": "^4.18.0",
|
|
32
37
|
"bcrypt": "^5.1.1",
|
|
33
38
|
"bson": "^6.10.4",
|
|
34
39
|
"dotenv": "^16.4.5",
|
|
@@ -38,6 +43,7 @@
|
|
|
38
43
|
"joi": "^17.13.3",
|
|
39
44
|
"jsonwebtoken": "^9.0.2",
|
|
40
45
|
"libsodium-wrappers": "^0.7.15",
|
|
46
|
+
"metaphone": "^2.0.1",
|
|
41
47
|
"mongodb": "^6.17.0",
|
|
42
48
|
"multer": "^1.4.5-lts.1",
|
|
43
49
|
"node-cron": "^3.0.3",
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
// Test script to demonstrate the updated phoneme checker behavior
|
|
2
|
+
// This script simulates the behavior without actual audio to show the logic
|
|
3
|
+
|
|
4
|
+
const { useGeminiAiService } = require('./dist/index.js');
|
|
5
|
+
|
|
6
|
+
// Mock the Gemini AI response to simulate your example
|
|
7
|
+
const mockAnalysisText = `
|
|
8
|
+
TRANSCRIPTION: d-k
|
|
9
|
+
FIRST_PHONEME: /d/
|
|
10
|
+
PHONEMES_DETECTED: ["/d/", "/k/"]
|
|
11
|
+
TARGET_PHONEME_PRESENT: NO
|
|
12
|
+
MATCH_TYPE: NONE
|
|
13
|
+
POSITION: -1
|
|
14
|
+
CONFIDENCE: 0.85
|
|
15
|
+
CONTEXT: The initial sound is a clear /d/. This is followed by a very brief, sharp, unvoiced velar plosive sound, which is identified as /k/. The target phoneme /k/ is not the first sound produced.
|
|
16
|
+
`;
|
|
17
|
+
|
|
18
|
+
// Simulate the extractValue function behavior
|
|
19
|
+
function extractValue(text, key) {
|
|
20
|
+
const regex = new RegExp(`${key}:\\s*(.+?)(?=\\n|$)`, "i");
|
|
21
|
+
const match = text.match(regex);
|
|
22
|
+
return match ? match[1].trim() : null;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function extractListValue(text, key) {
|
|
26
|
+
const value = extractValue(text, key);
|
|
27
|
+
if (!value) return [];
|
|
28
|
+
return value
|
|
29
|
+
.replace(/[\[\]]/g, "")
|
|
30
|
+
.split(",")
|
|
31
|
+
.map((item) => item.trim())
|
|
32
|
+
.filter((item) => item.length > 0);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function extractNumericValue(text, key) {
|
|
36
|
+
const value = extractValue(text, key);
|
|
37
|
+
if (!value) return null;
|
|
38
|
+
const num = parseFloat(value);
|
|
39
|
+
return isNaN(num) ? null : num;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Parse the mock response
|
|
43
|
+
const transcription = extractValue(mockAnalysisText, "TRANSCRIPTION");
|
|
44
|
+
const firstPhoneme = extractValue(mockAnalysisText, "FIRST_PHONEME");
|
|
45
|
+
const detectedPhonemes = extractListValue(mockAnalysisText, "PHONEMES_DETECTED");
|
|
46
|
+
const isTargetPresent = extractValue(mockAnalysisText, "TARGET_PHONEME_PRESENT")?.toUpperCase() === "YES";
|
|
47
|
+
const matchType = extractValue(mockAnalysisText, "MATCH_TYPE")?.toUpperCase();
|
|
48
|
+
const position = extractNumericValue(mockAnalysisText, "POSITION");
|
|
49
|
+
const confidence = extractNumericValue(mockAnalysisText, "CONFIDENCE");
|
|
50
|
+
const context = extractValue(mockAnalysisText, "CONTEXT");
|
|
51
|
+
|
|
52
|
+
console.log("=== FIRST PHONEME CHECKER TEST ===");
|
|
53
|
+
console.log("Target phoneme: /k/");
|
|
54
|
+
console.log("Transcription:", transcription);
|
|
55
|
+
console.log("First phoneme detected:", firstPhoneme);
|
|
56
|
+
console.log("All detected phonemes:", detectedPhonemes);
|
|
57
|
+
console.log("Is target present as first sound:", isTargetPresent);
|
|
58
|
+
console.log("Match type:", matchType);
|
|
59
|
+
console.log("Position:", position);
|
|
60
|
+
console.log("Confidence:", confidence);
|
|
61
|
+
|
|
62
|
+
// Determine final match result - only consider it a match if target is the first phoneme
|
|
63
|
+
const isMatch = (isTargetPresent && position === 0);
|
|
64
|
+
const exactMatch = (matchType === "EXACT" && position === 0);
|
|
65
|
+
const partialMatch = (matchType === "PARTIAL" && position === 0);
|
|
66
|
+
|
|
67
|
+
console.log("\n=== RESULT ===");
|
|
68
|
+
console.log("Is match (first sound only):", isMatch);
|
|
69
|
+
console.log("Exact match:", exactMatch);
|
|
70
|
+
console.log("Partial match:", partialMatch);
|
|
71
|
+
|
|
72
|
+
const result = {
|
|
73
|
+
transcription,
|
|
74
|
+
targetPhoneme: "/k/",
|
|
75
|
+
isMatch,
|
|
76
|
+
confidence,
|
|
77
|
+
detectedPhonemes,
|
|
78
|
+
matchDetails: {
|
|
79
|
+
exactMatch,
|
|
80
|
+
partialMatch,
|
|
81
|
+
position: isMatch ? position : -1,
|
|
82
|
+
context: `First phoneme detected: ${firstPhoneme}. Target: /k/. Only considering first sound for matching.`,
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
console.log("\n=== FINAL RESULT OBJECT ===");
|
|
87
|
+
console.log(JSON.stringify(result, null, 2));
|
|
88
|
+
|
|
89
|
+
console.log("\n=== COMPARISON WITH YOUR ORIGINAL ===");
|
|
90
|
+
console.log("Original result had isMatch: true (checking all phonemes)");
|
|
91
|
+
console.log("New result has isMatch:", isMatch, "(checking only first phoneme)");
|
|
92
|
+
console.log("This correctly identifies that /k/ is NOT the first sound produced");
|