diff options
author | Minteck <contact@minteck.org> | 2022-04-09 16:39:03 +0200 |
---|---|---|
committer | Minteck <contact@minteck.org> | 2022-04-09 16:40:02 +0200 |
commit | 0f8967b9113d698cdeb2d05ca85d2d9a80461c24 (patch) | |
tree | 00664ddd9c55a2c33631fd1bd33e556cea9c67e5 /wolfram.js | |
parent | dac03ac82bc0f8044a4b339c27b5390e4dcecf2f (diff) | |
download | voicer-0f8967b9113d698cdeb2d05ca85d2d9a80461c24.tar.gz voicer-0f8967b9113d698cdeb2d05ca85d2d9a80461c24.tar.bz2 voicer-0f8967b9113d698cdeb2d05ca85d2d9a80461c24.zip |
Diffstat (limited to 'wolfram.js')
-rw-r--r-- | wolfram.js | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/wolfram.js b/wolfram.js new file mode 100644 index 0000000..35c2398 --- /dev/null +++ b/wolfram.js @@ -0,0 +1,23 @@ +(async () => { + try { + const translatte = require('translatte'); + const axios = require('axios'); + const fs = require('fs'); + + let input = Buffer.from(process.argv[2], 'base64').toString(); + let w_in = (await translatte(input, {from: 'fr', to: 'en'})).text; + let key = fs.readFileSync("./wolframkey").toString(); + let response = (await axios.get(`https://api.wolframalpha.com/v1/result?appid=${key}&i=${encodeURI(w_in)}&units=metric&timeout=10`)).data + let w_out = (await translatte(response, {from: 'en', to: 'fr'})).text; + + console.log(w_out.replace(/([0-9]+)\.([0-9]+)/gm, "$1,$2")); + process.exit(); + } catch (e) { + if (e.message === "Request failed with status code 501") { + process.exit(5); + } else { + console.log("Désolé, je ne parviens pas à accéder à Internet en ce moment. Vérifiez que votre appareil dispose d'une connexion Internet stable et réessayez."); + process.exit(); + } + } +})()
\ No newline at end of file |