// Loading required packages require("./requires.js") console.log(start); // Initialising map to be used to store the functionality later on for reloadability mapFunctions = new Map() // Loading the Function Map var path = `${mainDir}/services/modules` var folders = fs.readdirSync(path).filter(function (file) { return fs.statSync(path+'/'+file).isDirectory(); }); folders.forEach(element => { var commandFiles = fs.readdirSync(`${path}/${element}`).filter(file => file.endsWith('.js') && !file.startsWith("index")); for (const file of commandFiles) { delete require.cache[require.resolve(`${path}/${element}/${file}`)]; const command = require(`${path}/${element}/${file}`); mapFunctions.set(command.name, command); } }); // The startup information for the project, here you can add stuff that might be nice to see when the app starts mapFunctions.get("Startup_function").function() console.log("------------------------------------ Status ------------------------------------"); console.log(__dirname); console.log(platform); console.log(`The Startup took ${new Date() - start}ms`) console.log(`${mapFunctions.size} Function modules loaded`); console.log("--------------------------------------------------------------------------------"); // --------------------------------------------------------- CLI COMMANDS --------------------------------------------------------- // const rl = readline.createInterface({ input: process.stdin, output: process.stdout }); rl.on("line", data =>{ const args = data.trim().split(" "); const command = args.shift().toLowerCase(); mapFunctions.get("cliCommands").function(command, args) }) // ----------------------------------------------------------- ELECTRON ----------------------------------------------------------- // let mainWindow; function createWindow() { mainWindow = new electron.BrowserWindow({ width: 1200, height: 800, webPreferences: { nodeIntegration: false, contextIsolation: true, preload: `${mainDir}/electron/main/preload.js` } }); mainWindow.loadFile('./electron/main/index.html'); } electron.app.whenReady().then(createWindow); // electron.ipcMain.on("extract", (event, args) => { // mapFunctions.get("extraction-video-to-audio").function(args) // }) // setTimeout(() => { // mainWindow.webContents.send("fuck", "worked uwu") // }, 5000); electron.ipcMain.handle('get-module-names', async () => { let module_array = { "ai_modules":[], "transcription_modules":[] } mapFunctions.forEach(e => { switch(e.type){ case "llm": module_array.ai_modules.push({"name": e.name, "displayname": e.displayname}) break; case "transcription": module_array.transcription_modules.push({"name": e.name, "displayname": e.displayname}) break; } }) // console.log(module_array); return module_array }); // electron.ipcMain.on("get_modules", async (event, args) => { // let module_array = { // "ai_modules":[], // "transcription_modules":[] // } // mapFunctions.forEach(e => { // switch(e.type){ // case "llm": // module_array.ai_modules.push({"name": e.name, "displayname": e.displayname}) // break; // case "transcription": // module_array.transcription_modules.push({"name": e.name, "displayname": e.displayname}) // break; // } // }) // console.log(module_array); // mainWindow.webContents.send("modules", module_array) // }) electron.ipcMain.on("file_submit", async (event, args) => { try { globalArgs = args let curstep = 0 let totalsteps = 4 const TEMPLATE_MAP = { "followup-report": "followup_report.txt", "agenda": "agenda.txt", "result-protocol": "result_protocol.txt", "sprint-planning": "sprint_planning_note.txt", "custom": "custom_document.txt" }; const templateFile = TEMPLATE_MAP[args.document.type]; if (!templateFile) { throw new Error("Unknown document type: " + args.document.type); } console.log(args); let audiopath = "" let transcriptpath = "" console.log("\n\n Running the Video to Audio Extractor"); // This code handles the Video to Audio extraction module call await mapFunctions.get("module-handler").function(args.video.module, {inputVideoPath: args.video.inputVideoPath, outputType: mapFunctions.get(args.transcription.module).audioformat}).then(resp => { console.log(resp); audiopath = resp curstep++ mainWindow.webContents.send("progress", {curstep:curstep, totalsteps:totalsteps}) }).catch(err => { mainWindow.webContents.send("error", err) return }) console.log("\n\n Running the Audio to Transcription module"); // TODO implement transcription module // This code handles the Audio to Text transcription module call await mapFunctions.get("module-handler").function(args.transcription.module, audiopath).then(resp => { console.log(resp); transcriptpath = resp curstep++ mainWindow.webContents.send("progress", {curstep:curstep, totalsteps:totalsteps}) }).catch(err => { mainWindow.webContents.send("error", err) return }) console.log("\n\n Running the Transcription Summarizer module"); // This code summarises the transcript, so that it can be used by an llm // await mapFunctions.get("summarize-transcription").function('A:\\programing\\@projects\\video2document\\storage\\transcripts\\IMG_2978.json').then(resp => { await mapFunctions.get("summarize-transcription2").function(transcriptpath).then(resp => { console.log(resp); transcriptpath = resp curstep++ mainWindow.webContents.send("progress", {curstep:curstep, totalsteps:totalsteps}) }).catch(err => { mainWindow.webContents.send("error", err) return }) console.log("\n\n Running the LLM module"); // TODO implement documentation module // This code handles the Text to Document processing module call console.log(`\n\n Running the LLM for Document Style ${args.document.type}`); await mapFunctions.get("module-handler").function(args.document.module, { inputTranscriptPath: transcriptpath, documentTypePath: "./storage/documentType/" + templateFile, language: "en" }).then(resp => { console.log(resp); transcriptpath = resp curstep++ mainWindow.webContents.send("progress", { curstep: curstep, totalsteps: totalsteps }) }).catch(err => { mainWindow.webContents.send("error", err) return }) // TODO actually implement this functionality // Module to get the first few lines for each speaker to send to the frontend // await mapFunctions.get("speaker-getter-idfk").function(transcriptpath).then(resp => { // console.log(resp); // transcriptpath = resp // curstep++ // mainWindow.webContents.send("progress", {curstep:curstep, totalsteps:totalsteps}) // // { // // speakerA: {source: "Pfad zur Audio File"}, // // speakerB:..... // // } mainWindow.webContents.send("speakers", {speakerA:"pfad1", speakerB:"pfad2"}) // }).catch(err => { // mainWindow.webContents.send("error", err) // return // }) } catch (error) { console.log(error); } }) let q = { video: { module: "String", // The name of the module, idk if we ever implement other extraction modules, the default one is extraction-video-to-audio inputVideoPath: "String", // See script.js on line 27 for an example of what this should look like outputType: "String" // The file format to be used for the audio output file, such as wav, mp3, flac and so on }, transcription:{ module: "String" // The module name of the transcription model you want to use }, document:{ module: "String", // The module name of the AI model you want to use to create the document styles: [ // An array of all the document styles/prompts you want to have the document be processed with { prompt: "String", } ] } } let q1 = { "ai_modules": [ {name:"abc", displayname:"ABC"}, {name:"qeg", displayname:"aqghegahu"} ], "transcription_modules": [ {name:"abc", displayname:"ABC"}, {name:"qeg", displayname:"aqghegahu"} ] }