worked on fixing the code

This commit is contained in:
santa
2025-11-24 16:40:12 +01:00
parent af13907fdc
commit a5a60635fc
4 changed files with 140 additions and 123 deletions
+5 -3
View File
@@ -139,7 +139,7 @@ electron.ipcMain.on("file_submit", async (event, args) => {
let audiopath = ""
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
await mapFunctions.get("module-handler").function(args.video.module, {inputVideoPath: args.video.inputVideoPath, outputType: args.video.outputType}).then(resp => {
console.log(resp);
@@ -164,11 +164,13 @@ electron.ipcMain.on("file_submit", async (event, args) => {
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(transcriptpath).then(resp => {
// await mapFunctions.get("summarize-transcription").function(transcriptpath).then(resp => {
await mapFunctions.get("summarize-transcription").function('/Users/santa/Proj25/video2document/storage/transcripts/IMG_2978.json').then(resp => {
console.log(resp);
transcriptpath = resp
curstep++
+2
View File
@@ -299,6 +299,7 @@
"resolved": "https://registry.npmjs.org/@types/node/-/node-24.9.2.tgz",
"integrity": "sha512-uWN8YqxXxqFMX2RqGOrumsKeti4LlmIMIyV0lgut4jx7KQBcBiW6vkDtIBvHnHIquwNfJhk8v2OtmO8zXWHfPA==",
"license": "MIT",
"peer": true,
"dependencies": {
"undici-types": "~7.16.0"
}
@@ -2534,6 +2535,7 @@
"integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==",
"dev": true,
"license": "Apache-2.0",
"peer": true,
"bin": {
"tsc": "bin/tsc",
"tsserver": "bin/tsserver"
@@ -1,5 +1,3 @@
const fs = require("fs");
const path = require("path");
// Prepare output directory (always storage/transcriptionSummaries under project root)
const outputDir = `${__dirname}/../../../storage/transcriptionSummaries`;
@@ -14,6 +12,7 @@ module.exports = {
type: "summarizer", // value used to differentiate each module to order them in the UI
displayname: "Summarizer", // The displayname used within the UI
async function(args) {
return new Promise(async (resolve, reject) => {
let inputJson = args.json;
//JSON Path
@@ -27,11 +26,15 @@ module.exports = {
}
}
// JSON parsen
if (typeof inputJson === "string") {
if (typeof args === "string") {
try {
inputJson = JSON.parse(inputJson);
await fs.readFile(args, 'utf8', function (err, data) {
if (err) throw err;
inputJson = JSON.parse(data);
});
} catch (e) {
console.log("Invalid JSON in summarize-transcription");
console.log(e)
return { error: "Invalid JSON" };
}
}
@@ -131,8 +134,12 @@ module.exports = {
fs.writeFileSync(txtPath, output.join("\n"), "utf-8");
console.log(`Summary successfully saved:\n- ${jsonPath}\n- ${txtPath}`);
resolve(jsonPath);
} catch (err) {
console.error("Error saving Summary:", err);
reject(err);
}
})
}
}
@@ -79,6 +79,8 @@ function saveTranscript(transcript, sessionId) {
fs.writeFileSync(outputPath, JSON.stringify(transcript, null, 2));
console.log(`Transcript saved: ${outputPath}`);
return outputPath;
}
//---------------------------------------------------Modul---------------------------------------------------
@@ -89,6 +91,7 @@ module.exports = {
displayname: 'AssemblyAI',
async function(audioFileName) {
return new Promise(async (resolve, reject) => {
try {
// audioFileName ist nur "datei.mp3"
const audioPath = audioFileName;
@@ -108,10 +111,13 @@ module.exports = {
const transcript = await pollTranscript(transcriptId);
const sessionId = getSessionId(audioFileName);
saveTranscript(transcript, sessionId);
resolve(saveTranscript(transcript, sessionId));
} catch (error) {
console.error('Transcription error:', error.message);
reject(error);
}
})
}
};