MBROLA_T4 is a port of the MBROLA diphone-based speech synthesizer engine, adapted for the Teensy 4.0 and 4.1 microcontrollers.
This library enables real-time speech synthesis using MBROLA voice databases, with full integration into the Teensy Audio Library. Voices are compiled into code which can be stored into PROGMEM or external FLASH.
- Port of the original MBROLA engine (written in C).
- Compatible with the Teensy Audio Library.
- Voices are included in
.h/.cppformat (converted from MBROLA.bin) - Selectable A-law, μ-law, compression for voices.
- Low RAM requirement: a voice take around 1.5MB of storage in ROM/flash but the engine itself uses only around 60KB of (statically) allocated RAM which can be located in DTCM, DMAMEM or even EXTMEM.
- Voice engine fully encapsulated: multiple voices may be played simultaneously.
- Low CPU usage with real-time audio synthesis at 44.1 kHz
This project is based on both:
- the original MBROLA engine (MBROLA project) by the Faculté Polytechnique de Mons
- and the open-source port Mimbrola by Ethan Akira
This library is released under the GNU Affero GPL v3 (same as the orignal MBROLA code)
Before you can synthesize speech, you need to convert a MBROLA voice database. Voices may be downloaded from the official MBROLA voice repository (beware the voices are not open source: check license terms before usage).
Once downloaded, the voice must be converted into C++ source files that can be compiled into your Teensy project.
Use the provided voice2cpp utility located in the /tools/ subdirectory of this library. For example, to convert the French voice fr4, use:
cd tools
gcc voice2cpp.c -o voice2cpp
./voice2cpp -u2 /path/to/fr4_binary_fileThe parameter -u2 selects µ-law compression with downsampling, to reduce flash usage.
This will generate two files:
mbrola_voice_fr4_u2.hmbrola_voice_fr4_u2.cpp
You can then include them in your sketch or project.
Each voice generates a corresponding derived class of AudioPlayMBROLA, named as:
AudioPlayMBROLA_<voice>_<compressiontype>, e.g. AudioPlayMBROLA_fr4_u2.
#include "mbrola_voice_fr4_u2.h" // Include the generated voice
AudioPlayMBROLA_fr4_u2 mbrola; // Use the generated voice object
void setup() {
// Initialize audio system
AudioMemory(16);
// Play a short phrase
mbrola.speak(
"b 80\n"
"oU 90\n"
"S 80\n"
"_ 200\n"
);
}See the subdirectory /examples/ for a complete working code.