A self-hosted discord bot that randomly generates alternative names to Benedict Cumberbatch, and can even speak them in voice chat too!
- Name Generation by randomly selecting name parts from a json file
- Text-to-Speech using ElevenLabs and Piper TTS
- Docker-ready with configurable env vars and volume mounts
The image can be pulled from ghcr.io/ebower42/cumberbatch-name-generator:latest. Read the
Docker Compose section for information on use.
Install the following software:
Download and unzip the latest version from the Releases page.
Install the required packages
pip install -r requirements.txt
In order to run the bot properly, you must have a number of environment variables specified:
AUDIO_DIR- The directory to put generated audio filesPIPER_VOICE_ID- The voice id of the piper voice, defaults toen_GB-alan-mediumPIPER_VOICES_DIR- The directory containing the piper voice onnx and json filesFFMPEG_EXEC- The path to the ffmpeg executable. You only need to specify this ifffmpegis not part of your system path.BOT_TOKEN- The token that's generated by discord when creating the bot in the discord dev portalELEVEN_LABS_TOKEN- An API token for ElevenLabs
Once you have finished all of that, you can run the bot!
python src/bot.py
This documentation assumes you are familiar with docker compose.
Create a docker-compose.yml file. Example:
services:
bot:
image: ghcr.io/ebower42/cumberbatch-name-generator:latest
restart: unless-stopped
env_file:
- .env
volumes:
- ./voices:/voices
- ./audio:/audioThe /voices directory is where your Piper voice files live, and the /audio directory is where generated audio files
are saved.
Create a .env file next to your docker-compose.yml with the following content:
BOT_TOKEN=your_discord_bot_token
ELEVEN_LABS_TOKEN=your_eleven_labs_api_keyStart the bot:
docker compose up -dIf you'd like a different voice for Piper TTS, follow these steps.
The bot's command prefix is !b or !batch. A command message has the following syntax:
!b [command] [arguments]
The bot has the following commands:
gen- Generate a new name and send it as a replyjoin- Join the voice channel you are currently inleave- Leave the voice channel the bot is currently inspeak- Speak the last generated nameautospeak <on|off>- Turn on/off autospeak. This toggles whether the bot speaks the name automatically when it generates a new one.help- Reply with help text
If no command is given, it assumes the gen command.
If all users leave the voice channel the bot is in, the bot will automatically leave in 20 seconds. This is cancelled if
a user re-joins. To change this timing, you can set the AUTO_VOICE_LEAVE_DELAY environment variable to however
many seconds you want before the bot leaves an empty voice channel.
Piper has a number of voices to download that can be browsed and sampled here. Once you have chosen a voice you like, grab the voice ID from the URL of the sample page. Example:
https://rhasspy.github.io/piper-samples/#en_GB-alan-medium
The voice ID for this URL is en_GB-alan-medium.
You have two ways to download the voice files. Whichever way you choose, make sure they are in the directory specified
by the PIPER_VOICES_DIR environment variable. Additionally, make sure you have the PIPER_VOICE environment variable
set to the ID of whichever voice you choose.
If you have the piper package installed, you can run
python -m piper.download_voices --download-dir <voices_directory> <voice_id>
You can download voice files here. You must download BOTH
the .onnx and .onnx.json files.
