mirror of
https://gitlab.rlp.net/proj-wise2526-video2document/video2document.git
synced 2026-06-15 18:01:52 +02:00
made it so that the transcript summary file name is not hardcoded anymore
This commit is contained in:
@@ -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`;
|
||||||
@@ -7,6 +5,16 @@ if (!fs.existsSync(outputDir)) {
|
|||||||
fs.mkdirSync(outputDir, { recursive: true });
|
fs.mkdirSync(outputDir, { recursive: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getSessionId(inputPath) {
|
||||||
|
try {
|
||||||
|
const parsed = new URL(inputPath);
|
||||||
|
const base = path.basename(parsed.pathname);
|
||||||
|
return base.replace(/\.[^.]+$/, '');
|
||||||
|
} catch {
|
||||||
|
return path.basename(inputPath, path.extname(inputPath));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//Speaker, Sentence, Start, End
|
//Speaker, Sentence, Start, End
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
@@ -115,10 +123,13 @@ module.exports = {
|
|||||||
//console.log("\n------------\nMerged Transcription Result:\n", output, "\n------------\n");
|
//console.log("\n------------\nMerged Transcription Result:\n", output, "\n------------\n");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const jsonPath = path.join(outputDir, "transcription_result.json");
|
|
||||||
|
let filename = getSessionId(args);
|
||||||
|
|
||||||
|
const jsonPath = path.join(outputDir, `${filename}-${new Date().getTime()}.json`);
|
||||||
fs.writeFileSync(jsonPath, JSON.stringify(result, null, 2), "utf-8");
|
fs.writeFileSync(jsonPath, JSON.stringify(result, null, 2), "utf-8");
|
||||||
|
|
||||||
const txtPath = path.join(outputDir, "transcription_result.txt");
|
const txtPath = path.join(outputDir, `${filename}-${new Date().getTime()}.txt`);
|
||||||
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}`);
|
||||||
|
|||||||
Reference in New Issue
Block a user