discord-voice-recorder/README.md
2020-11-19 23:10:24 +05:30

3.4 KiB

Discord Voice Recorder

A Discord.js script which can record voice calls. Summon the bot to a voice channel, and voilà! the audio is piped right into your local machine.

Jump to Installation & Usage to get started.

Recording voice calls without prior consent violates privacy. Do not use this bot without approval. I'm not responsible for your insanity.

Installation and Usage

Clone the repository :

git clone https://github.com/chebro/discord-voice-recorder/

Run npm i to download necessary node_modules. Then, head over to the FFmpeg.org, and download executables for your OS; If you're on Windows, double-check if the FFmpeg bin is on your path.

Setting Up the Local Environment

To run this script locally, create a discord bot first. Invite the bot to your server, then:

  1. Create a config.json file and a recordings folder at the root folder.
  2. Paste the bot token (from developer window) and any bot prefix into config.json, like so:
{
    "BOT_TOKEN": "<YOUR_BOT_TOKEN>",
    "PREFIX": "<BOT_PREFIX>"
}

Running the Script

Run npm start, the bot should be online.

Start Recording

<PREFIX>enter <VOICE_CHANNEL_NAME>

Note: You should hear a 'drop' sound after running this. If you don't, there's a problem with your FFmpeg installation.

Stop Recording

<PREFIX>exit

Managing the Output

The audio will be recorded in PCM format and saved to the /recordings directory.

To work with PCM audio, you could use software such as Audacity. To import the audio into Audacity, open File > Import Raw Data... and then select your audio file. You should select Signed 16-bit PCM as the encoding, a Little-endian byte order, 2 Channels (Stereo) and a sample rate of 48000Hz.

Merge Recording

The output for each piece of audio stream is written to a unique file. To merge all output files, run:

node ./bin/merge.js

This creates a merge.pcm in the /recordings directory.

Note: Do not forget to empty your recordings folder after each session. Running ./bin/merge.js otherwise, will dump large merge files.

Convert the Merged File to MP3

As mentioned in issue #3, to convert pcm to mp3, run:

ffmpeg -f s16le -ar 44.1k -ac 2 -i merge.pcm output.mp3

Thanks

Special thanks to @eslachance for the gist. It is what inspired me to make this repo.