Skip to content

ebower42/CumberbatchNameGenerator

Repository files navigation

Cumberbatch Name Generator Discord Bot

A self-hosted discord bot that randomly generates alternative names to Benedict Cumberbatch, and can even speak them in voice chat too!


Features

  • 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

Installation

Docker (recommended)

The image can be pulled from ghcr.io/ebower42/cumberbatch-name-generator:latest. Read the Docker Compose section for information on use.

Source Code

Install the following software:

Download and unzip the latest version from the Releases page.

Install the required packages

pip install -r requirements.txt

Choose a voice for Piper TTS

In order to run the bot properly, you must have a number of environment variables specified:

  • AUDIO_DIR - The directory to put generated audio files
  • PIPER_VOICE_ID - The voice id of the piper voice, defaults to en_GB-alan-medium
  • PIPER_VOICES_DIR - The directory containing the piper voice onnx and json files
  • FFMPEG_EXEC - The path to the ffmpeg executable. You only need to specify this if ffmpeg is not part of your system path.
  • BOT_TOKEN - The token that's generated by discord when creating the bot in the discord dev portal
  • ELEVEN_LABS_TOKEN - An API token for ElevenLabs

Once you have finished all of that, you can run the bot!

python src/bot.py

Docker Compose

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:/audio

The /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_key

Start the bot:

docker compose up -d

If you'd like a different voice for Piper TTS, follow these steps.

Using the Bot

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 reply
  • join - Join the voice channel you are currently in
  • leave - Leave the voice channel the bot is currently in
  • speak - Speak the last generated name
  • autospeak <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.


Choosing a Different Piper TTS Voice

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.

Download Using the piper Python Package

If you have the piper package installed, you can run

python -m piper.download_voices --download-dir <voices_directory> <voice_id>

Download Directly

You can download voice files here. You must download BOTH the .onnx and .onnx.json files.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors