3#include "AudioCodecs/CodecMP3Helix.h"
4#include "AudioTools/AudioOutput.h"
5#include "AudioTools/AudioStreams.h"
6#include "AudioTools/AudioTypes.h"
7#include "NumberToText.h"
8#include "AudioDictionary.h"
23 tts.registerCallback(
callback,
this);
28 decodedStream =
new audio_tools::EncodedAudioStream(&sink, &decoder);
34 tts.registerCallback(
callback,
this);
39 decodedStream =
new audio_tools::EncodedAudioStream(&sink, &decoder);
49 decodedStream =
new audio_tools::EncodedAudioStream(&sink, &decoder);
57 void say(
const char *word) {
59 AudioStream *mp3Stream = p_dictionary->get(word);
60 if (mp3Stream !=
nullptr) {
63 copier.begin(*decodedStream, *mp3Stream);
68 LOGE(
"Word not available in dictionary: %s", word);
83 void say(audio_tools::Vector<const char *> words) {
85 for (
auto word : words) {
93 uint8_t buffer[1024] = {0};
94 unsigned long timeout = millis()+delay_ms;
95 while(timeout>millis()){
96 p_sink->write((
const uint8_t*)buffer,1024);
103 audio_tools::AudioDecoder *p_decoder =
nullptr;
104 audio_tools::EncodedAudioStream *decodedStream =
nullptr;
107 audio_tools::StreamCopy copier;
108 Print *p_sink=
nullptr;
111 static void callback(audio_tools::Vector<const char *> words,
void* ref) {
Dictionary which provides a Stream of Audio for the indicated word.
Definition: SimpleTTSBase.h:49
Translates a number into englich words.
Definition: NumberToText.h:15
Common Functionality for TTS classes.
Definition: SimpleTTSBase.h:15
Audio output from text via the indicated audio sink. The text components need to be prerecorded and a...
Definition: TextToSpeech.h:18
TextToSpeech(AudioStream &sink, AudioDecoder &decoder, AudioDictionaryBase &dict)
Default Constructor.
Definition: TextToSpeech.h:44
void say(audio_tools::Vector< const char * > words)
a simple API to say multiple of the supported words
Definition: TextToSpeech.h:83
TextToSpeech(SimpleTTSBase &tts, AudioStream &sink, AudioDecoder &decoder, AudioDictionaryBase &dict)
TextToSpeech which support a SimpleTTSBase.
Definition: TextToSpeech.h:21
void delay(uint32_t delay_ms)
writes silence for the indicated ms
Definition: TextToSpeech.h:92
void say(const char *word)
a simple API to say one of the supported words
Definition: TextToSpeech.h:57
static void callback(audio_tools::Vector< const char * > words, void *ref)
callback which says the words
Definition: TextToSpeech.h:111