@eeplatform/core 1.5.2 → 1.6.1
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 +562 -241
- package/dist/index.js +10894 -9354
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +11024 -9462
- package/dist/index.mjs.map +1 -1
- package/package.json +8 -2
- package/test-first-phoneme.js +92 -0
package/CHANGELOG.md
CHANGED
|
@@ -0,0 +1,145 @@
|
|
|
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();
|