mirror of
https://gitlab.rlp.net/proj-wise2526-video2document/video2document.git
synced 2026-06-16 18:31:51 +02:00
worked on fixing the code
This commit is contained in:
@@ -139,7 +139,7 @@ electron.ipcMain.on("file_submit", async (event, 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: args.video.outputType}).then(resp => {
|
await mapFunctions.get("module-handler").function(args.video.module, {inputVideoPath: args.video.inputVideoPath, outputType: args.video.outputType}).then(resp => {
|
||||||
console.log(resp);
|
console.log(resp);
|
||||||
@@ -164,11 +164,13 @@ 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(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);
|
console.log(resp);
|
||||||
transcriptpath = resp
|
transcriptpath = resp
|
||||||
curstep++
|
curstep++
|
||||||
|
|||||||
Generated
+2
@@ -299,6 +299,7 @@
|
|||||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-24.9.2.tgz",
|
"resolved": "https://registry.npmjs.org/@types/node/-/node-24.9.2.tgz",
|
||||||
"integrity": "sha512-uWN8YqxXxqFMX2RqGOrumsKeti4LlmIMIyV0lgut4jx7KQBcBiW6vkDtIBvHnHIquwNfJhk8v2OtmO8zXWHfPA==",
|
"integrity": "sha512-uWN8YqxXxqFMX2RqGOrumsKeti4LlmIMIyV0lgut4jx7KQBcBiW6vkDtIBvHnHIquwNfJhk8v2OtmO8zXWHfPA==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
"peer": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"undici-types": "~7.16.0"
|
"undici-types": "~7.16.0"
|
||||||
}
|
}
|
||||||
@@ -2534,6 +2535,7 @@
|
|||||||
"integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==",
|
"integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
|
"peer": true,
|
||||||
"bin": {
|
"bin": {
|
||||||
"tsc": "bin/tsc",
|
"tsc": "bin/tsc",
|
||||||
"tsserver": "bin/tsserver"
|
"tsserver": "bin/tsserver"
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
const fs = require("fs");
|
|
||||||
const path = require("path");
|
|
||||||
|
|
||||||
// Prepare output directory (always storage/transcriptionSummaries under project root)
|
// Prepare output directory (always storage/transcriptionSummaries under project root)
|
||||||
const outputDir = `${__dirname}/../../../storage/transcriptionSummaries`;
|
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
|
type: "summarizer", // value used to differentiate each module to order them in the UI
|
||||||
displayname: "Summarizer", // The displayname used within the UI
|
displayname: "Summarizer", // The displayname used within the UI
|
||||||
async function(args) {
|
async function(args) {
|
||||||
|
return new Promise(async (resolve, reject) => {
|
||||||
let inputJson = args.json;
|
let inputJson = args.json;
|
||||||
|
|
||||||
//JSON Path
|
//JSON Path
|
||||||
@@ -27,11 +26,15 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// JSON parsen
|
// JSON parsen
|
||||||
if (typeof inputJson === "string") {
|
if (typeof args === "string") {
|
||||||
try {
|
try {
|
||||||
inputJson = JSON.parse(inputJson);
|
await fs.readFile(args, 'utf8', function (err, data) {
|
||||||
|
if (err) throw err;
|
||||||
|
inputJson = JSON.parse(data);
|
||||||
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log("Invalid JSON in summarize-transcription");
|
console.log("Invalid JSON in summarize-transcription");
|
||||||
|
console.log(e)
|
||||||
return { error: "Invalid JSON" };
|
return { error: "Invalid JSON" };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -131,8 +134,12 @@ module.exports = {
|
|||||||
fs.writeFileSync(txtPath, output.join("\n"), "utf-8");
|
fs.writeFileSync(txtPath, output.join("\n"), "utf-8");
|
||||||
|
|
||||||
console.log(`Summary successfully saved:\n- ${jsonPath}\n- ${txtPath}`);
|
console.log(`Summary successfully saved:\n- ${jsonPath}\n- ${txtPath}`);
|
||||||
|
|
||||||
|
resolve(jsonPath);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error("Error saving Summary:", 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));
|
fs.writeFileSync(outputPath, JSON.stringify(transcript, null, 2));
|
||||||
|
|
||||||
console.log(`Transcript saved: ${outputPath}`);
|
console.log(`Transcript saved: ${outputPath}`);
|
||||||
|
|
||||||
|
return outputPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------Modul---------------------------------------------------
|
//---------------------------------------------------Modul---------------------------------------------------
|
||||||
@@ -89,6 +91,7 @@ module.exports = {
|
|||||||
displayname: 'AssemblyAI',
|
displayname: 'AssemblyAI',
|
||||||
|
|
||||||
async function(audioFileName) {
|
async function(audioFileName) {
|
||||||
|
return new Promise(async (resolve, reject) => {
|
||||||
try {
|
try {
|
||||||
// audioFileName ist nur "datei.mp3"
|
// audioFileName ist nur "datei.mp3"
|
||||||
const audioPath = audioFileName;
|
const audioPath = audioFileName;
|
||||||
@@ -108,10 +111,13 @@ module.exports = {
|
|||||||
const transcript = await pollTranscript(transcriptId);
|
const transcript = await pollTranscript(transcriptId);
|
||||||
|
|
||||||
const sessionId = getSessionId(audioFileName);
|
const sessionId = getSessionId(audioFileName);
|
||||||
saveTranscript(transcript, sessionId);
|
|
||||||
|
resolve(saveTranscript(transcript, sessionId));
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Transcription error:', error.message);
|
console.error('Transcription error:', error.message);
|
||||||
|
reject(error);
|
||||||
}
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user