How to make Arduino TTS dynamic( talkie library)

I have been trying to use this library by Arminjo GitHub - ArminJo/Talkie: Refurbished Arduino version of the Talkie library from Peter Knight. and make it dynamic.

The TTS is static in nature here. If the voices are defined once then its over but that's not what I want. I want it to be able to read actual texts, actual different texts perhaps making use of loops or something.

What I'm trying to do is receive data from another arduino, lets say the keyword DANGER, and pass it
through the in-built function voice.say().

I will be only sending keywords, i.e the words that are present in program memory defined in the library.

I do understand that the voice.say() accepts uint8_t datatype. Any help is greatly appreciated.

#include "Talkie.h"
#include "Vocab_US_Large.h"
#include "Vocab_Special.h"

Talkie voice;
  String pause="sp3_";
  String str=pause+"Hi";
  uint8_t data[]=str;
  void setup() {

}
void loop() {
    voice.say(spPAUSE2);
    voice.say(sp2_DANGER);
    voice.say(sp2_DANGER);
    voice.say(sp3_STORM);
    voice.say(sp3_IN);
    voice.say(sp3_THE);
    voice.say(sp3_NORTH);
    voice.say(data);
}

This is the code, it doesn't compile for obvious reasons.

I Know that what I'm trying to do in the code is wrong. It is just a reference for what I want to do.

After reading the "How to use this forum" post, please follow the instructions to post your code (using code tags) and explain the problems you are having with it.

Be sure to use an amplifier with the Arduino. Connecting speakers or headphones to the Arduino output pins (as the library documentation suggests) will end up destroying the output pins.

jremington:
After reading the "How to use this forum" post, please follow the instructions to post your code (using code tags) and explain the problems you are having with it.

Be sure to use an amplifier with the Arduino. Connecting speakers or headphones to the Arduino output pins (as the library documentation suggests) will end up destroying the output pins.

I have updated my post.

Yes I'm using PAM8403 class D amplifier. I hope my question is clearer now.

it doesn't compile for obvious reasons.

If the problems are obvious to you, you should have fixed them and tried again, before posting.

But before that, start with the examples that come with the library, and get those working.

Don't use Strings with AVR-based Arduinos. They cause memory corruption and random crashes.

jremington:
If the problems are obvious to you, you should have fixed them and tried again, before posting.

But before that, start with the examples that come with the library, and get those working.

Don't use Strings with AVR-based Arduinos. They cause memory corruption and random crashes.

Well if you're assuming I'm very new to arduino and coding then I'm not.

Reason why I posted here is because I couldn't think of any possible fixes and some of you might help me with it.

That's the first thing I do, run the examples in any library.

Not sure about the String stuff. I have always played around with them using arduino.

Reason why I posted here is because I couldn't think of any possible fixes

Fixes for what? You still haven't described the problem. If you want help with compiler error messages, post the messages.

For a summary of the problems with Strings, read this post.

Function names are internal and vanish after compilation. So one of many general approaches to have list-directed speech output would be to link keywords with function calls, i.e.

//key table defined 
#define DANGER 29
#define STORM 13
...
input_key = get_input();  //input data from another source
if (input_key == DANGER) voice.say(sp2_DANGER);
if (input_key == STORM) voice.say(sp3_STORM);
...

jremington:
Fixes for what? You still haven't described the problem. If you want help with compiler error messages, post the messages.

For a summary of the problems with Strings, read this post.

Function names are internal and vanish after compilation. So one of many general approaches to have list-directed speech output would be to link keywords with function calls, i.e.

//key table defined 

#define DANGER 29
#define STORM 13
...
input_key = get_input();  //input data from another source
if (input_key == DANGER) voice.say(sp2_DANGER);
if (input_key == STORM) voice.say(sp3_STORM);
...

jremington:
Fixes for what? You still haven't described the problem. If you want help with compiler error messages, post the messages.

For a summary of the problems with Strings, read this post.

Function names are internal and vanish after compilation. So one of many general approaches to have list-directed speech output would be to link keywords with function calls, i.e.

//key table defined 
#define DANGER 29
#define STORM 13
...
input_key = get_input();  //input data from another source
if (input_key == DANGER) voice.say(sp2_DANGER);
if (input_key == STORM) voice.say(sp3_STORM);
...

jremington:
Fixes for what? You still haven't described the problem. If you want help with compiler error messages, post the messages.

For a summary of the problems with Strings, read this post.

Function names are internal and vanish after compilation. So one of many general approaches to have list-directed speech output would be to link keywords with function calls, i.e.

//key table defined 

#define DANGER 29
#define STORM 13
...
input_key = get_input();  //input data from another source
if (input_key == DANGER) voice.say(sp2_DANGER);
if (input_key == STORM) voice.say(sp3_STORM);
...

Thanks for the Strings post.

Well yes, the way you have mentioned about using if loops is what I had thought about. This would become tiresome to write it for all the keywords as I want it to be more generalised and not be dependent on if or switch statements.

jremington:
Fixes for what? You still haven’t described the problem. If you want help with compiler error messages, post the messages.

I think what we can do is take the address of the array from program memory and map the address to its respective word. Whenever a word is detected we can point to the address in voice.say(). Probably this could be the answer but the implementation would be quite difficult. I have attache the png of the way the array looks.