forked from pschatzmann/arduino-espeak-ng
-
Notifications
You must be signed in to change notification settings - Fork 0
/
espeak-arduino-voice.ino
45 lines (38 loc) · 1.32 KB
/
espeak-arduino-voice.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/**
* @file espeak-min.ino
* @author Phil Schatzmann
* @brief Arduino C++ API - minimum example. The espeak-ng-data is stored on in
* progmem with the arduino-posix-fs library and we output audio to I2S with the
* help of the AudioTools library
* @version 0.1
* @date 2022-10-27
*
* @copyright Copyright (c) 2022
*/
#include "AudioTools.h" // https://github.com/pschatzmann/arduino-audio-tools
//#include "AudioLibs/AudioKit.h" // https://github.com/pschatzmann/arduino-audiokit
#include "FileSystems.h" // https://github.com/pschatzmann/arduino-posix-fs
#include "espeak.h"
I2SStream i2s; // or replace with AudioKitStream for AudioKit
ESpeak espeak(i2s);
void setup() {
Serial.begin(115200);
//file_systems::FSLogger.begin(file_systems::FSInfo, Serial);
// add voice option
espeak.add("/mem/data/voices/!v/Alicia", espeak_ng_data_voices__v_Alicia, espeak_ng_data_voices__v_Alicia_len);
// setup espeak
espeak.begin();
// Set voice and voice option
espeak.setVoice("en+Alicia");
// 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("Hello world!");
delay(5000);
}