@eeplatform/core 1.7.2 → 1.7.4

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,7 +1,7 @@
1
1
  {
2
2
  "name": "@eeplatform/core",
3
3
  "license": "MIT",
4
- "version": "1.7.2",
4
+ "version": "1.7.4",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
7
7
  "types": "dist/index.d.ts",
@@ -1,145 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- /**
4
- * Simple demonstration script for Gemini AI Audio Transcription
5
- *
6
- * Usage:
7
- * node demo-transcription.js /path/to/audio/file.wav
8
- *
9
- * Or with options:
10
- * LANGUAGE=English ENABLE_TIMESTAMPS=true node demo-transcription.js /path/to/audio/file.mp3
11
- */
12
-
13
- const { useGeminiAiService } = require("../dist/index.js");
14
- const path = require("path");
15
-
16
- async function demonstrateTranscription() {
17
- // Get command line arguments
18
- const audioFilePath = process.argv[2];
19
-
20
- if (!audioFilePath) {
21
- console.error("Please provide an audio file path");
22
- console.error("Usage: node demo-transcription.js /path/to/audio/file.wav");
23
- process.exit(1);
24
- }
25
-
26
- // Initialize the service
27
- const geminiService = useGeminiAiService();
28
-
29
- try {
30
- console.log("🎵 Gemini AI Audio Transcription Demo");
31
- console.log("=====================================\n");
32
-
33
- // Check if file exists and format is supported
34
- const fs = require("fs");
35
- if (!fs.existsSync(audioFilePath)) {
36
- throw new Error("Audio file not found: " + audioFilePath);
37
- }
38
-
39
- const extension = path.extname(audioFilePath).toLowerCase();
40
- const mimeTypeMap = {
41
- ".wav": "audio/wav",
42
- ".mp3": "audio/mp3",
43
- ".aiff": "audio/aiff",
44
- ".aac": "audio/aac",
45
- ".ogg": "audio/ogg",
46
- ".flac": "audio/flac",
47
- };
48
-
49
- const mimeType = mimeTypeMap[extension];
50
- if (!mimeType || !geminiService.validateAudioFormat(mimeType)) {
51
- console.error("❌ Unsupported audio format:", extension);
52
- console.log(
53
- "Supported formats:",
54
- geminiService.getSupportedAudioFormats()
55
- );
56
- process.exit(1);
57
- }
58
-
59
- console.log("📁 File:", path.basename(audioFilePath));
60
- console.log("🎵 Format:", mimeType);
61
- console.log(
62
- "✅ Format supported:",
63
- geminiService.validateAudioFormat(mimeType)
64
- );
65
- console.log("");
66
-
67
- // Prepare options from environment variables
68
- const options = {
69
- language: process.env.LANGUAGE || undefined,
70
- enableTimestamps: process.env.ENABLE_TIMESTAMPS === "true",
71
- prompt: process.env.CUSTOM_PROMPT || undefined,
72
- };
73
-
74
- console.log("⚙️ Options:");
75
- console.log(" Language:", options.language || "Auto-detect");
76
- console.log(
77
- " Timestamps:",
78
- options.enableTimestamps ? "Enabled" : "Disabled"
79
- );
80
- console.log(" Custom prompt:", options.prompt || "None");
81
- console.log("");
82
-
83
- // Start transcription
84
- console.log("🔄 Starting transcription...");
85
- const startTime = Date.now();
86
-
87
- const result = await geminiService.transcribeAudioFromFile(
88
- audioFilePath,
89
- options
90
- );
91
-
92
- const endTime = Date.now();
93
- const duration = ((endTime - startTime) / 1000).toFixed(2);
94
-
95
- // Display results
96
- console.log("");
97
- console.log("✅ Transcription completed in", duration, "seconds");
98
- console.log("");
99
- console.log("📝 TRANSCRIPTION:");
100
- console.log("==================");
101
- console.log(result.transcription);
102
- console.log("");
103
-
104
- if (result.language) {
105
- console.log("🌐 Language:", result.language);
106
- }
107
-
108
- if (result.timestamps && result.timestamps.length > 0) {
109
- console.log("⏰ Timestamps:");
110
- result.timestamps.forEach((timestamp, index) => {
111
- console.log(
112
- ` ${index + 1}. [${timestamp.start}s - ${timestamp.end}s] ${
113
- timestamp.text
114
- }`
115
- );
116
- });
117
- console.log("");
118
- }
119
-
120
- console.log("🎉 Demo completed successfully!");
121
- } catch (error) {
122
- console.error("");
123
- console.error("❌ Transcription failed:");
124
- console.error(" Error:", error.message);
125
- console.error("");
126
-
127
- if (error.message.includes("API key")) {
128
- console.error(
129
- "💡 Make sure your GEMINI_API_KEY environment variable is set"
130
- );
131
- } else if (error.message.includes("audio format")) {
132
- console.error(
133
- "💡 Supported formats:",
134
- geminiService.getSupportedAudioFormats().join(", ")
135
- );
136
- } else if (error.message.includes("Failed to read")) {
137
- console.error("💡 Check that the file path is correct and accessible");
138
- }
139
-
140
- process.exit(1);
141
- }
142
- }
143
-
144
- // Run the demonstration
145
- demonstrateTranscription();
@@ -1,92 +0,0 @@
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");