-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
39 lines (33 loc) · 883 Bytes
/
server.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
const express = require('express');
const app = express();
const say = require('say');
const path = require('path');
const uuid = require('uuid');
app.get('/', (req, res) => {
res.send("OK");
});
app.get('/get/:id', (req, res) => {
res.sendFile(__dirname + "/public/" + req.params.id);
});
app.get('/make/:message', (req, res) => {
var message = req.params.message;
// TODO: Generate a random filename from a UUID
var filename = uuid.v4() + ".wav";
var place = path.join(__dirname + "/public/", filename);
say.export(message, 'Microsoft Eva Mobile', 0.75, place, (err) => {
if (err) {
res.send(err);
return console.error(err)
}
console.log('Text has been saved to: ' + place);
res.send(filename);
});
});
app.get('/voices', (req, res) => {
say.getInstalledVoices((a) => {
res.send(a);
});
});
app.listen(80, () => {
console.log("App Running.");
});