-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathserver.js
61 lines (45 loc) · 1.4 KB
/
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
'use strict';
var express = require('express'),
path = require('path'),
fs = require('fs');
/**
* Main application file
*/
// Set default node environment to development
process.env.NODE_ENV = process.env.NODE_ENV || 'development';
// Application Config
// var config = require('./lib/config/config');
// Connect to database
// var db = mongoose.connect(config.mongo.uri, config.mongo.options);
// Bootstrap models
// var modelsPath = path.join(__dirname, 'lib/models');
// fs.readdirSync(modelsPath).forEach(function (file) {
// if (/(.*)\.(js$|coffee$)/.test(file)) {
// require(modelsPath + '/' + file);
// }
// });
// Populate empty DB with sample data
// require('./lib/config/dummydata');
// Passport Configuration
// var passport = require('./lib/config/passport');
var app = express();
// Express settings
require('./express-config')(app);
// Routing
// require('./lib/routes')(app);
app.get('/', function (req, res) {
res.render('index');
});
app.get("/api/tts", function (req, res){
res.type('audio/mpeg');
var text = req.query.text;
var request = require('request');
// var url = "http://translate.google.com/translate_tts?tl=en&q=" + text;
var url = "http://www.voicerss.org/controls/speech.ashx?hl=en-us&c=mp3&src=" + text;
request.get(url).pipe(res);
});
// Start server
app.listen(process.env.PORT || 9000, function () {
});
// Expose app
exports = module.exports = app;