Adapted from dnhkng's GLaDOS repository.
Add the evil robot to your Python project as easy as:
import glados
tts = glados.TTS()
tts.speak_text_aloud("Hello, World!")
Find more usage options here!
If you just want to quickly make some GLaDOS TTS speech and don't really care about writing custom code, simply download the latest portable builds here. All you have to do is download and run your preferred .exe
file!
- Install with
install_windows.bat
. This should automatically:- Install Miniconda if you don't already have
pip
or aconda
binary - Install the virtual environment (with CUDA and CuDNN if you want!)
- Download the required model files if not already present
- Install Miniconda if you don't already have
- Run the interactive console demo with
run_console_windows.bat
- Install Miniconda if you do not have
conda
already installed. - Install the Conda environment with one of the following commands:
- GPU accelerated:
conda env create -f environment_cuda.yaml
- CPU only:
conda env create -f environment.yaml
- GPU accelerated:
- Download the required models with one of the following commands:
- Linux:
download_models_ubuntu.bash
- Mac:
download_models_mac.command
- Linux:
- Run the interactive console demo with
conda run -n glados python speak_console.py
You can get this a portable .exe
file for Windows here.
This is the suggested way to quickly generate messages. After it loads the models, it is actually very fast. It usually takes a fraction of a second to generate a message.
To run the installed version:
conda run -n glados python speak_console.py
There is a fixed delay between messages. By default this is 0.5
seconds, but you can change it with the -d
/--delay
parameter followed by the number of seconds you'd like the delay to be.
There is an automatic greeting message that plays on startup. You can change this with the -g
/--greeting
parameter followed by your greeting message.
You can also completely disable the greeting message with the -ng
/--no-greet
flag.
You can get this a portable .exe
file for Windows here.
This has to load the models every single time it runs, so it can be a bit slow.
conda run -n glados python speak.py -t "Hello, command line!"
-t
is the short version of the --text
parameter.
You can optionally choose to save to a .wav
file with the -o
/--output
parameter followed by the desired filename.
If you want to prevent the text from being read aloud, use the -q
/--quiet
flag. This is useful when you just want to make a .wav
file with the -o
parameter.
Below is a more comprehensive example of using the module in your own code.
import time # For making delays
import glados # Import the local module
# Create a reusable text-to-speech object (this will take some time to load the AI models)
tts = glados.TTS()
# Say some long text, delay 1 second, and then move on to the next line of code
# The speech will continue in the background until it finishes or is interrupted
tts.speak_text_aloud_async("Calcium is a soft, silvery-white metal and one of the most abundant elements on Earth.")
time.sleep(1)
# Say some text and wait until it is done being spoken
# If the previous speech isn't over yet, this will interrupt it
tts.speak_text_aloud("Hello, and thank you, world.")
# Manually stop the speech playback
tts.stop_audio()
# Generate audio to a Numpy array
audio = tts.generate_speech_audio("Wow, my voice is now stored directly in your random access memory.")
# Play the generated audio back, delay 1 second, and then move on to the next line of code
tts.play_audio_async(audio)
time.sleep(1)
# Restart the audio playback and wait until it's done this time.
tts.play_audio(audio)
# Save the generated audio as a wave file
tts.save_wav(audio, "example.wav")
- Apply upstream changes from main GLaDOS repo
- Fix run script on Win to detect .venv / conda / the environment