forked from ahmadk6/Voice-over-Translation-Tool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
34 lines (34 loc) · 1.1 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
const { doTranslate } = require("./translationService.js");
// const { changeSubtitles } = require("./subtitlesService.js");
const express = require('express');
const cors = require('cors');
const multer = require('multer')
const app = express();
app.use(cors());
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
app.listen(8000, () => {
console.log(`Server is running on port 8000.`);
});
var video;
var date;
const storage = multer.diskStorage({
destination: function(req, file, cb) {
return cb(null, "./files")
},
filename: function(req, file, cb) {
date = Date.now().toString()
video = `${date}_${file.originalname}`
return cb(null, video)
}
})
const upload = multer({ storage })
app.post('/translate', upload.single('file'), (req, res) => {
video = 'files/' + video;
doTranslate(video, date, req, res);
});
// app.post('/changeSubtitles', upload.single('file'), (req, res) => {
// //video = 'files/' + video;
// video = 'test/test4.mp4'
// changeSubtitles(video, date, req, res);
// });