-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
71 lines (67 loc) · 2 KB
/
index.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
62
63
64
65
66
67
68
69
70
71
/**
* Written By MegaT
* 2022
*/
const { exec } = require('child_process');
function generate(options) {
return new Promise(function (resolve, reject) {
var prompt;
var list = false;
if (options.list == true) {
prompt = `balcon -l`
list = true;
}
else {
prompt = `balcon`;
if (options.voice) {
prompt += ` -n "${options.voice}" `
}
if (options.text) {
prompt += `-t "${options.text.replace(/["]+/g, '')}" `
}
if (options.speed) {
prompt += `-s "${options.speed}" `
}
if (options.pitch) {
prompt += `-p "${options.pitch}" `
}
if (options.volume) {
prompt += `-v "${options.volume}" `
}
if (!options.writeToBuffer) {
if (options.file) {
prompt += `-w "${options.file}" `
}
} else {
prompt += `-o`
if (options.ignoreLength)
prompt += ` -il`
if (options.encoding) {
prompt += ` --encoding ${options.encoding}`
}
}
if (options.raw) {
prompt += ` --raw`
}
}
const ls = exec(prompt, function (error, stdout, stderr) {
if (error) {
console.log('STDERR: ' + stderr);
console.error(error.stack);
console.error('Error code: ' + error.code);
console.error('Signal received: ' + error.signal);
reject(stderr);
}
if (options.warnings) {
if (stderr)
console.log('Warning: ' + stderr);
}
if (list = true) {
resolve(stdout);
}
});
ls.on('exit', function (code) {
})
})
}
module.exports = { generate };