Skip to content

Latest commit

 

History

27 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 

Repository files navigation

ElevenlabsTTSBot

A local TTS bot using AI for voice generation with ElevenLabs Speech Synthesis!

Video Installation Guide

Video Installation Guide

First Things First

Download the latest release of the ElevenlabsTTSBot and extract the folder to your preferred location.

Creating Your Bot

Go to the Discord Developer Portal.
  • Click New Application
  • Set a name for your bot and accept the T&C
  • Set an avatar for your bot if you like
  • Go to the "Bot" tab
  • Scroll down to "Privileged Gateway Intents" and enable all three options
  • Scroll back up and select "Reset Token" to show your bot token, you will need this for the bot data file
  • Invite your bot by going to - discordapp.com/oauth2/authorize?client_id={CLIENT_ID}&scope=bot&permissions=35184408799232 Replace the {CLIENT_ID} including the brackets with the "Application ID" found under the "General Information" tab in your Application settings.
  • Select which server you want to add the bot to.

Creating an ElevenLabs Account

You are required to make an ElevenLabs account to run this bot. Go to ElevenLabs website and create your free account. Free users get a 10,000 character quota per month, which may last anywhere from the entire month to 10 minutes depending on your friend group...

Bot Data Information

Open the botdata.json file using your text editor of choice. Any notepad should work just fine. Note: Make sure NOT TO add OR remove any " or , characters in the file.
  • Update the discord_token field using the token you just got from the developer Portal
  • Enabling developer mode to get the server ID. If you cannot find the ID of your server, you must go to user settings, scroll to "Advanced" under "App Settings" and enable Developer mode. After doing this, simply right click your server and select "Copy Server ID"
  • Update the discord_server_id field with the ID of your server
  • Update the elevenlabs_api_key field using the API Key found on your Elevenlabs.io profile.
  • (Optional) Feel free to edit the other fields but make sure to keep the format as is

Dependencies

FFMpeg

  • Go to www.github.com/BtbN/FFmpeg-Builds/releases and download the latest gpl build for your system
  • Open the Zipped folder and extract the "bin" folder to your preferred location, for example in the DiscordMadnessboard directory
  • Open Windows System Properties and click the "Advanced" tab, and go to "Environment Variables"
  • Click the "Path" System variable, "Edit", and "New". Here you will need to add the path to your /bin folder, which can quickly be found by right clicking the folder and going to properties
  • Click OK and exit System Properties, FFMpeg is now ready to be used

Python

Should work with Python 3.10 + but only tested with 3.11
  • Go to the Python website and download the latest version of Python 3.11
  • When installing, make sure to tick the "Add python.exe to PATH" box, or otherwise do the same as you did for FFMpeg by manually adding Python to path

Python Libraries

Installing using Requirements.txt

  • Navigate to the ElevenlabsTTSBot folder in your CLI of choice (such as Powershell)
  • Tip: In Windows you can right click whilst in the folder and select "Open in Terminal"
  • Type "pip install -r requirements.txt"

Installing the packages separately

  • Open Windows PowerShell as an Administrator
  • Type "pip install discord"
  • Type "pip install mutagen"
  • Type "pip install PyNaCl"
This should install the required libraries to Python, if it does not work please check your Python installation completed correctly, or use another method such as choco to install the libraries.

Running the Bot

That's it!
You can now run the TTS Bot by opening the bot.py file with Python. For troubleshooting you can run the file in debug mode using your developing environment of choice, such as VS Code.

Commands

The currently available commands are as follows:
  • quota - Displays your available character count
  • voices - Displays the available AI voices
  • unstable - tts with 0 stability for simplicity - !unstable (voice) (ttsmessage) | (voicename or random) (string)
  • tts - tts with selected voice and stability - !tts (voice) (stability) (ttsmessage) | (voicename or random) (num 1-100) (string)
  • random - uses a random voice with random stability - !random (ttsmessage) | (string)
  • help
  • stop
  • join
  • leave

Activating Leave & Join sounds

The bot is also able to welcome and say goodbye to people joining and leaving voice chat! To enable, follow these steps:
  • Create a new role (or use an old one) in your Discord guild under "Server Settings" - "Roles"
  • Add users who will be welcomed to the role by clicking them, selecting "Roles" and applying the role to them
  • Copy the Role ID from the Roles section in your server settings
  • Update the "role_id" line in the botdata.json file with your role ID number
  • Set the "leave_join_sounds" line to "True"
  • (Optional) Change the stability to anything between 0.00 and 1.00 depending on preference! You can also add or remove bits that the bot may say using the "joinmessagesprefix" list etc.

Using Custom Voices

Follow these steps to use custom voices:
  • Go to [Elevenlabs Voice Library](https://elevenlabs.io/app/voice-library)
  • Click "Add to VoiceLab" on your preferred custom voice
  • Select the "VoiceLab" tab
  • Copy the voice ID by clicking the button that says "ID"
  • Paste the ID in the customvoices.json file with your name of choice (the name can be anything)
  • Use the "custom" command to use a custom voice with the bot
  • NOTE: You can only use custom voices added to your VoiceLab list, (max 3 by default)

Final Note

I am in no way associated with ElevenLabs or their products, this is simply a bot I made for fun for me and my friends to enjoy that I've released to the public. It's also completely free of charge, however 10,000 characters may not be enough for you if the bot gets heavily used. If so, I'd recommend subscribing to ElevenLabs for an increased monthly quota. Have fun!

Frequently Asked Questions

Q: The bot.py file opens my command prompt then instantly closes

A: Open Powershell or CMD and navigate to the ElevenlabsTTSBot folder. (Right click in the folder and select "Open in Terminal"). Type "Python.exe bot.py", or "Python3.exe bot.py". This should load the file properly. Alternatively, you can run the code in an IDE such as VS Code.

Q: How much does this bot cost to use?

A: Nothing! The only potential cost is increasing your monthly quota with Elevenlabs.

Changelog

Version 1.1

  • Improved performance of the main bot.py file
  • Refactoring of code
  • Updated voice request for the new ElevenLabs API
  • Fixed crashes on bot startup
  • Other QOL boring code stuff
1.1.1
Added custom voice functionality

About

A locally run Discord bot for AI Text To Speech

Resources

Stars

5 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages