This is a local, offline text-to-speech tool for generating multiple-voice dialogues from text files, designed for
classroom use (e.g., English role-playing for children).
It uses Piper TTS for offline neural voices and outputs both per-line WAVs and a
merged MP3 for each lesson.
- Multiple voices per dialogue (map speakers to voices in
voices.yaml) - Automatic processing of all dialogues in the
dialogues/folder - Generates per-line WAV files and a merged MP3
- Customizable pause duration between lines
- Flags for selective processing and overwriting existing files
dialogue-generator/
├── dialogues/ # Text files with dialogues (one per lesson)
├── voices/ # Pretrained Piper voice models (.onnx + .json). Feel free to add more as necessary.
├── voices.yaml # Map speakers to voices
├── output/ # Generated audio (per lesson)
├── generate.py # Main Python script
├── helpers.py # functions to assist the main script
├── requirements.txt # Python dependencies
└── README.md
git clone git@github.com:RomanLeca/dialogue_generator.git
cd dialogue-apppython3 -m venv venv
source venv/bin/activatepip install -r requirements.txtbrew install ffmpegsudo apt install ffmpeg- Download pretrained Piper voices from rhasspy/piper-voices.
- Place .onnx and .json files in the voices/ folder.
- Map each speaker in voices.yaml
- Create .txt files in the dialogues/ folder. Filenames in
dialogues/should avoid spaces or special characters; only letters, numbers, and underscores_are recommended. - Format (colon
:is mandatory.):Speaker1: Hello, how are you? Speaker2: I’m fine, thanks! Speaker1: Let’s play together. - One speaker per line
- Filename without extension becomes the lesson name (this is useful for CLI calls later)
python generate.py [OPTIONS]| Flag | Description |
|---|---|
--only LESSON_NAME |
Process only the specified lesson (filename without .txt) |
--overwrite |
Overwrite all existing audio files |
--skip-existing |
Skip lessons that have already been generated (default) |
--pause-ms N |
Pause duration between lines in milliseconds (default 400) |
python generate.pypython generate.py --only lesson_01python generate.py --overwritepython generate.py --pause-ms 600This project can be run as a local web app for non-technical users.
- Install brew
- Install Python 3.11
brew install python@3.11
- Install ffmpeg (required for audio processing):
brew install ffmpeg
Copy the project folder to laptop (without the venv).
Double-click: Start.command
- A local server starts automatically
- Your browser opens to: http://127.0.0.1:8000/
- You can paste a dialogue and export MP3 files.
- To stop the app close the Terminal window (or press Ctrl+C).
This project is licensed under the MIT License.
You are free to use, modify, and distribute this software for personal, educational, or classroom use.
This project uses Piper TTS pretrained voices, which are provided under their own license.
Please refer to Piper Voices License for terms regarding voice models.
When sharing or distributing this project, please include this LICENSE section and the original copyright notice.