-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
74 lines (52 loc) · 1.75 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
const express = require('express');
const app = express();
const port = process.env.PORT || 5000;
const path = require('path');
const say = require('say');
const bodyParser = require("body-parser");
const { v4: uuidv4 } = require('uuid');
const LanguageToolApi = require('language-grammar-api');
app.use(bodyParser.json());
app.use(express.static(path.join(__dirname, "public")));
app.set('view engine', 'pug');
app.set('views','views');
app.get("/", (req,res,next) => {
res.status(200).render("dysverter");
});
app.get("/apropos", (req,res,next) => {
res.status(200).render("accueil");
})
app.get("/contacts", (req,res,next) => {
res.status(200).render("contact");
})
let spellCheck = new Object();
spellCheck.analyse = async function (text) {
var response = await languageToolClient.check({
text: `${text}`, // required
language: 'fr' // required (you can use .languages call to get language)
});
response.text = `${text}`;
return response;
}
app.post("/dev", (req,res,next) => {
spellCheck.analyse(req.body.clientText).then((resp) => {
res.json(resp);
});
});
const options = {
endpoint: 'https://languagetool.org/api/v2'
};
const languageToolClient = new LanguageToolApi(options);
async function getLanguages(){
languageToolClient.languages().then((res) => {
console.log(res);
});
}
app.post("/syntheseVocal", (req,res,next) => {
var uid = uuidv4();
say.export(`${req.body.text}`, 'Audrey', `${req.body.speed}` , `public/audios/${uid}.wav`, (err) => {
var data = {audio: `audios/${uid}.wav`};
res.json(data);
})
});
const server = app.listen(port, () => console.log("Listening on port 3000"));