-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathgentle_stt.js
38 lines (32 loc) · 994 Bytes
/
gentle_stt.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
var request = require('request');
var fs = require('fs');
var url = "http://localhost:8765/transcriptions?async=false";
/**
* Takes in file with absolute path. can use node module path to get absolute path of a file.
*/
function send_to_gentle(file, callback) {
console.log("Sending request to Gentle STT")
// fs.readFile(file, function(error, data) {
// if (error) {
// console.log(error);
// return false;
// }
var options = {
headers: {
'Content-Type': 'multipart'
},
formData: {
audio: fs.createReadStream(file)
}
};
request.post(url, options, function(error, response, body) {
if (error) console.log(error);
// var parsed = parse(JSON.parse(body));
if (typeof callback !== 'undefined') {
// fs.writeFileSync("./tmp/tmp.watson.tramscription.json",JSON.stringify(JSON.parse(body) ))
callback(JSON.parse(body));
}
});
// });
}
module.exports = send_to_gentle;