mirror of
https://gitlab.rlp.net/proj-wise2526-video2document/video2document.git
synced 2026-06-15 18:01:52 +02:00
102 lines
3.0 KiB
JavaScript
102 lines
3.0 KiB
JavaScript
import { app, BrowserWindow, ipcMain, dialog } from 'electron';
|
|
import { exec } from 'child_process';
|
|
import path from 'path';
|
|
import { fileURLToPath } from 'url';
|
|
// Import audio events and transcription module
|
|
import { audioEvents } from '../../services/modules/extraction/ffmpegExtractor.js';
|
|
import { transcribe } from '../../services/modules/transcription-remote/assembly.js';
|
|
|
|
const __filename = fileURLToPath(import.meta.url);
|
|
const __dirname = path.dirname(__filename);
|
|
|
|
let mainWindow;
|
|
|
|
function createWindow() {
|
|
mainWindow = new BrowserWindow({
|
|
width: 800,
|
|
height: 600,
|
|
webPreferences: {
|
|
nodeIntegration: false,
|
|
contextIsolation: true,
|
|
preload: path.join(__dirname, 'preload.js')
|
|
}
|
|
});
|
|
|
|
mainWindow.loadFile('main/index.html');
|
|
}
|
|
|
|
// Setup pipeline orchestrator
|
|
function setupOrchestrator() {
|
|
console.log('🎯 [Pipeline] Orchestrator ready. Listening for audio_ready events...');
|
|
|
|
audioEvents.on('audio_ready', async (data) => {
|
|
const { audioPath, sessionId } = data;
|
|
|
|
console.log(`✅ [Pipeline] Audio ready: ${sessionId}`);
|
|
|
|
// AC6: Send status to UI - Audio bereit
|
|
mainWindow.webContents.send('pipeline-status', {
|
|
sessionId,
|
|
status: 'audio_ready',
|
|
message: 'Audio bereit'
|
|
});
|
|
|
|
try {
|
|
// AC4: Status transcription_started
|
|
console.log(`🚀 [Pipeline] Starting transcription: ${sessionId}`);
|
|
mainWindow.webContents.send('pipeline-status', {
|
|
sessionId,
|
|
status: 'transcription_started',
|
|
message: 'Transkription gestartet'
|
|
});
|
|
|
|
// AC2: Auto-start transcription (S2-02b)
|
|
await transcribe(audioPath, sessionId);
|
|
|
|
// AC6: Status transcription_completed
|
|
console.log(`✅ [Pipeline] Transcription completed: ${sessionId}`);
|
|
mainWindow.webContents.send('pipeline-status', {
|
|
sessionId,
|
|
status: 'transcription_completed',
|
|
message: 'Transkription abgeschlossen'
|
|
});
|
|
|
|
} catch (error) {
|
|
// AC5: Error logging + failed_transcription_start
|
|
console.error(`❌ [Pipeline] Transcription failed: ${sessionId}`);
|
|
console.error(` Error:`, error.message);
|
|
|
|
mainWindow.webContents.send('pipeline-status', {
|
|
sessionId,
|
|
status: 'failed_transcription_start',
|
|
message: 'Fehler beim Transkriptionsstart',
|
|
error: error.message
|
|
});
|
|
}
|
|
});
|
|
}
|
|
|
|
app.whenReady().then(() => {
|
|
createWindow();
|
|
setupOrchestrator();
|
|
});
|
|
|
|
// Kommunikation vom Renderer (Frontend)
|
|
ipcMain.handle('convert-video', async (event, filePath) => {
|
|
const output = path.join(path.dirname(filePath), 'converted.mp4');
|
|
|
|
return new Promise((resolve, reject) => {
|
|
exec(`ffmpeg -i "${filePath}" -vcodec libx264 "${output}"`, (error, stdout, stderr) => {
|
|
if (error) {
|
|
console.error('Fehler beim Konvertieren:', error);
|
|
reject(error);
|
|
} else {
|
|
console.log('Konvertierung abgeschlossen:', output);
|
|
resolve(output);
|
|
}
|
|
});
|
|
});
|
|
});
|
|
|
|
|