mirror of
https://gitlab.rlp.net/proj-wise2526-video2document/video2document.git
synced 2026-06-15 18:01:52 +02:00
Fixed the Download button in main
This commit is contained in:
@@ -1,12 +1,12 @@
|
|||||||
// Loading required packages
|
// Loading required packages
|
||||||
require("./requires.js")
|
require("./requires.js")
|
||||||
console.log(start);
|
console.log(start);
|
||||||
|
|
||||||
|
|
||||||
// Initialising map to be used to store the functionality later on for reloadability
|
// Initialising map to be used to store the functionality later on for reloadability
|
||||||
mapFunctions = new Map()
|
mapFunctions = new Map()
|
||||||
|
|
||||||
|
|
||||||
// Loading the Function Map
|
// Loading the Function Map
|
||||||
var path = `${mainDir}/services/modules`
|
var path = `${mainDir}/services/modules`
|
||||||
var folders = fs.readdirSync(path).filter(function (file) {
|
var folders = fs.readdirSync(path).filter(function (file) {
|
||||||
@@ -20,9 +20,9 @@ folders.forEach(element => {
|
|||||||
mapFunctions.set(command.name, command);
|
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
|
// 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()
|
mapFunctions.get("Startup_function").function()
|
||||||
console.log("------------------------------------ Status ------------------------------------");
|
console.log("------------------------------------ Status ------------------------------------");
|
||||||
@@ -31,34 +31,34 @@ console.log(platform);
|
|||||||
console.log(`The Startup took ${new Date() - start}ms`)
|
console.log(`The Startup took ${new Date() - start}ms`)
|
||||||
console.log(`${mapFunctions.size} Function modules loaded`);
|
console.log(`${mapFunctions.size} Function modules loaded`);
|
||||||
console.log("--------------------------------------------------------------------------------");
|
console.log("--------------------------------------------------------------------------------");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// --------------------------------------------------------- CLI COMMANDS --------------------------------------------------------- //
|
// --------------------------------------------------------- CLI COMMANDS --------------------------------------------------------- //
|
||||||
|
|
||||||
const rl = readline.createInterface({
|
const rl = readline.createInterface({
|
||||||
input: process.stdin,
|
input: process.stdin,
|
||||||
output: process.stdout
|
output: process.stdout
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
rl.on("line", data =>{
|
rl.on("line", data =>{
|
||||||
const args = data.trim().split(" ");
|
const args = data.trim().split(" ");
|
||||||
const command = args.shift().toLowerCase();
|
const command = args.shift().toLowerCase();
|
||||||
mapFunctions.get("cliCommands").function(command, args)
|
mapFunctions.get("cliCommands").function(command, args)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ----------------------------------------------------------- ELECTRON ----------------------------------------------------------- //
|
// ----------------------------------------------------------- ELECTRON ----------------------------------------------------------- //
|
||||||
|
|
||||||
let mainWindow;
|
let mainWindow;
|
||||||
|
|
||||||
function createWindow() {
|
function createWindow() {
|
||||||
mainWindow = new electron.BrowserWindow({
|
mainWindow = new electron.BrowserWindow({
|
||||||
width: 1200,
|
width: 1200,
|
||||||
@@ -69,21 +69,21 @@ function createWindow() {
|
|||||||
preload: `${mainDir}/electron/main/preload.js`
|
preload: `${mainDir}/electron/main/preload.js`
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
mainWindow.loadFile('./electron/main/index.html');
|
mainWindow.loadFile('./electron/main/index.html');
|
||||||
}
|
}
|
||||||
|
|
||||||
electron.app.whenReady().then(createWindow);
|
electron.app.whenReady().then(createWindow);
|
||||||
|
|
||||||
|
|
||||||
// electron.ipcMain.on("extract", (event, args) => {
|
// electron.ipcMain.on("extract", (event, args) => {
|
||||||
// mapFunctions.get("extraction-video-to-audio").function(args)
|
// mapFunctions.get("extraction-video-to-audio").function(args)
|
||||||
// })
|
// })
|
||||||
|
|
||||||
// setTimeout(() => {
|
// setTimeout(() => {
|
||||||
// mainWindow.webContents.send("fuck", "worked uwu")
|
// mainWindow.webContents.send("fuck", "worked uwu")
|
||||||
// }, 5000);
|
// }, 5000);
|
||||||
|
|
||||||
electron.ipcMain.handle('get-module-names', async () => {
|
electron.ipcMain.handle('get-module-names', async () => {
|
||||||
let module_array = {
|
let module_array = {
|
||||||
"ai_modules":[],
|
"ai_modules":[],
|
||||||
@@ -102,8 +102,8 @@ electron.ipcMain.handle('get-module-names', async () => {
|
|||||||
// console.log(module_array);
|
// console.log(module_array);
|
||||||
return module_array
|
return module_array
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// electron.ipcMain.on("get_modules", async (event, args) => {
|
// electron.ipcMain.on("get_modules", async (event, args) => {
|
||||||
// let module_array = {
|
// let module_array = {
|
||||||
// "ai_modules":[],
|
// "ai_modules":[],
|
||||||
@@ -120,12 +120,13 @@ electron.ipcMain.handle('get-module-names', async () => {
|
|||||||
// }
|
// }
|
||||||
// })
|
// })
|
||||||
// console.log(module_array);
|
// console.log(module_array);
|
||||||
|
|
||||||
// mainWindow.webContents.send("modules", module_array)
|
// mainWindow.webContents.send("modules", module_array)
|
||||||
// })
|
// })
|
||||||
|
|
||||||
|
var globalArgs = {}
|
||||||
|
var globalFinalHtmlPath = ""
|
||||||
|
|
||||||
electron.ipcMain.on("file_submit", async (event, args) => {
|
electron.ipcMain.on("file_submit", async (event, args) => {
|
||||||
try {
|
try {
|
||||||
globalArgs = args
|
globalArgs = args
|
||||||
@@ -145,11 +146,11 @@ electron.ipcMain.on("file_submit", async (event, args) => {
|
|||||||
if (!templateFile) {
|
if (!templateFile) {
|
||||||
throw new Error("Unknown document type: " + args.document.type);
|
throw new Error("Unknown document type: " + args.document.type);
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(args);
|
console.log(args);
|
||||||
let audiopath = ""
|
let audiopath = ""
|
||||||
let transcriptpath = ""
|
let transcriptpath = ""
|
||||||
|
|
||||||
console.log("\n\n Running the Video to Audio Extractor");
|
console.log("\n\n Running the Video to Audio Extractor");
|
||||||
// This code handles the Video to Audio extraction module call
|
// 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 => {
|
await mapFunctions.get("module-handler").function(args.video.module, {inputVideoPath: args.video.inputVideoPath, outputType: mapFunctions.get(args.transcription.module).audioformat}).then(resp => {
|
||||||
@@ -161,8 +162,8 @@ electron.ipcMain.on("file_submit", async (event, args) => {
|
|||||||
mainWindow.webContents.send("error", err)
|
mainWindow.webContents.send("error", err)
|
||||||
return
|
return
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
console.log("\n\n Running the Audio to Transcription module");
|
console.log("\n\n Running the Audio to Transcription module");
|
||||||
// TODO implement transcription module
|
// TODO implement transcription module
|
||||||
// This code handles the Audio to Text transcription module call
|
// This code handles the Audio to Text transcription module call
|
||||||
@@ -175,8 +176,8 @@ electron.ipcMain.on("file_submit", async (event, args) => {
|
|||||||
mainWindow.webContents.send("error", err)
|
mainWindow.webContents.send("error", err)
|
||||||
return
|
return
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
console.log("\n\n Running the Transcription Summarizer module");
|
console.log("\n\n Running the Transcription Summarizer module");
|
||||||
// This code summarises the transcript, so that it can be used by an llm
|
// 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-transcription").function('A:\\programing\\@projects\\video2document\\storage\\transcripts\\IMG_2978.json').then(resp => {
|
||||||
@@ -189,24 +190,24 @@ electron.ipcMain.on("file_submit", async (event, args) => {
|
|||||||
mainWindow.webContents.send("error", err)
|
mainWindow.webContents.send("error", err)
|
||||||
return
|
return
|
||||||
})
|
})
|
||||||
|
|
||||||
console.log("\n\n Running the LLM module");
|
console.log("\n\n Running the LLM module");
|
||||||
// TODO implement documentation module
|
// TODO implement documentation module
|
||||||
// This code handles the Text to Document processing module call
|
// This code handles the Text to Document processing module call
|
||||||
|
|
||||||
console.log(`\n\n Running the LLM for Document Style ${args.document.type}`);
|
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 => {
|
await mapFunctions.get("module-handler").function(args.document.module, { inputTranscriptPath: transcriptpath, documentTypePath: "./storage/documentType/" + templateFile, language: "en" }).then(resp => {
|
||||||
console.log(resp);
|
console.log(resp);
|
||||||
transcriptpath = resp
|
globalFinalHtmlPath = resp
|
||||||
curstep++
|
curstep++
|
||||||
mainWindow.webContents.send("progress", { curstep: curstep, totalsteps: totalsteps })
|
mainWindow.webContents.send("progress", {curstep:curstep, totalsteps:totalsteps})
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
mainWindow.webContents.send("error", err)
|
mainWindow.webContents.send("error", err)
|
||||||
return
|
return
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// TODO actually implement this functionality
|
// TODO actually implement this functionality
|
||||||
// Module to get the first few lines for each speaker to send to the frontend
|
// 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 => {
|
// await mapFunctions.get("speaker-getter-idfk").function(transcriptpath).then(resp => {
|
||||||
@@ -214,7 +215,7 @@ electron.ipcMain.on("file_submit", async (event, args) => {
|
|||||||
// transcriptpath = resp
|
// transcriptpath = resp
|
||||||
// curstep++
|
// curstep++
|
||||||
// mainWindow.webContents.send("progress", {curstep:curstep, totalsteps:totalsteps})
|
// mainWindow.webContents.send("progress", {curstep:curstep, totalsteps:totalsteps})
|
||||||
|
|
||||||
// // {
|
// // {
|
||||||
// // speakerA: {source: "Pfad zur Audio File"},
|
// // speakerA: {source: "Pfad zur Audio File"},
|
||||||
// // speakerB:.....
|
// // speakerB:.....
|
||||||
@@ -224,15 +225,18 @@ electron.ipcMain.on("file_submit", async (event, args) => {
|
|||||||
// mainWindow.webContents.send("error", err)
|
// mainWindow.webContents.send("error", err)
|
||||||
// return
|
// return
|
||||||
// })
|
// })
|
||||||
|
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
electron.ipcMain.on("file_download", async() => {
|
||||||
|
await mapFunctions.get("htmlDocumentConverter").convert({inputPath:globalFinalHtmlPath, format: globalArgs.document.outputType, showDialog: true});
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
let q =
|
let q =
|
||||||
{
|
{
|
||||||
video: {
|
video: {
|
||||||
@@ -252,8 +256,8 @@ let q =
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
let q1 = {
|
let q1 = {
|
||||||
"ai_modules": [
|
"ai_modules": [
|
||||||
{name:"abc", displayname:"ABC"},
|
{name:"abc", displayname:"ABC"},
|
||||||
|
|||||||
Reference in New Issue
Block a user