Open Yvtq8K3n opened 3 years ago
Any updates on this? Or some alternative so I can record in a voice channel and output it?
Any updates on this? Or some alternative so I can record in a voice channel and output it?
I did manage to find a way to successfully record and store voice recordings. However, I have no clue how it works. First, I made a class called Decoder, as follows: ` class OpusDecodingStream extends Transform { encoder
constructor(options, encoder) {
super(options)
this.encoder = encoder
}
_transform(data, encoding, callback) {
this.push(this.encoder.decode(data))
callback()
}
} ` Then with this decoder, which I still have no clue how it works, I parsed the audio and was able to store it.
await entersState(connection, VoiceConnectionStatus.Ready, 20e3);
if (connection) {
const receiver = connection.receiver;
member.guild.channels.cache.get(voiceChannel.id).members.forEach((tempMember) => {
const username = findUsername(tempMember.id)
const filename = "./recordings/test_${Date.now()}_${username}.wav";
const encoder = new OpusEncoder(16000, 1)
const commandAudioStream = receiver.subscribe(tempMember.id, {
end: {
behavior: EndBehaviorType.AfterSilence,
duration: 100,
},
})
.pipe(new OpusDecodingStream({}, encoder))
.pipe(new FileWriter(filename, {
channels: 1,
sampleRate: 16000
}))
});
Hopes this helps, but I really would like to see a cleaner guide. Not everyone is an audio engineer;( It would be nice to know how to store in other audio formats. You can see the full code in here: https://github.com/Yvtq8K3n/BobbyMcLovin/blob/742d041f5d3bd621628681c9ded0d7acde096c24/index.js#L72-L84
TypeError: failed to downcast any to number at crc (C:\Users\Yvtq8\Desktop\SideProjects\BobbyMcLovin\node_modules\node-crc\lib\lib.js:11:17) at OggLogicalBitstream.calculateCRC (C:\Users\Yvtq8\Desktop\SideProjects\BobbyMcLovin\node_modules\prism-media\dist\ogg\OggLogicalBitstream.js:92:23) at OggLogicalBitstream.writePage (C:\Users\Yvtq8\Desktop\SideProjects\BobbyMcLovin\node_modules\prism-media\dist\ogg\OggLogicalBitstream.js:150:33) at OggLogicalBitstream.writeHeaderPages (C:\Users\Yvtq8\Desktop\SideProjects\BobbyMcLovin\node_modules\prism-media\dist\ogg\OggLogicalBitstream.js:74:18) at new OggLogicalBitstream (C:\Users\Yvtq8\Desktop\SideProjects\BobbyMcLovin\node_modules\prism-media\dist\opus\OggLogicalBitstream.js:16:14) at C:\Users\Yvtq8\Desktop\SideProjects\BobbyMcLovin\index.js:51:35 at Map.forEach ()
at start (C:\Users\Yvtq8\Desktop\SideProjects\BobbyMcLovin\index.js:37:70)