mirror of
https://gitlab.rlp.net/proj-wise2526-video2document/video2document.git
synced 2026-06-15 18:01:52 +02:00
Compare commits
47 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 84ab93ce77 | |||
| 173ed90642 | |||
| 925eb33eab | |||
| 911cba14fd | |||
| 6813659443 | |||
| a0ed2ab7bd | |||
| 4b72568ad3 | |||
| 76c18fa713 | |||
| 2edc7f8351 | |||
| 6083773f88 | |||
| 4a91f03289 | |||
| 444d408480 | |||
| d9eacafc3a | |||
| ab737f0dc9 | |||
| 79e0c48755 | |||
| 9254ddc57f | |||
| c021272ca4 | |||
| e7e97a7f60 | |||
| 80392874bb | |||
| 94f390f28b | |||
| 73f6fa7524 | |||
| 1a681eb2b8 | |||
| 87e3368a9a | |||
| 6d9c94c685 | |||
| fbd5368223 | |||
| 449255dda1 | |||
| c8cbd4e92a | |||
| 0f54edb0aa | |||
| 54f1f6c135 | |||
| a32e7e5744 | |||
| d9e96316c0 | |||
| da3a8c7d8c | |||
| af794e0245 | |||
| dfe91bb15a | |||
| 92043440fe | |||
| bd8ed1bf81 | |||
| 3a8963b49d | |||
| f4c45f8371 | |||
| 73ad7b0687 | |||
| fb173a4041 | |||
| b70680e950 | |||
| a069452f87 | |||
| fd4d342eeb | |||
| 70221683c3 | |||
| a92e33fa59 | |||
| 0dc2ebe99c | |||
| a0fe1a80e3 |
Binary file not shown.
+5
-1
@@ -964,4 +964,8 @@ app.*.symbols
|
|||||||
!/dev/ci/**/Gemfile.lock
|
!/dev/ci/**/Gemfile.lock
|
||||||
|
|
||||||
#Storage files
|
#Storage files
|
||||||
storage/
|
storage/
|
||||||
|
|
||||||
|
*.mp4
|
||||||
|
*.wav
|
||||||
|
*.flac
|
||||||
|
|||||||
+33
-6
@@ -1,6 +1,33 @@
|
|||||||
build-job:
|
workflow:
|
||||||
script:
|
rules:
|
||||||
- echo "Building the Project.."
|
# Run the pipeline for merge requests or when committing to a branch
|
||||||
test-job:
|
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
|
||||||
script:
|
- if: $CI_COMMIT_BRANCH
|
||||||
- echo "Running Tests.."
|
|
||||||
|
image: python:3.14.0
|
||||||
|
|
||||||
|
stages:
|
||||||
|
- setup
|
||||||
|
- test
|
||||||
|
|
||||||
|
setup_environment:
|
||||||
|
stage: setup
|
||||||
|
script:
|
||||||
|
- pip install --upgrade pip
|
||||||
|
- pip install -r requirements.txt
|
||||||
|
- echo "Dependencies installed successfully."
|
||||||
|
|
||||||
|
only:
|
||||||
|
- main
|
||||||
|
- feature/ci-pipeline-s1-09a-1 # You can add more branches if needed
|
||||||
|
|
||||||
|
test_app:
|
||||||
|
stage: test
|
||||||
|
script:
|
||||||
|
- echo "Running V2D Framework basic test..."
|
||||||
|
- python -m unittest discover || echo "No tests found."
|
||||||
|
|
||||||
|
only:
|
||||||
|
- main
|
||||||
|
- feature/ci-pipeline-s1-09a-1
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
from fastapi import FastAPI
|
||||||
|
|
||||||
|
app = FastAPI()
|
||||||
|
|
||||||
|
@app.get("/health")
|
||||||
|
def health_check():
|
||||||
|
return {"status": "ok"}
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 2.6 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 18 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 35 KiB |
+25
-11
@@ -3,15 +3,23 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>Video Upload Drag and Drop + Button</title>
|
<title id="title">Video to document</title>
|
||||||
<link rel="stylesheet" href="style.css">
|
<link rel="stylesheet" href="style.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<div class="mitte" id="mitte">
|
<div class="mitte" id="mitte">
|
||||||
<h1>Video to document</h1>
|
<div class="flagsBtns" id="flagsBtns">
|
||||||
|
<select name="ai_type" id="ai_type">
|
||||||
|
</select>
|
||||||
|
<select name="language_option" id="language_option">
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<h1 id="h1">Video to document</h1>
|
||||||
|
|
||||||
<div class="upload-container" id="uploadContainer">
|
<div class="upload-container" id="uploadContainer">
|
||||||
<p>Drag and drop video file</p>
|
<p id="p1">Drag and drop video file</p>
|
||||||
<div class="file-name" id="fileName">No video chosen</div>
|
<div class="file-name" id="fileName">No video chosen</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -19,22 +27,28 @@
|
|||||||
<input type="file" id="videoUpload" accept="video/*">
|
<input type="file" id="videoUpload" accept="video/*">
|
||||||
|
|
||||||
<div class="checkbox-group">
|
<div class="checkbox-group">
|
||||||
<label for="checkbox-group">Choose prefered document style:</label>
|
<label id="checkbox_group" for="checkbox-group">Choose prefered document style:</label>
|
||||||
<div class="checkbox-container">
|
<div class="checkbox-container">
|
||||||
<input type="checkbox" id="docFormat">
|
<input type="checkbox" name ="docFormat" id="docFormat">
|
||||||
<label for "docFormat">Meeting report</label>
|
<label id="label_format" for="docFormat">Meeting report</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="checkbox-container">
|
<div class="checkbox-container">
|
||||||
<input type="checkbox" id="docFormatCustom">
|
<input type="checkbox" name="docFormat" id="docFormatSummary">
|
||||||
<label for "docFormatCustom">Summary with timestamps</label>
|
<label id="label_summary" for="docFormatSummary">Summary with timestamps</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button class="submit-btn" id="submitButton">Submit Video</button>
|
<button class="submit-btn" id="submitButton" onclick="checkBoxes()">Submit</button>
|
||||||
|
|
||||||
|
<div class="progressbar">
|
||||||
|
<div class="progress_fill"></div>
|
||||||
|
<span class="progress_text">0%</span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="script.js"></script>
|
<script src="languages.js"></script>
|
||||||
<script src="./renderer.js"></script>
|
<script src="script.js"></script>
|
||||||
|
<script src="./renderer.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
var languageOptions = {
|
||||||
|
"eng":{
|
||||||
|
"title": "Video to document",
|
||||||
|
"h1": "Video to document",
|
||||||
|
"p1": "Drag and drop video file",
|
||||||
|
"fileName": "No video chosen",
|
||||||
|
"manualUploadBtn": "Search video",
|
||||||
|
"checkbox_group": "Choose prefered document style:",
|
||||||
|
"label_format": "Meeting report",
|
||||||
|
"label_summary": "Summary with timestamps",
|
||||||
|
"submitButton": "Submit"
|
||||||
|
},
|
||||||
|
"de":{
|
||||||
|
"title": "Video zu Dokument",
|
||||||
|
"h1": "Video zu Dokument",
|
||||||
|
"p1": "Video per Drag & Drop ablegen",
|
||||||
|
"fileName": "Kein Video ausgewaehlt",
|
||||||
|
"manualUploadBtn": "Video suchen",
|
||||||
|
"checkbox_group": "Bevorzugte Dokumentvarianten:",
|
||||||
|
"label_format": "Meeting Bericht",
|
||||||
|
"label_summary": "Zusammenfassung mit Zeitstempeln",
|
||||||
|
"submitButton": "Absenden"
|
||||||
|
},
|
||||||
|
"in":{
|
||||||
|
"title": "दस्तावेज़ के लिए वीडियो",
|
||||||
|
"h1": "दस्तावेज़ के लिए वीडियो",
|
||||||
|
"p1": "वीडियो फ़ाइल खींचें और छोड़ें",
|
||||||
|
"fileName": "कोई वीडियो नहीं चुना गया",
|
||||||
|
"manualUploadBtn": "वीडियो खोजें",
|
||||||
|
"checkbox_group": "पसंदीदा दस्तावेज़ शैली चुनें:",
|
||||||
|
"label_format": "बैठक रिपोर्ट",
|
||||||
|
"label_summary": "टाइमस्टैम्प के साथ सारांश",
|
||||||
|
"submitButton": "जमा करना"
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
+58
-1
@@ -2,6 +2,9 @@ import { app, BrowserWindow, ipcMain, dialog } from 'electron';
|
|||||||
import { exec } from 'child_process';
|
import { exec } from 'child_process';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { fileURLToPath } from 'url';
|
import { fileURLToPath } from 'url';
|
||||||
|
// Import audio events and transcription module
|
||||||
|
import { audioEvents } from '../../services/modules/extraction/ffmpegExtractor.js';
|
||||||
|
import { transcribe } from '../../services/modules/transcription-remote/assembly.js';
|
||||||
|
|
||||||
const __filename = fileURLToPath(import.meta.url);
|
const __filename = fileURLToPath(import.meta.url);
|
||||||
const __dirname = path.dirname(__filename);
|
const __dirname = path.dirname(__filename);
|
||||||
@@ -22,7 +25,61 @@ function createWindow() {
|
|||||||
mainWindow.loadFile('main/index.html');
|
mainWindow.loadFile('main/index.html');
|
||||||
}
|
}
|
||||||
|
|
||||||
app.whenReady().then(createWindow);
|
// Setup pipeline orchestrator
|
||||||
|
function setupOrchestrator() {
|
||||||
|
console.log('🎯 [Pipeline] Orchestrator ready. Listening for audio_ready events...');
|
||||||
|
|
||||||
|
audioEvents.on('audio_ready', async (data) => {
|
||||||
|
const { audioPath, sessionId } = data;
|
||||||
|
|
||||||
|
console.log(`✅ [Pipeline] Audio ready: ${sessionId}`);
|
||||||
|
|
||||||
|
// AC6: Send status to UI - Audio bereit
|
||||||
|
mainWindow.webContents.send('pipeline-status', {
|
||||||
|
sessionId,
|
||||||
|
status: 'audio_ready',
|
||||||
|
message: 'Audio bereit'
|
||||||
|
});
|
||||||
|
|
||||||
|
try {
|
||||||
|
// AC4: Status transcription_started
|
||||||
|
console.log(`🚀 [Pipeline] Starting transcription: ${sessionId}`);
|
||||||
|
mainWindow.webContents.send('pipeline-status', {
|
||||||
|
sessionId,
|
||||||
|
status: 'transcription_started',
|
||||||
|
message: 'Transkription gestartet'
|
||||||
|
});
|
||||||
|
|
||||||
|
// AC2: Auto-start transcription (S2-02b)
|
||||||
|
await transcribe(audioPath, sessionId);
|
||||||
|
|
||||||
|
// AC6: Status transcription_completed
|
||||||
|
console.log(`✅ [Pipeline] Transcription completed: ${sessionId}`);
|
||||||
|
mainWindow.webContents.send('pipeline-status', {
|
||||||
|
sessionId,
|
||||||
|
status: 'transcription_completed',
|
||||||
|
message: 'Transkription abgeschlossen'
|
||||||
|
});
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
// AC5: Error logging + failed_transcription_start
|
||||||
|
console.error(`❌ [Pipeline] Transcription failed: ${sessionId}`);
|
||||||
|
console.error(` Error:`, error.message);
|
||||||
|
|
||||||
|
mainWindow.webContents.send('pipeline-status', {
|
||||||
|
sessionId,
|
||||||
|
status: 'failed_transcription_start',
|
||||||
|
message: 'Fehler beim Transkriptionsstart',
|
||||||
|
error: error.message
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
app.whenReady().then(() => {
|
||||||
|
createWindow();
|
||||||
|
setupOrchestrator();
|
||||||
|
});
|
||||||
|
|
||||||
// Kommunikation vom Renderer (Frontend)
|
// Kommunikation vom Renderer (Frontend)
|
||||||
ipcMain.handle('convert-video', async (event, filePath) => {
|
ipcMain.handle('convert-video', async (event, filePath) => {
|
||||||
|
|||||||
@@ -1,7 +1,15 @@
|
|||||||
|
|
||||||
|
|
||||||
const { contextBridge, ipcRenderer, webUtils } = require('electron')
|
const { contextBridge, ipcRenderer, webUtils } = require('electron')
|
||||||
|
|
||||||
contextBridge.exposeInMainWorld("explorer", {
|
try {
|
||||||
onFileDrop: (file) => webUtils.getPathForFile(file)
|
contextBridge.exposeInMainWorld("explorer", {
|
||||||
})
|
onFileDrop: (file) => webUtils.getPathForFile(file)
|
||||||
|
})
|
||||||
|
contextBridge.exposeInMainWorld("extractor", {
|
||||||
|
extract: (file) => ipcRenderer.send("extract", file)
|
||||||
|
})
|
||||||
|
contextBridge.exposeInMainWorld("electronAPI", {
|
||||||
|
getFilePath: (file) => {return webUtils.getPathForFile(file)}
|
||||||
|
})
|
||||||
|
} catch (error) {
|
||||||
|
console.log("Error in preload.js");
|
||||||
|
}
|
||||||
+38
-19
@@ -1,22 +1,41 @@
|
|||||||
|
|
||||||
const dropzone = document.getElementById("uploadContainer");
|
uploadContainer.addEventListener("dragover", (e) =>{
|
||||||
|
try {
|
||||||
dropzone.addEventListener("dragover", (e) =>{
|
e.stopPropagation();
|
||||||
e.stopPropagation();
|
e.preventDefault();
|
||||||
e.preventDefault();
|
} catch (error) {
|
||||||
});
|
console.log("Error in renderer.js dragover listener function")
|
||||||
|
|
||||||
dropzone.addEventListener("drop", (e) => {
|
|
||||||
e.stopPropagation()
|
|
||||||
e.preventDefault()
|
|
||||||
const files = e.dataTransfer.files
|
|
||||||
const filePath = window.explorer.onFileDrop(files[0])
|
|
||||||
var holdy = filePath + "";
|
|
||||||
if(holdy.endsWith(".mp4")){
|
|
||||||
console.log(filePath)
|
|
||||||
|
|
||||||
const files1 = e.dataTransfer.files;
|
|
||||||
handleFiles(files1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
})
|
});
|
||||||
|
|
||||||
|
//listener for when a file get dropped on the drag&drop field
|
||||||
|
uploadContainer.addEventListener("drop", (e) => {
|
||||||
|
try {
|
||||||
|
e.stopPropagation()
|
||||||
|
e.preventDefault()
|
||||||
|
const files = e.dataTransfer.files
|
||||||
|
const filePath = window.explorer.onFileDrop(files[0])
|
||||||
|
var holdy = filePath + "";
|
||||||
|
if(holdy.endsWith(".mp4") || holdy.endsWith(".mov") || holdy.endsWith(".avi") || holdy.endsWith( ".mkv")){
|
||||||
|
console.log(filePath)
|
||||||
|
|
||||||
|
const files1 = e.dataTransfer.files;
|
||||||
|
handleFiles(files1);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log("Error in renderer.js with the listerner for the drop function");
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
window.addEventListener('load', (e) => {
|
||||||
|
console.log("test");
|
||||||
|
loadLanguageOptions();
|
||||||
|
});
|
||||||
|
|
||||||
|
language_option.addEventListener('change', (e)=>{
|
||||||
|
const select = document.getElementById('language_option');
|
||||||
|
console.log(select.value);
|
||||||
|
changeLanguage(select.value);
|
||||||
|
});
|
||||||
|
|||||||
+125
-24
@@ -1,31 +1,132 @@
|
|||||||
const uploadContainer = document.getElementById('uploadContainer');
|
//listener for the file explorer search
|
||||||
const fileInput = document.getElementById('videoUpload');
|
manualUploadBtn.addEventListener('click', () => {
|
||||||
const fileName = document.getElementById('fileName');
|
try {
|
||||||
const manualBtn = document.getElementById('manualUploadBtn');
|
videoUpload.click();
|
||||||
const videoPreview = document.getElementById('videoPreview');
|
} catch (error) {
|
||||||
|
console.log("Error in manualBtn EventListener click");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
manualBtn.addEventListener('click', () => {
|
|
||||||
fileInput.click();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//function to check if one checkbox is at least klicked
|
||||||
|
function checkBoxes() {
|
||||||
|
try {
|
||||||
|
const checkboxes = document.querySelectorAll('input[name="docFormat"]');
|
||||||
|
let isChecked = false;
|
||||||
|
|
||||||
fileInput.addEventListener('change', () => {
|
checkboxes.forEach(function(checkbox){
|
||||||
handleFiles(fileInput.files);
|
if(checkbox.checked){
|
||||||
});
|
isChecked = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if(isChecked){
|
||||||
|
//Code to submit the video
|
||||||
|
var pathTest = window.electronAPI.getFilePath(videoUpload.files[0]);
|
||||||
function handleFiles(files) {
|
if(pathTest.endsWith(".mp4") || holdy.endsWith(".mov") || holdy.endsWith(".avi") || holdy.endsWith( ".mkv")){
|
||||||
if (files.length > 0) {
|
window.extractor.extract({inputVideoPath: pathTest, outputType:"wav"})
|
||||||
const file = files[0];
|
}
|
||||||
if (file.type.startsWith('video/')) {
|
} else {
|
||||||
fileInput.files = files;
|
//language only english at the moment
|
||||||
fileName.textContent = `Chosen video: ${file.name}`;
|
alert('Please select at least one document type.');
|
||||||
}
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error)
|
||||||
|
}
|
||||||
|
|
||||||
|
// mapFunctions.get("extraction-video-to-audio").function({inputVideoPath:"./a.mp4", outputType:"wav"})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//language changing feature
|
||||||
|
function changeLanguage(language) {
|
||||||
|
try {
|
||||||
|
document.getElementById('title').textContent = languageOptions[language].title;
|
||||||
|
document.getElementById('h1').textContent = languageOptions[language].h1;
|
||||||
|
document.getElementById('p1').textContent = languageOptions[language].p1;
|
||||||
|
document.getElementById('fileName').textContent = languageOptions[language].fileName;
|
||||||
|
document.getElementById('manualUploadBtn').textContent = languageOptions[language].manualUploadBtn;
|
||||||
|
document.getElementById('checkbox_group').textContent = languageOptions[language].checkbox_group;
|
||||||
|
document.getElementById('label_format').textContent = languageOptions[language].label_format;
|
||||||
|
document.getElementById('label_summary').textContent = languageOptions[language].label_summary;
|
||||||
|
document.getElementById('submitButton').textContent = languageOptions[language].submitButton;
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//listener for the file explorer search when something got selected
|
||||||
|
videoUpload.addEventListener('change', () => {
|
||||||
|
try {
|
||||||
|
handleFiles(videoUpload.files);
|
||||||
|
} catch (error) {
|
||||||
|
console.log("Error in manualBtn EventListener change");
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
//function to display the file path in the drop down box
|
||||||
|
function handleFiles(files) {
|
||||||
|
try {
|
||||||
|
if (files.length > 0) {
|
||||||
|
const file = files[0];
|
||||||
|
if (file.type.startsWith('video/')) {
|
||||||
|
videoUpload.files = files;
|
||||||
|
fileName.textContent = `Chosen video: ${file.name}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log("Error in script.js handleFiles function");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//function to regulate the progress on the progressbar
|
||||||
|
function updateProgressBar(bar, value){
|
||||||
|
try {
|
||||||
|
value = Math.round(value);
|
||||||
|
bar.querySelector(".progress_fill").style.width = `${value}%`;
|
||||||
|
bar.querySelector(".progress_text").textContent = `${value}%`;
|
||||||
|
} catch (error) {
|
||||||
|
console.log("Error in scripts.js updateProgressBar function");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//function to load ai options to the drop down list
|
||||||
|
function loadAiOptions(options){
|
||||||
|
try {
|
||||||
|
var menu = document.getElementById('ai_type');
|
||||||
|
for(i = 0; i < options.length; i++){
|
||||||
|
var opty = options[i];
|
||||||
|
var namey = "option" + i;
|
||||||
|
var choice = document.createElement(namey);
|
||||||
|
choice.textContent = "t";
|
||||||
|
choice.value = i;
|
||||||
|
menu.appendChild(choice);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log("Error in script.js loadAiOptions function");
|
||||||
|
console.log(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//function to load language options to the drop down list
|
||||||
|
function loadLanguageOptions(){
|
||||||
|
try {
|
||||||
|
var menu = document.getElementById('language_option');
|
||||||
|
var object_holdy;
|
||||||
|
var choice ;
|
||||||
|
object_holdy = Object.keys(languageOptions);
|
||||||
|
for(i = 0; i < object_holdy.length; i++){
|
||||||
|
choice = document.createElement('option');
|
||||||
|
choice.textContent = object_holdy[i];
|
||||||
|
choice.value = object_holdy[i];
|
||||||
|
menu.appendChild(choice);
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.log("Error in script.js loadLanguageOptions function");
|
||||||
|
console.log(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
+40
-3
@@ -5,7 +5,7 @@ body {
|
|||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
height: 100vh;
|
height: 100vh;
|
||||||
background-color: #444;
|
background-color: #555;
|
||||||
gap: 15px;
|
gap: 15px;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
@@ -75,6 +75,7 @@ gap: 5px;
|
|||||||
|
|
||||||
.checkbox-group {
|
.checkbox-group {
|
||||||
margin-top: 15px;
|
margin-top: 15px;
|
||||||
|
margin-bottom: 15px;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 10px;
|
gap: 10px;
|
||||||
@@ -92,14 +93,14 @@ gap: 5px;
|
|||||||
}
|
}
|
||||||
|
|
||||||
.mitte {
|
.mitte {
|
||||||
background-color: #eaf0ff;
|
background-color: #f2f3f4;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
padding: 5% 50px;
|
padding: 5% 50px;
|
||||||
margin-top: 20px;
|
margin-top: 20px;
|
||||||
gap: 10px;
|
gap: 10px;
|
||||||
border: 2px;
|
border: 1px;
|
||||||
border-color: black;
|
border-color: black;
|
||||||
border-style: solid;
|
border-style: solid;
|
||||||
}
|
}
|
||||||
@@ -108,3 +109,39 @@ h1 {
|
|||||||
align-content: center;
|
align-content: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.progressbar{
|
||||||
|
position: relative;
|
||||||
|
width: 210px;
|
||||||
|
height: 30px;
|
||||||
|
background: rgb(42, 46, 78);
|
||||||
|
border-radius: 5px;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.progress_fill{
|
||||||
|
width: 0%;
|
||||||
|
height: 100%;
|
||||||
|
background: green;
|
||||||
|
transition: all 0.2s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.progress_text{
|
||||||
|
position: absolute;
|
||||||
|
top: 50%;
|
||||||
|
right: 5px;
|
||||||
|
transform: translateY(-50%);
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.flagsBtns {
|
||||||
|
display: flex;
|
||||||
|
justify-content: flex-end;
|
||||||
|
}
|
||||||
|
|
||||||
|
.de_Btn, .eng_Btn, .in_Btn {
|
||||||
|
padding: 8px 16px;
|
||||||
|
color: white;
|
||||||
|
border: none;
|
||||||
|
border-radius: 8px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
@@ -33,6 +33,73 @@ console.log(`${mapFunctions.size} Function modules loaded`);
|
|||||||
console.log("--------------------------------------------------------------------------------");
|
console.log("--------------------------------------------------------------------------------");
|
||||||
|
|
||||||
|
|
||||||
|
// ======================== S3-06 : PIPELINE ORCHESTRATOR ========================
|
||||||
|
// Get audioEvents from ffmpegExtractor module
|
||||||
|
const ffmpegExtractor = mapFunctions.get("extraction-video-to-audio");
|
||||||
|
const audioEvents = ffmpegExtractor.audioEvents;
|
||||||
|
|
||||||
|
console.log('🎯 [S3-06] Pipeline Orchestrator ready. Listening for audio_ready events...');
|
||||||
|
|
||||||
|
audioEvents.on('audio_ready', async (data) => {
|
||||||
|
const { audioPath, sessionId } = data;
|
||||||
|
|
||||||
|
console.log(`✅ [Pipeline] Audio ready: ${sessionId}`);
|
||||||
|
console.log(`📁 Audio path: ${audioPath}`);
|
||||||
|
|
||||||
|
// Send status to UI
|
||||||
|
if (mainWindow) {
|
||||||
|
mainWindow.webContents.send('pipeline-status', {
|
||||||
|
sessionId,
|
||||||
|
status: 'audio_ready',
|
||||||
|
message: 'Audio bereit'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
console.log(`🚀 [Pipeline] Starting transcription: ${sessionId}`);
|
||||||
|
|
||||||
|
if (mainWindow) {
|
||||||
|
mainWindow.webContents.send('pipeline-status', {
|
||||||
|
sessionId,
|
||||||
|
status: 'transcription_started',
|
||||||
|
message: 'Transkription gestartet'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get transcription module
|
||||||
|
const assemblyModule = mapFunctions.get("assembly");
|
||||||
|
|
||||||
|
if (assemblyModule && assemblyModule.run) {
|
||||||
|
await assemblyModule.run(audioPath);
|
||||||
|
} else {
|
||||||
|
console.warn('⚠️ Assembly module not found or missing run function');
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(`✅ [Pipeline] Transcription completed: ${sessionId}`);
|
||||||
|
|
||||||
|
if (mainWindow) {
|
||||||
|
mainWindow.webContents.send('pipeline-status', {
|
||||||
|
sessionId,
|
||||||
|
status: 'transcription_completed',
|
||||||
|
message: 'Transkription abgeschlossen'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.error(`❌ [Pipeline] Transcription failed: ${sessionId}`);
|
||||||
|
console.error(` Error:`, error.message);
|
||||||
|
|
||||||
|
if (mainWindow) {
|
||||||
|
mainWindow.webContents.send('pipeline-status', {
|
||||||
|
sessionId,
|
||||||
|
status: 'failed_transcription_start',
|
||||||
|
message: 'Fehler beim Transkriptionsstart',
|
||||||
|
error: error.message
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// ===============================================================================
|
||||||
|
|
||||||
|
|
||||||
// --------------------------------------------------------- CLI COMMANDS --------------------------------------------------------- //
|
// --------------------------------------------------------- CLI COMMANDS --------------------------------------------------------- //
|
||||||
@@ -55,4 +122,25 @@ rl.on("line", data =>{
|
|||||||
|
|
||||||
// ----------------------------------------------------------- ELECTRON ----------------------------------------------------------- //
|
// ----------------------------------------------------------- ELECTRON ----------------------------------------------------------- //
|
||||||
|
|
||||||
// TODO - Add Electron support to the project
|
let mainWindow;
|
||||||
|
|
||||||
|
function createWindow() {
|
||||||
|
mainWindow = new electron.BrowserWindow({
|
||||||
|
width: 800,
|
||||||
|
height: 600,
|
||||||
|
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)
|
||||||
|
})
|
||||||
Generated
+1507
-5
File diff suppressed because it is too large
Load Diff
+7
-5
@@ -1,10 +1,13 @@
|
|||||||
{
|
{
|
||||||
"type": "module",
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@types/axios": "^0.9.36",
|
||||||
|
"axios": "^1.13.2",
|
||||||
"cli-progress": "^3.12.0",
|
"cli-progress": "^3.12.0",
|
||||||
|
"dotenv": "^17.2.3",
|
||||||
|
"electron": "^39.1.1",
|
||||||
|
"express": "^5.1.0",
|
||||||
"ffmpeg-static": "^5.2.0",
|
"ffmpeg-static": "^5.2.0",
|
||||||
"fluent-ffmpeg": "^2.1.3",
|
"fluent-ffmpeg": "^2.1.3"
|
||||||
"express": "^5.1.0"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/cli-progress": "^3.11.6",
|
"@types/cli-progress": "^3.11.6",
|
||||||
@@ -22,6 +25,7 @@
|
|||||||
"test": "tests"
|
"test": "tests"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
"start": "electron main.js",
|
||||||
"test": "echo \"Error: no test specified\" && exit 1"
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
@@ -31,5 +35,3 @@
|
|||||||
"author": "",
|
"author": "",
|
||||||
"license": "ISC"
|
"license": "ISC"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fastapi
|
||||||
|
uvicorn
|
||||||
|
pytest
|
||||||
@@ -8,3 +8,11 @@ fs = require("fs")
|
|||||||
readline = require("readline")
|
readline = require("readline")
|
||||||
config = require("./config/config")
|
config = require("./config/config")
|
||||||
|
|
||||||
|
ffmpegPath = require('ffmpeg-static');
|
||||||
|
ffmpeg = require('fluent-ffmpeg');
|
||||||
|
path = require('path');
|
||||||
|
cliProgress = require('cli-progress');
|
||||||
|
|
||||||
|
// { app, BrowserWindow, ipcMain, dialog } = require('electron');
|
||||||
|
|
||||||
|
electron = require('electron');
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
npx ts-node ./extract.ts /Users/mikehughes/Downloads/Testvideo/Kurzgesagt.mov
|
|
||||||
npx ts-node ./transcribe.ts ../storage/audio/Kurzgesagt.wav
|
|
||||||
|
|
||||||
npx ts-node ./extract.ts /Users/mikehughes/Downloads/Testvideo/GitLabMeeting.mov
|
|
||||||
npx ts-node ./transcribe.ts ../storage/audio/GitLabMeeting.wav
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
#!/usr/bin/env ts-node
|
|
||||||
|
|
||||||
import { extractAudioFromVideo } from "../services/modules/extraction/ffmpegExtractor.ts";
|
|
||||||
|
|
||||||
const videoPath = process.argv[2];
|
|
||||||
|
|
||||||
if (!videoPath) {
|
|
||||||
console.error("Usage: ts-node extractAudio.ts <videoPath>");
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
(async () => {
|
|
||||||
try {
|
|
||||||
console.log(`Extracting audio from: ${videoPath}`);
|
|
||||||
|
|
||||||
await extractAudioFromVideo(videoPath); // Call the extraction function (ffmpegExtractor.ts in services/modules/extraction)
|
|
||||||
|
|
||||||
console.log("Audio extraction completed successfully.");
|
|
||||||
} catch (err) {
|
|
||||||
console.error("Audio extraction failed:", err);
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
})();
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
import { whisperLocal } from "../services/modules/transcription/local/whisperLocal.ts";
|
|
||||||
|
|
||||||
const audioPath = process.argv[2];
|
|
||||||
if (!audioPath) {
|
|
||||||
console.error("Please provide an audio file path as argument.");
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
const whisper = new whisperLocal();
|
|
||||||
|
|
||||||
(async () => {
|
|
||||||
try {
|
|
||||||
const text = await whisper.transcribe(audioPath);
|
|
||||||
console.log(text);
|
|
||||||
} catch (err) {
|
|
||||||
console.error("Transcription failed:", err);
|
|
||||||
}
|
|
||||||
})();
|
|
||||||
@@ -0,0 +1,101 @@
|
|||||||
|
const EventEmitter = require('events');
|
||||||
|
const audioEvents = new EventEmitter();
|
||||||
|
|
||||||
|
// Ensure ffmpeg binary is available
|
||||||
|
if (!ffmpegPath) {
|
||||||
|
throw new Error('FFmpeg binary not found!');
|
||||||
|
}
|
||||||
|
ffmpeg.setFfmpegPath(ffmpegPath);
|
||||||
|
|
||||||
|
// Prepare output directory (always storage/audio under project root)
|
||||||
|
const outputDir = `${__dirname}/../../../storage/audio`;
|
||||||
|
if (!fs.existsSync(outputDir)) {
|
||||||
|
fs.mkdirSync(outputDir, { recursive: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name:"extraction-video-to-audio", // Unique name for our function that will later be used to get the function from the map via "mapFunctions.get("example").function()"
|
||||||
|
type:"extractor", // value used to differentiate each module to order them in the UI
|
||||||
|
displayname:"Default extractor", // The displayname used within the UI
|
||||||
|
async function(parameter){
|
||||||
|
/*
|
||||||
|
parameter structure:
|
||||||
|
{
|
||||||
|
inputVideoPath: String, // Path to the file
|
||||||
|
outputType: String // Audio file output format
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
let progressBar = new cliProgress.SingleBar({
|
||||||
|
format: 'Processing |{bar}| {percentage}% | {timemark}',
|
||||||
|
barCompleteChar: '\u2588',
|
||||||
|
barIncompleteChar: '\u2591',
|
||||||
|
hideCursor: true
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
// if (meta.url === `file://${process.argv[1]}`) {
|
||||||
|
this.extractAudioFromVideo(parameter.inputVideoPath, progressBar, parameter.outputType)
|
||||||
|
.then(() => console.log('Audio extraction successful.'))
|
||||||
|
.catch((err) => console.error(err));
|
||||||
|
// }
|
||||||
|
} catch (error) {
|
||||||
|
console.log(parameter.outputType);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
// Derive input and output paths
|
||||||
|
// const inputVideoPath = process.argv[2];
|
||||||
|
// console.log(process.argv);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extracts audio from a video using ffmpeg.
|
||||||
|
* - Converts video to WAV (16 kHz, Mono, PCM optional if needed)
|
||||||
|
* - Shows CLI progress bar
|
||||||
|
* - Handles errors gracefully (without errors)
|
||||||
|
*/
|
||||||
|
extractAudioFromVideo: async function (videoFilePath, progressBar, outputType){
|
||||||
|
let inputVideoName = path.basename(videoFilePath, path.extname(videoFilePath));
|
||||||
|
let outputAudioPath = path.join(outputDir, `${inputVideoName}.${outputType}`);
|
||||||
|
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
try {
|
||||||
|
ffmpeg(videoFilePath)
|
||||||
|
.outputFormat(outputType)
|
||||||
|
// .audioCodec('pcm_s16le')
|
||||||
|
.audioChannels(1)
|
||||||
|
.audioFrequency(16000)
|
||||||
|
// .setFfmpegPath("./ffmpeg.exe")
|
||||||
|
.on('progress', (progress) => {
|
||||||
|
if (!progressBar.isActive) progressBar.start(100, 0, { timemark: '00:00:00' });
|
||||||
|
if (progress.percent) {
|
||||||
|
progressBar.update(progress.percent, { timemark: progress.timemark });
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.on('end', () => {
|
||||||
|
progressBar.update(100, { timemark: 'done' });
|
||||||
|
progressBar.stop();
|
||||||
|
console.log(`Extraction completed: ${outputAudioPath}`);
|
||||||
|
|
||||||
|
audioEvents.emit('audio_ready', {
|
||||||
|
sessionId: inputVideoName,
|
||||||
|
audioPath: outputAudioPath
|
||||||
|
});
|
||||||
|
|
||||||
|
resolve();
|
||||||
|
})
|
||||||
|
.on('error', (err) => {
|
||||||
|
progressBar.stop();
|
||||||
|
console.error(`failed_audio_extraction on type ${outputType}: ${err.message}`);
|
||||||
|
reject(err);
|
||||||
|
})
|
||||||
|
.save(outputAudioPath);
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.log();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
audioEvents: audioEvents
|
||||||
|
}
|
||||||
@@ -1,90 +0,0 @@
|
|||||||
import ffmpegPath from 'ffmpeg-static';
|
|
||||||
import ffmpeg from 'fluent-ffmpeg';
|
|
||||||
import path from 'path';
|
|
||||||
import fs from 'fs';
|
|
||||||
import cliProgress from 'cli-progress';
|
|
||||||
import { fileURLToPath } from 'url';
|
|
||||||
|
|
||||||
// Base code reference: https://docs.yemreak.com/arsiv/programming/extract-audio-from-video-with-typescript-and-ffmpeg
|
|
||||||
// Test command: npx ts-node ./extract.ts /path/to/video.mp4
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Extracts audio from a video file and saves it as WAV.
|
|
||||||
* @param videoFilePath Path to the input video file.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Ensure ffmpeg binary is available
|
|
||||||
if (!ffmpegPath) {
|
|
||||||
throw new Error('FFmpeg binary not found!');
|
|
||||||
}
|
|
||||||
ffmpeg.setFfmpegPath(ffmpegPath);
|
|
||||||
|
|
||||||
// Ensure an input video path is provided via CLI
|
|
||||||
if (process.argv.length < 3) {
|
|
||||||
console.error('Usage: ts-node ./extract.ts <input-video-path>');
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Resolve __dirname equivalent in ESM
|
|
||||||
const __filename = fileURLToPath(import.meta.url);
|
|
||||||
const __dirname = path.dirname(__filename);
|
|
||||||
|
|
||||||
// Prepare output directory (always storage/audio under project root)
|
|
||||||
const outputDir = path.join(__dirname, '..', '..', '..', 'storage', 'audio');
|
|
||||||
if (!fs.existsSync(outputDir)) {
|
|
||||||
fs.mkdirSync(outputDir, { recursive: true });
|
|
||||||
}
|
|
||||||
|
|
||||||
// Derive input and output paths
|
|
||||||
const inputVideoPath = process.argv[2];
|
|
||||||
const inputVideoName = path.basename(inputVideoPath, path.extname(inputVideoPath));
|
|
||||||
const outputAudioPath = path.join(outputDir, `${inputVideoName}.wav`);
|
|
||||||
|
|
||||||
// Initialize CLI progress bar
|
|
||||||
const progressBar = new cliProgress.SingleBar({
|
|
||||||
format: 'Processing |{bar}| {percentage}% | {timemark}',
|
|
||||||
barCompleteChar: '\u2588',
|
|
||||||
barIncompleteChar: '\u2591',
|
|
||||||
hideCursor: true
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Extracts audio from a video using ffmpeg.
|
|
||||||
* - Converts video to WAV (16 kHz, Mono, PCM optional if needed)
|
|
||||||
* - Shows CLI progress bar
|
|
||||||
* - Handles errors gracefully (without errors)
|
|
||||||
*/
|
|
||||||
export function extractAudioFromVideo(videoFilePath: string): Promise<void> {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
ffmpeg(videoFilePath)
|
|
||||||
.outputFormat('wav')
|
|
||||||
.audioCodec('pcm_s16le')
|
|
||||||
.audioChannels(1)
|
|
||||||
.audioFrequency(16000)
|
|
||||||
.on('progress', (progress) => {
|
|
||||||
if (!progressBar.isActive) progressBar.start(100, 0, { timemark: '00:00:00' });
|
|
||||||
if (progress.percent) {
|
|
||||||
progressBar.update(progress.percent, { timemark: progress.timemark });
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.on('end', () => {
|
|
||||||
progressBar.update(100, { timemark: 'done' });
|
|
||||||
progressBar.stop();
|
|
||||||
console.log(`Extraction completed: ${outputAudioPath}`);
|
|
||||||
resolve();
|
|
||||||
})
|
|
||||||
.on('error', (err) => {
|
|
||||||
progressBar.stop();
|
|
||||||
console.error(`failed_audio_extraction: ${err.message}`);
|
|
||||||
reject(err);
|
|
||||||
})
|
|
||||||
.save(outputAudioPath);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Run extraction if executed directly from CLI
|
|
||||||
if (import.meta.url === `file://${process.argv[1]}`) {
|
|
||||||
extractAudioFromVideo(inputVideoPath)
|
|
||||||
.then(() => console.log('Audio extraction successful.'))
|
|
||||||
.catch((err) => console.error(err));
|
|
||||||
}
|
|
||||||
+1
-2
@@ -5,7 +5,7 @@ import { fileURLToPath } from "url"; // To handle __dirname in ES modules
|
|||||||
|
|
||||||
const __filename = fileURLToPath(import.meta.url); // Get current file path
|
const __filename = fileURLToPath(import.meta.url); // Get current file path
|
||||||
const __dirname = path.dirname(__filename); // Get current directory path
|
const __dirname = path.dirname(__filename); // Get current directory path
|
||||||
const transcriptsDir = path.resolve(__dirname, "../../storage/transcriptions");
|
const transcriptsDir = path.resolve(__dirname, "../../../storage/transcriptions");
|
||||||
|
|
||||||
|
|
||||||
export class whisperLocal { // is called by transcribe.ts
|
export class whisperLocal { // is called by transcribe.ts
|
||||||
@@ -26,7 +26,6 @@ export class whisperLocal { // is called by transcribe.ts
|
|||||||
|
|
||||||
async transcribe(audioPath: string): Promise<string> { //asyncronous function to transcribe audio
|
async transcribe(audioPath: string): Promise<string> { //asyncronous function to transcribe audio
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const transcriptsDir = path.resolve(__dirname, "../../../../storage/transcripts"); //storage directory for transcripts
|
|
||||||
|
|
||||||
if (!fs.existsSync(transcriptsDir)) { //if transcripts directory does not exist, create it
|
if (!fs.existsSync(transcriptsDir)) { //if transcripts directory does not exist, create it
|
||||||
fs.mkdirSync(transcriptsDir, { recursive: true });
|
fs.mkdirSync(transcriptsDir, { recursive: true });
|
||||||
@@ -0,0 +1,128 @@
|
|||||||
|
require('dotenv/config');
|
||||||
|
const axios = require('axios');
|
||||||
|
const fs = require('fs');
|
||||||
|
const path = require('path');
|
||||||
|
|
||||||
|
const API_KEY = process.env.ASSEMBLYAI_API_KEY;
|
||||||
|
const BASE_URL = 'https://api.assemblyai.com/v2';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Uploads audio file to AssemblyAI
|
||||||
|
*/
|
||||||
|
async function uploadAudio(audioPath) {
|
||||||
|
const audioData = fs.readFileSync(audioPath);
|
||||||
|
|
||||||
|
const response = await axios.post(`${BASE_URL}/upload`, audioData, {
|
||||||
|
headers: {
|
||||||
|
'authorization': API_KEY,
|
||||||
|
'content-type': 'application/octet-stream'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return response.data.upload_url;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract session id from path or URL
|
||||||
|
*/
|
||||||
|
function getSessionId(inputPath) {
|
||||||
|
try {
|
||||||
|
const parsed = new URL(inputPath);
|
||||||
|
const base = path.basename(parsed.pathname);
|
||||||
|
return base.replace(/\.[^.]+$/, '');
|
||||||
|
} catch (err) {
|
||||||
|
return path.basename(inputPath, path.extname(inputPath));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates transcription job with speaker diarization
|
||||||
|
*/
|
||||||
|
async function createTranscript(audioUrl) {
|
||||||
|
const response = await axios.post(`${BASE_URL}/transcript`, {
|
||||||
|
audio_url: audioUrl,
|
||||||
|
speaker_labels: true,
|
||||||
|
language_detection: true
|
||||||
|
}, {
|
||||||
|
headers: {
|
||||||
|
'authorization': API_KEY,
|
||||||
|
'content-type': 'application/json'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return response.data.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Polls transcript status until completed
|
||||||
|
*/
|
||||||
|
async function pollTranscript(transcriptId) {
|
||||||
|
while (true) {
|
||||||
|
const response = await axios.get(`${BASE_URL}/transcript/${transcriptId}`, {
|
||||||
|
headers: { 'authorization': API_KEY }
|
||||||
|
});
|
||||||
|
|
||||||
|
const status = response.data.status;
|
||||||
|
|
||||||
|
if (status === 'completed') {
|
||||||
|
return response.data;
|
||||||
|
} else if (status === 'error') {
|
||||||
|
throw new Error(`Transcription failed: ${response.data.error}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Wait 3 seconds before next poll
|
||||||
|
await new Promise(resolve => setTimeout(resolve, 3000));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Saves transcript to storage
|
||||||
|
*/
|
||||||
|
function saveTranscript(transcript, sessionId) {
|
||||||
|
const outputDir = path.join(__dirname, '..', '..', '..', 'storage', 'transcripts');
|
||||||
|
|
||||||
|
if (!fs.existsSync(outputDir)) {
|
||||||
|
fs.mkdirSync(outputDir, { recursive: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
const outputPath = path.join(outputDir, `${sessionId}.json`);
|
||||||
|
fs.writeFileSync(outputPath, JSON.stringify(transcript, null, 2));
|
||||||
|
|
||||||
|
console.log(`✅ Transcript saved: ${outputPath}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: "assembly",
|
||||||
|
type: "transcription",
|
||||||
|
displayname: "AssemblyAI",
|
||||||
|
run: async function(audioPath) {
|
||||||
|
try {
|
||||||
|
// Determine if audioPath is an external URL or a local file
|
||||||
|
let audioUrl;
|
||||||
|
if (/^https?:\/\//i.test(audioPath)) {
|
||||||
|
console.log('🔗 Using external audio URL...');
|
||||||
|
audioUrl = audioPath;
|
||||||
|
} else {
|
||||||
|
if (!fs.existsSync(audioPath)) {
|
||||||
|
throw new Error(`Audio file not found: ${audioPath}`);
|
||||||
|
}
|
||||||
|
console.log('📤 Uploading audio file...');
|
||||||
|
audioUrl = await uploadAudio(audioPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('🔄 Creating transcript job...');
|
||||||
|
const transcriptId = await createTranscript(audioUrl);
|
||||||
|
|
||||||
|
console.log('⏳ Waiting for transcription...');
|
||||||
|
const transcript = await pollTranscript(transcriptId);
|
||||||
|
|
||||||
|
const sessionId = getSessionId(audioPath);
|
||||||
|
saveTranscript(transcript, sessionId);
|
||||||
|
|
||||||
|
return transcript;
|
||||||
|
} catch (error) {
|
||||||
|
console.error('❌ Transcription error:', error.message);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,133 @@
|
|||||||
|
import 'dotenv/config';
|
||||||
|
import axios from 'axios';
|
||||||
|
import fs from 'fs';
|
||||||
|
import path from 'path';
|
||||||
|
import { fileURLToPath } from 'url';
|
||||||
|
|
||||||
|
const __filename = fileURLToPath(import.meta.url);
|
||||||
|
const __dirname = path.dirname(__filename);
|
||||||
|
|
||||||
|
const API_KEY = process.env.ASSEMBLYAI_API_KEY;
|
||||||
|
const BASE_URL = 'https://api.assemblyai.com/v2';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Uploads audio file to AssemblyAI
|
||||||
|
*/
|
||||||
|
async function uploadAudio(audioPath: string): Promise<string> {
|
||||||
|
const audioData = fs.readFileSync(audioPath);
|
||||||
|
|
||||||
|
const response = await axios.post<{ upload_url: string }>(`${BASE_URL}/upload`, audioData, {
|
||||||
|
headers: {
|
||||||
|
'authorization': API_KEY,
|
||||||
|
'content-type': 'application/octet-stream'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return response.data.upload_url;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract a session id (basename without extension) from a local path or a URL
|
||||||
|
*/
|
||||||
|
function getSessionId(inputPath: string): string {
|
||||||
|
try {
|
||||||
|
const parsed = new URL(inputPath);
|
||||||
|
const base = path.basename(parsed.pathname);
|
||||||
|
return base.replace(/\.[^.]+$/, '');
|
||||||
|
} catch (err) {
|
||||||
|
// not a URL, treat as local path
|
||||||
|
return path.basename(inputPath, path.extname(inputPath));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates transcription job with speaker diarization
|
||||||
|
*/
|
||||||
|
async function createTranscript(audioUrl: string): Promise<string> {
|
||||||
|
const response = await axios.post<{ id: string }>(`${BASE_URL}/transcript`, {
|
||||||
|
audio_url: audioUrl,
|
||||||
|
speaker_labels: true,
|
||||||
|
language_detection: true
|
||||||
|
}, {
|
||||||
|
headers: {
|
||||||
|
'authorization': API_KEY,
|
||||||
|
'content-type': 'application/json'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return response.data.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Polls transcript status until completed
|
||||||
|
*/
|
||||||
|
async function pollTranscript(transcriptId: string): Promise<any> {
|
||||||
|
while (true) {
|
||||||
|
const response = await axios.get<any>(`${BASE_URL}/transcript/${transcriptId}`, {
|
||||||
|
headers: { 'authorization': API_KEY }
|
||||||
|
});
|
||||||
|
|
||||||
|
const status = response.data.status;
|
||||||
|
|
||||||
|
if (status === 'completed') {
|
||||||
|
return response.data;
|
||||||
|
} else if (status === 'error') {
|
||||||
|
throw new Error(`Transcription failed: ${response.data.error}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Wait 3 seconds before next poll
|
||||||
|
await new Promise(resolve => setTimeout(resolve, 3000));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Saves transcript to storage
|
||||||
|
*/
|
||||||
|
function saveTranscript(transcript: any, sessionId: string): void {
|
||||||
|
const outputDir = path.join(__dirname, '..', '..', '..', 'storage', 'transcripts');
|
||||||
|
|
||||||
|
if (!fs.existsSync(outputDir)) {
|
||||||
|
fs.mkdirSync(outputDir, { recursive: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
const outputPath = path.join(outputDir, `${sessionId}.json`);
|
||||||
|
fs.writeFileSync(outputPath, JSON.stringify(transcript, null, 2));
|
||||||
|
|
||||||
|
console.log(`✅ Transcript saved: ${outputPath}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: "assembly",
|
||||||
|
type: "transcription",
|
||||||
|
displayname: "AssemblyAI",
|
||||||
|
run: async (audioPath: string) => {
|
||||||
|
try {
|
||||||
|
// Determine if audioPath is an external URL or a local file
|
||||||
|
let audioUrl: string;
|
||||||
|
if (/^https?:\/\//i.test(audioPath)) {
|
||||||
|
console.log('🔗 Using external audio URL...');
|
||||||
|
audioUrl = audioPath;
|
||||||
|
} else {
|
||||||
|
console.log('🔄 Uploading local audio...');
|
||||||
|
if (!fs.existsSync(audioPath)) {
|
||||||
|
throw new Error(`Audio file not found: ${audioPath}`);
|
||||||
|
}
|
||||||
|
audioUrl = await uploadAudio(audioPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('🔄 Creating transcript job...');
|
||||||
|
const transcriptId = await createTranscript(audioUrl);
|
||||||
|
|
||||||
|
console.log('⏳ Waiting for transcription...');
|
||||||
|
const transcript = await pollTranscript(transcriptId);
|
||||||
|
|
||||||
|
const sessionId = getSessionId(audioPath);
|
||||||
|
saveTranscript(transcript, sessionId);
|
||||||
|
|
||||||
|
return transcript;
|
||||||
|
} catch (error: any) {
|
||||||
|
console.error('❌ Transcription error:', error.message);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
module.exports = {
|
|
||||||
name:"assembly", // Unique name for our function that will later be used to get the function from the map via "mapFunctions.get("example").function()"
|
|
||||||
type:"transcription", // value used to differentiate each module to order them in the UI
|
|
||||||
displayname:"Assembly", // The displayname used within the UI
|
|
||||||
async function(parameter){
|
|
||||||
// TODO add code to actually process the audio file
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Submodule services/modules/transcription/local/whisper.cpp deleted from 999a7e0cbf
@@ -5,5 +5,9 @@ module.exports = {
|
|||||||
|
|
||||||
// We are now calling the example function from the example folder
|
// We are now calling the example function from the example folder
|
||||||
mapFunctions.get("example").function("Startup")
|
mapFunctions.get("example").function("Startup")
|
||||||
|
|
||||||
|
// mapFunctions.get("extraction-video-to-audio").function({inputVideoPath:"./a.mp4", outputType:"wav"})
|
||||||
|
// mapFunctions.get("extraction-video-to-audio").function({inputVideoPath:"./b.mp4", outputType:"wav"})
|
||||||
|
// mapFunctions.get("extraction-video-to-audio").function({inputVideoPath:"./b.mp4", outputType:"flac"})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
// services/pipeline/jobs/transcribeLatest.ts
|
||||||
|
import path from 'path';
|
||||||
|
import fs from 'fs';
|
||||||
|
// @ts-ignore: module has no type declarations or cannot be resolved in current TS config
|
||||||
|
import assembly from '../../modules/transcription/assembly';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finds the most recently modified .wav file in storage/audio/
|
||||||
|
*/
|
||||||
|
function getLatestWav(): string {
|
||||||
|
const audioDir = path.join(process.cwd(), 'storage', 'audio');
|
||||||
|
const files = fs.readdirSync(audioDir).filter(f => f.toLowerCase().endsWith('.wav'));
|
||||||
|
if (files.length === 0) throw new Error('⚠️ No .wav file found in storage/audio');
|
||||||
|
|
||||||
|
const newest = files
|
||||||
|
.map(f => ({ f, t: fs.statSync(path.join(audioDir, f)).mtimeMs }))
|
||||||
|
.sort((a, b) => b.t - a.t)[0].f;
|
||||||
|
|
||||||
|
return path.join(audioDir, newest);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Full transcription pipeline according to the defined workflow:
|
||||||
|
* 1. Audio Upload → AssemblyAI
|
||||||
|
* 2. Job Creation (transcript_id)
|
||||||
|
* 3. Polling Status (queued → processing → completed)
|
||||||
|
* 4. Download Transcript JSON
|
||||||
|
* 5. Storage: /transcripts/{session_id}.json
|
||||||
|
*/
|
||||||
|
async function main() {
|
||||||
|
const audioPath = getLatestWav();
|
||||||
|
|
||||||
|
console.log('1️⃣ Audio Upload → AssemblyAI');
|
||||||
|
console.log(' Source:', audioPath);
|
||||||
|
|
||||||
|
console.log('2️⃣ Job Creation (transcript_id)');
|
||||||
|
console.log('3️⃣ Polling Status (queued → processing → completed)');
|
||||||
|
console.log('4️⃣ Download Transcript JSON');
|
||||||
|
console.log('5️⃣ Storage: /transcripts/{session_id}.json');
|
||||||
|
|
||||||
|
// Execute the transcription process via the AssemblyAI module
|
||||||
|
const result = await assembly.run(audioPath);
|
||||||
|
|
||||||
|
console.log('✅ Transcription completed successfully');
|
||||||
|
console.log('🆔 Transcript ID:', result.id);
|
||||||
|
console.log('📁 Transcript file saved under: storage/transcripts/');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Entry point
|
||||||
|
main().catch((err) => {
|
||||||
|
console.error('❌ Transcription pipeline failed:', err.message || err);
|
||||||
|
process.exit(1);
|
||||||
|
});
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
import 'dotenv/config';
|
||||||
|
import assemblyModule from '../../services/modules/transcription-remote/assembly.ts';
|
||||||
|
|
||||||
|
// Test: URL passed as argument OR local file ./storage/audio/test.wav
|
||||||
|
const audioPath = process.argv[2] || './storage/audio/test.wav';
|
||||||
|
|
||||||
|
assemblyModule.run(audioPath)
|
||||||
|
.then(result => {
|
||||||
|
console.log('✅ Success!');
|
||||||
|
console.log('Transcript ID:', result.id);
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error('❌ Error:', error?.message || error);
|
||||||
|
});
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
from fastapi.testclient import TestClient
|
||||||
|
from app.main import app
|
||||||
|
|
||||||
|
client = TestClient(app)
|
||||||
|
|
||||||
|
def test_health():
|
||||||
|
response = client.get("/health")
|
||||||
|
assert response.status_code == 200
|
||||||
Reference in New Issue
Block a user