AI trends are here to stay, and today there’s much talk about Vall-E and its future combination with GPT-3. But we must remember that all these Artificial Intelligence products come from collaborative investigation that have been freely available, so we will always find an open-source equivalent, and we must be thankful about it.
That’s the case of TorToiSe-TTS (text to speech), an AI voice generator from written text totally free to use in your PC.
https://github.com/neonbjb/tortoise-tts
Just listen to a little sample below from Morgan Freeman:
Installation
The easiest is to use the cloud script in Google Collab uploaded by the developer:
https://colab.research.google.com/drive/1wVVqUPqwiDBUVeWWOUNglpGhU3hg_cbR?usp=sharing
You just need to sign in and click "play" ▶ to run each block of code.
But for sure you want to run TorToiSe-TTS locally, without internet, and save the audio in your local drive, so let's move on.
Installing python3
Like many AI applications, TorToiSe-TTS runs in python, so you need python3 in your PC. I always recommend the use of Linux, but you might be able to run it in a Windows terminal as well.
https://www.python.org/downloads/
On Linux, just install it from your distro repo:
sudo apt-get update
sudo apt-get install python3.11
You'll also need the module venv to virtualize a python environment (it uses to come with the Windows installer):
sudo apt-get install python3.11-venv
Download repository
Download the official repository:
https://github.com/neonbjb/tortoise-tts
Be it the compressed file:
Or using git:
git clone https://github.com/neonbjb/tortoise-tts
You can also download my fork repository, where I add further installation instructions, a terminal automatic launcher and some test voices for Ultron (yes, Tony Stark's evil droid) which we'll see later on.
https://github.com/TheRoam/tortoise-tts-linuxLauncher
Create a python virtual environment
Next we'll have to install a series of python modules needed to run TorToiSe-TTS, but before this, we'll create a virtual python version, so the installation of these modules won't affect the rest of the python installation. You'll find this helpful when you use different AI apps that use different versions of the same module.
Open a terminal and write the following, so you'll create a "TTS" environment:
cd tortoise-tts
python3 -m venv TTS
Activate it this way:
source TTS/bin/activate
And now you'll see a referente to the TTS environment in the terminal:
(TTS) abc@123:~$ |
Install python modules
Let's now install the required modules, following the collab indications:
pip3 install -U scipy
pip3 install transformers==4.19.0
pip3 install -r requirements.txt
python3 setup.py install
Now you can try running TorToiSe-TTS, but some libraries will fail, depending on your python installation:
python3 scripts/tortoise_tts.py "This is The Roaming Workshop" -v "daniel" -p "fast" -o "test1.wav"
Try the previous command until you don't get any errors, installing the missing moules. In my case, they were the following:
pip3 install torch
pip3 install torchaudio
pip3 install llvmlite
pip3 install numpy==1.23
Finally, this test1.wav sound like this in the voice of daniel (which turns out to be Daniel Craig):
Using TorToiSe-TTS
The most simple program in TorToiSe-TTS is found in the folder scripts/tortoise_tts.py
and these are the main arguments:
python3 scripts/tortoise_tts.py "text" -v "voice" -V "route/to/voices/folder" --seed number -p "fast" -o "output-file.wav"
"text"
: text chain that will be converted to audio-v
: voice to be used to convert text. It must be the name of one of the folders available in/tortoise/voices/
-V
: specifies a folder for voices, in the case that you use a custom one.--seed
: seed number to feature the algorithm (can be any number)-p
: preset mode that determines quality ("ultra_fast", "fast", "standard", "high_quality").-o
: route and name of the output file. You must specify the fileformat, which is.wav
If you use my repo script TTS.sh
you'll be asked for these arguments on screen and it will run the algorithm automatically.
Add your own voices
You can add more voices to TorToiSe-TTS. For example, I wanted to add the voice of Ultron, the Marvel supervillain, following the developer Neonbjb indications:
- You must record 3 "clean" samples (without background noise or music) of about 10 seconds duration.
- The format must be 16bits floating point WAV with 22500 sample rate (you can use Audacity)
- Create a new folder inside
/tortoise/voices
(or anywhere, really) and save your recordings there. - When running TorToiSe-TTS, you'll need to call the voices folder with argument
-V
and the new voice with argument-v
For example, to use my Ultron recordings:
python3 sripts/tortoise_tts.py "This is The Roaming Workshop" -V "./tortoise/voices" -v "ultron-en" -p "fast" --seed 17 -o "./wavs/TRW_ultron3.wav"
Which sound like this:
I've taken cuts from a scene in Avengers: age of Ultron, both in English (ultron-en) and Spanish (ultron-es) which you can download from my repository.
Right now, the TorToiSe-TTS model is trained only in English, so it only woks properly in this language.
You can introduce text in another language, and AI will try to read it, but it will use the pronunciation learnt in English and it will sound weird.
If you are willing to train a model in your language (you need plenty GPU and several months), contact the developer, as he's keep to expand the project.
In the meantime, you can send any doubts or comments on 🐦 Twitter or 🐤 Koo!