← Back to projects

Discord voice bot

A bot that joins a voice channel and speaks in the voice you pick, running voice cloning on an ordinary CPU, and a handful of decisions about consent that came before any code.

workingWorks; own use or demo. No real client data yet.

The problem

I wanted to understand voice cloning up close, and the way to understand it is to build it. The scope was deliberately tight: run on CPU, with no GPU and no paid service, inside a Discord bot my friends would actually use.

That CPU constraint decided much of the project: which model was usable, how much reference audio was needed and how much latency was acceptable.

Technical decisions

In a weekend project, the natural path would be to clone the voices of people on the server and apologise later. But a voice is biometric data, under Brazilian data protection law it is personal data, and the model licence forbids use without explicit consent. So I wrote the rule into the README itself, ahead of the setup instructions: ask permission in the group before recording.

That leaves the project depending on people saying yes, which is slower than pulling audio from an old call, and the available voices are limited to those who agreed.

No voice, audio or history enters the repository

Versioning the prepared voices alongside the code would make reinstalling much easier. Even so, the voices (.safetensors, ~270 MB), the audio samples, the generated output and the log of who said what are all kept out of version control, by an explicit rule in .gitignore.

Anyone cloning the repository gets nothing that works: they have to record their own samples and redo the preparation. I gave up reproducibility on purpose, because the other option was publishing other people’s biometric data in a repository.

Two separate Python environments, and the separation is mandatory

The first thing anyone would try is a single requirements.txt. Here the bot runs on the system Python, and audio preparation runs in a virtualenv with Python 3.11 and pinned versions.

A two-step setup with an explanation attached is bad for a newcomer, I know. But every pin has a reason: deepfilterlib only publishes a wheel for 3.11, torchaudio 2.2 removed a module the audio-cleanup library imports, and setuptools 81 removed the pkg_resources another dependency needs. I wrote the reason next to each pinned version, so nobody upgrades in good faith and breaks everything without understanding why.

What was left out

The bot does not use FFmpeg; only the preparation tools do. And there is no database and no web framework: it is three Python files. I kept the scope small on purpose, because I wanted to understand the model, not build a product.

  • Python
  • Pocket TTS
  • discord.py
  • PyTorch