-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlive-mode.js
More file actions
208 lines (173 loc) Β· 5.93 KB
/
Copy pathlive-mode.js
File metadata and controls
208 lines (173 loc) Β· 5.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
#!/usr/bin/env node
/**
* Otto Assistant Live Mode
* Continuous speech recognition with real-time processing
*/
const LiveModeManager = require('./src/core/live-mode-manager');
async function main() {
console.log("π€ Otto Assistant Live Mode");
console.log("ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ");
// Check system requirements
if (!await checkSystemRequirements()) {
console.error("β System requirements not met. Please install required dependencies.");
process.exit(1);
}
// Create live mode manager with configuration
const liveManager = new LiveModeManager({
autoExport: true,
exportInterval: 300000, // 5 minutes
minSegmentLength: 50,
maxContextAge: 1800000, // 30 minutes
chunkDuration: 2000, // 2 seconds
silenceThreshold: 0.01,
maxSilenceDuration: 3000 // 3 seconds
});
// Handle graceful shutdown
process.on('SIGINT', async () => {
console.log("\nπ Received interrupt signal...");
await liveManager.stopLiveMode();
process.exit(0);
});
process.on('SIGTERM', async () => {
console.log("\nπ Received termination signal...");
await liveManager.stopLiveMode();
process.exit(0);
});
// Handle uncaught errors
process.on('uncaughtException', async (error) => {
console.error("\nπ₯ Uncaught exception:", error);
await liveManager.stopLiveMode();
process.exit(1);
});
process.on('unhandledRejection', async (reason, promise) => {
console.error("\nπ₯ Unhandled rejection at:", promise, 'reason:', reason);
await liveManager.stopLiveMode();
process.exit(1);
});
try {
// Start live mode
await liveManager.startLiveMode();
// Keep process alive
console.log("π€ Live mode is active. Press Ctrl+C to stop.");
// The process will continue running until stopped
process.stdin.setRawMode(true);
process.stdin.resume();
} catch (error) {
console.error("β Failed to start live mode:", error);
process.exit(1);
}
}
/**
* Check system requirements
*/
async function checkSystemRequirements() {
const { spawn } = require('child_process');
console.log("π Checking system requirements...");
// Check for SoX (audio recording)
const soxCheck = await checkCommand('sox', ['--version']);
if (!soxCheck) {
console.error("β SoX not found. Install with: brew install sox (macOS) or apt-get install sox (Linux)");
return false;
}
console.log("β
SoX audio tools available");
// Check for Whisper (speech recognition)
const whisperCheck = await checkCommand('whisper', ['--help']);
if (!whisperCheck) {
console.error("β Whisper not found. Install with: pip install openai-whisper");
return false;
}
console.log("β
OpenAI Whisper available");
// Check Node.js version
const nodeVersion = process.version;
const majorVersion = parseInt(nodeVersion.slice(1).split('.')[0]);
if (majorVersion < 14) {
console.error(`β Node.js ${majorVersion} is too old. Please upgrade to Node.js 14+`);
return false;
}
console.log(`β
Node.js ${nodeVersion} is compatible`);
// Check configuration
try {
const config = require('./config.json');
if (!config.KITEGG_API_KEY) {
console.warn("β οΈ KITEGG_API_KEY not configured. Summary generation may fail.");
}
console.log("β
Configuration loaded");
} catch (e) {
console.warn("β οΈ config.json not found. Using environment variables.");
}
console.log("β
All requirements satisfied");
return true;
}
/**
* Check if a command is available
*/
function checkCommand(command, args = []) {
return new Promise((resolve) => {
const { spawn } = require('child_process');
const process = spawn(command, args, { stdio: 'ignore' });
process.on('close', (code) => {
resolve(code !== 127); // 127 = command not found
});
process.on('error', () => {
resolve(false);
});
// Timeout after 5 seconds
setTimeout(() => {
process.kill();
resolve(false);
}, 5000);
});
}
/**
* Show usage instructions
*/
function showUsage() {
console.log(`
π€ Otto Assistant Live Mode
USAGE:
node live-mode.js
VOICE COMMANDS:
"Stop listening" - Pause audio processing
"Export now" - Trigger immediate export to all platforms
"Export to Miro" - Export only to Miro with optimized layout
"Export to Obsidian" - Export only to Obsidian vault
"Export to Notion" - Export only to Notion
"Neue session" - Clear context and start fresh
"Status" - Get current session status
"Zusammenfassung" - Generate live summary
"Meeting ende" - Complete session and perform final export
KEYBOARD COMMANDS:
q + Enter - Quit live mode
s + Enter - Show detailed status
e + Enter - Export current session
c + Enter - Clear session context
h + Enter - Show help
FEATURES:
β’ Continuous speech recognition (no 25-second limit)
β’ Real-time transcription with low latency
β’ Voice Activity Detection for natural pauses
β’ Context management across conversation
β’ Auto-export every 5 minutes
β’ Optimized Miro layouts for large whiteboards
β’ Visual indicators for system state
β’ Graceful interruption handling
REQUIREMENTS:
β’ SoX audio tools (brew install sox)
β’ OpenAI Whisper (pip install openai-whisper)
β’ Node.js 14+
β’ Configured API keys in config.json
`);
}
// Show usage if --help flag is passed
if (process.argv.includes('--help') || process.argv.includes('-h')) {
showUsage();
process.exit(0);
}
// Run main function
if (require.main === module) {
main().catch(error => {
console.error("π₯ Fatal error:", error);
process.exit(1);
});
}
module.exports = { main, checkSystemRequirements };