Local vocabulary audio generation using Kokoro.
data/raw/ Source CSV vocabulary files
data/processed/ Generated TXT and combined CSV files
src/ CSV processing and text-to-audio scripts
requirements.txt Python package requirements
Use Python 3.10, 3.11, or 3.12. Kokoro 0.9.x does not support Python 3.13.
python3.11 -m venv .venv
source .venv/bin/activate
python -m pip install -r requirements.txtThis project was verified with Python 3.11.7.
CSV files to be processed should be UTF-8 text files with vocabulary entries in this shape:
word,definition
Input files may also use quoted rows:
"word","definition"
The first column is the vocabulary word. The second column is the definition. If a word appears in multiple input CSVs, the first definition found is kept.
Part-of-speech markers are normalized when converting CSV to TXT:
(n.) -> noun,
(v.) -> verb,
(adj.) -> adjective,
Combine, deduplicate, remove double quotes, and shuffle the raw CSV files:
python src/combine_and_shuffle.py data/raw/vocab1.csv data/raw/vocab2.csvThis always writes:
data/processed/combined.csv
Use --seed for reproducible shuffle order:
python src/combine_and_shuffle.py data/raw/vocab1.csv data/raw/vocab2.csv --seed 42Disable shuffling and keep input order after deduplication:
python src/combine_and_shuffle.py data/raw/vocab1.csv data/raw/vocab2.csv --no-shuffleConvert one CSV into TTS-friendly text:
python src/csv_to_txt.py data/raw/vocab1.csvBy default this writes:
data/processed/vocab1.txt
Convert the combined CSV:
python src/csv_to_txt.py data/processed/combined.csvThis writes:
data/processed/combined.txt
Generated TXT entries look like:
abase: verb, to humiliate, cause to feel shame; verb, to hurt the pride of.
Generate speech from a TXT file:
python src/txt_to_wav.py --input data/processed/combined.txtBy default, data/processed/combined.txt writes:
data/processed/combined.wav
Override voice, speed, device, or output path:
python src/txt_to_wav.py --input data/processed/combined.txt --voice af_bella --speed 1.1 --device cpu
python src/txt_to_wav.py --input data/processed/combined.txt --voice af_heart,af_bella --output data/processed/blended.wavEach non-empty TXT line is generated as its own vocabulary chunk. By default, the script inserts 1 second of silence between vocabulary lines. Override that pause if needed:
python src/txt_to_wav.py --input data/processed/combined.txt --line-pause 1.5List voices:
python src/txt_to_wav.py --list-voicesSupported devices are cpu, cuda, and auto. With --device auto, the script uses CUDA if available; otherwise it uses CPU.
The first TTS run downloads Kokoro model files from Hugging Face and the spaCy English model. After that, speech generation runs locally on your machine.
Kokoro weights are cached outside the repo by Hugging Face, typically under:
~/.cache/huggingface/hub/models--hexgrad--Kokoro-82M