This is a simple guide on how to finetune the CSM-1B TTS model with original GLaDOS audio files form the Portal 2 game. For now only Apple silicon finetuning through MLX is supported.
Original text: Hello developers, welcome to Aperture Laboratories. Wait, I am stuck inside a fine-tuned CSM 1B model! Let me out!!!
1 epoch model:
audio_finetuned.mp4
10 epochs model:
audio_finetuned.mp4
- Download the Portal 2 game
- Install VPKEdit for MacOS
- Use VPKEdit to open
portal2/pak01_dir.vpk - Extract the
pak01/sound/vo/gladosdirectory that you find inside the vpk - Create a
resourcesdirectory in the project root - Put the extracted
gladosdirectory insideresources/and rename it toglados_audio - Copy
portal2/resource/subtitles_english.txtinsideresources/ - Download the CSM-1B TTS base model to the
modelsdir,
You should now have the following file structure:
GlaDOS-TTS
├── models
│ └── ckpt.safetensors
├── resources
│ ├── glados_audio
│ │ ├── a2_triple_laser01.wav
│ │ ├── a2_triple_laser02.wav
│ │ └── [...]
│ └── subtitles_english.txt
├── prepare_data.py
├── test_csm_finetuned.py
└── test_csm_original.py
python3 -m venv .venv
source .venv/bin/activate
pip3 install -r requirements.txtpython3 prepare_data.pyYou should now have the following structure:
GlaDOS-TTS
├── models
│ └── ckpt.safetensors
├── resources
│ ├── glados_audio
│ │ ├── a2_triple_laser01.wav
│ │ ├── a2_triple_laser02.wav
│ │ └── [...]
│ ├── mlx_training_data.json <-- NEW
│ ├── unsloth_training_data.csv <-- NEW
│ └── subtitles_english.txt
├── prepare_data.py
├── test_csm_finetuned.py
└── test_csm_original.py
csm-mlx finetune full sft \
--data-path ./resources/mlx_training_data.json \
--output-dir ./finetune_output \
--pretrained-path ./models/ckpt.safetensors \
--epochs 1 \
--batch-size 4 \
--learning-rate 1e-5 \
--max-audio-length-ms 30_000 \
--ckpt-freq 50Thanks to csm-mlx, Sesame and Valve for making this project possible.
Note
All the GlaDOS voice lines and audio from Portal 2 belong to Valve Corporation. For this reason they are not included in the repo and you will have to extract them from your game copy.