Spaces:
Sleeping
Sleeping
Update routes/index.js
Browse files- routes/index.js +7 -19
routes/index.js
CHANGED
@@ -3,25 +3,13 @@ var router = express.Router();
|
|
3 |
var textToSpeech = require('../helpers/tts');
|
4 |
|
5 |
/* POST /talk */
|
6 |
-
router.post('/talk', function
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
// res.json({});
|
14 |
-
// });
|
15 |
-
|
16 |
-
// Read AZURE_KEY and AZURE_REGION from environment variables
|
17 |
-
const azureKey = process.env.AZURE_KEY || 'AZURE_KEY not set';
|
18 |
-
const azureRegion = process.env.AZURE_REGION || 'AZURE_REGION not set';
|
19 |
-
|
20 |
-
// Return a dummy response with environment variables
|
21 |
-
res.json({
|
22 |
-
message: "Dummy response: text-to-speech is temporarily disabled.",
|
23 |
-
azureKey: azureKey,
|
24 |
-
azureRegion: azureRegion,
|
25 |
});
|
26 |
});
|
27 |
|
|
|
3 |
var textToSpeech = require('../helpers/tts');
|
4 |
|
5 |
/* POST /talk */
|
6 |
+
router.post('/talk', function(req, res, next) {
|
7 |
+
textToSpeech(req.body.text, req.body.voice)
|
8 |
+
.then(result => {
|
9 |
+
res.json(result);
|
10 |
+
})
|
11 |
+
.catch(err => {
|
12 |
+
res.json({});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
});
|
14 |
});
|
15 |
|