It was quite a challenge to convert eSpeak NG to an Arduino Library.
The eSpeak NG is a compact open source software text-to-speech synthesizer for Linux, Windows, Android and other operating systems. It supports more than 100 languages and accents. It is based on the eSpeak engine created by Jonathan Duddington.
Language Specific Configuration Files
Using a foreign language is quite easy: You just need to load the language dependent files and set the corresponding voice. Here is the list of all language configuration files that are available.
The Arduino Sketch
To preserve some valuable memory we do not load the (default) English language, but I set up the German (de) language instead:
#include "AudioTools.h" // https://github.com/pschatzmann/arduino-audio-tools
#include "FileSystems.h" // https://github.com/pschatzmann/arduino-posix-fs
#include "espeak.h" // https://github.com/pschatzmann/arduino-espeak-ng)
I2SStream i2s; // or replace with AudioKitStream for AudioKit
const bool load_english = false;
ESpeak espeak(i2s, load_english);
void setup() {
Serial.begin(115200);
// add foreign language configuration file
espeak.add("/mem/data/de_dict", espeak_ng_data_de_dict,espeak_ng_data_de_dict_len);
espeak.add("/mem/data/lang/de", espeak_ng_data_lang_gmw_de, espeak_ng_data_lang_gmw_de_len);
// setup espeak
espeak.begin();
// Set voice
espeak.setVoice("de");
// setup output
audio_info espeak_info = espeak.audioInfo();
auto cfg = i2s.defaultConfig();
cfg.channels = espeak_info.channels; // 1
cfg.sample_rate = espeak_info.sample_rate; // 22050
cfg.bits_per_sample = espeak_info.bits_per_sample; // 16
i2s.begin(cfg);
}
void loop() {
espeak.say("Hallo Welt!");
delay(5000);
}
Dependencies
This library requires the installation of the following libraries:
- arduino-posix-fs Reading of file configuration data
- arduino-audio-tools Output of Audio
- arduino-espeak-ng espeak-ng library
Supported Platforms
For the time being I have only tested this sketch on an ESP32. Please note that the sketch needs about 1’638’633 bytes of PROGMEM.
Github
Further information can be found on Github
3 Comments
skdx · 27. November 2024 at 13:51
I solve the problem!!
I insert a missing space in this Line
ESpeak PROGMEM espeak(i2s, load_english);
The compoilation works well. But i get the message in the serial output –
Warning: open: file ‘/data/config’ does not exist
pschatzmann · 28. November 2024 at 7:10
Not sure how PROGMEM made it in there, because it should not be there.
If there are any doubs, double check with the provided examples in the project!
skdx · 27. November 2024 at 13:35
Hi Mr. Schatzmann,
i try to compile the sketch on a ESP32 Wroom an Arduino 1.8.19 and get the following message
‘ESpeakPROGMEM’ does not name a type; did you mean ‘espeakPHONEMES’?
I try to google the message without luck. What have i done wrong??
Thank you for your help