-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
42 lines (34 loc) · 1.15 KB
/
test.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
const Speaker = require("speaker");
const { default: Chatsounds, defaultModifiers } = require("./dist/index");
const sh = new Chatsounds();
async function update() {
const response1 = await sh.useSourcesFromGitHubMsgPack("PAC3-Server/chatsounds-valve-games", "master", "csgo");
const response2 = await sh.useSourcesFromGitHub("Metastruct/garrysmod-chatsounds", "master", "sound/chatsounds/autoadd");
if (response1 || response2) {
console.log("new chatsounds data!");
sh.mergeSources();
}
}
async function run(data) {
data = data.toString().trim();
const context = sh.new(data);
const speaker = new Speaker({
channels: 2, // 2 channels
bitDepth: 16, // 16-bit samples
sampleRate: 44100, // 44,100 Hz sample rate
});
speaker.on("end", () => speaker.close());
const audio = await context.stream({
sampleRate: 44100,
audioChannels: 2,
format: 's16le'
});
if (!audio) return console.log('no audio :(');
audio.pipe(speaker);
}
(async function() {
await update();
setInterval(update, 60 * 60 * 1000);
sh.useModifiers(defaultModifiers);
process.stdin.on("data", run);
})();