@@ -29,6 +29,7 @@ class TextToSpeech {
2929 p_tts = &tts;
3030 p_dictionary = &dict;
3131 p_decoder = &decoder;
32+ p_sink = &sink;
3233 decodedStream = new audio_tools::EncodedAudioStream (&sink, &decoder);
3334 begin ();
3435 }
@@ -39,6 +40,7 @@ class TextToSpeech {
3940 p_tts = &tts;
4041 p_dictionary = &dict;
4142 p_decoder = &decoder;
43+ p_sink = &sink;
4244 decodedStream = new audio_tools::EncodedAudioStream (&sink, &decoder);
4345 begin ();
4446 }
@@ -48,6 +50,7 @@ class TextToSpeech {
4850 AudioDictionaryBase &dict) {
4951 p_dictionary = &dict;
5052 p_decoder = &decoder;
53+ p_sink = &sink;
5154 decodedStream = new audio_tools::EncodedAudioStream (&sink, &decoder);
5255 begin ();
5356 }
@@ -90,14 +93,24 @@ class TextToSpeech {
9093 end ();
9194 }
9295
96+ // / writes silence for the indicated ms
97+ void delay (uint32_t delay_ms){
98+ uint8_t buffer[1024 ] = {0 };
99+ unsigned long timeout = millis ()+delay_ms;
100+ while (timeout>millis ()){
101+ p_sink->write ((const uint8_t *)buffer,1024 );
102+ }
103+ }
104+
93105 protected:
94106 bool active = false ;
95107 NumberToText ntt;
96108 audio_tools::AudioDecoder *p_decoder = nullptr ;
97109 audio_tools::EncodedAudioStream *decodedStream = nullptr ; // Decoding stream
98- SimpleTTSBase *p_tts = nullptr ; // Text source
110+ SimpleTTSBase *p_tts = nullptr ; // Text source
99111 AudioDictionaryBase *p_dictionary = nullptr ; // Dictionary to access audio data
100- audio_tools::StreamCopy copier; // copy in to out
112+ audio_tools::StreamCopy copier; // copy in to out
113+ Print *p_sink=nullptr ;
101114
102115 // / callback which says the words
103116 static void callback (audio_tools::Vector<const char *> words, void * ref) {
0 commit comments