I’m really disappointed with how little I can do with spencer…
the text to speech don’t work for me (another subject…) and I just tried to make it say two sentences in a row and I discover that you can’t, if you set two speech blocks in a row the second will raise “Another speech synthesis operation is already pending” error.
I tried in the block IDE to set another speech block in the “when done talking enclosure” part of the speech block, but it just do nothing to the code.
I tried with arduino IDE to make it wait with delay but it block the speech processing… so no way to make it say two sentences in a row… it seems to be something basic though.
My goal was just to make it wait between two setences, if you know how to do it, I’ll take it.
ok I succeeded to make it run twice in a row the speech synthesis with that code:
PreparedStatement* statement = nullptr;
bool synthesizing = false;
void speechPlay1(TTSError error, CompositeAudioFileSource* source){
synthesizing = false;
if(error != TTSError::OK){
Serial.printf("Text to speech error %d: %s\n", error, TTSStrings[(int) error]);
delete source;
delete statement;
statement = nullptr;
return;
}
LEDmatrix.startAnimation(new Animation(new SerialFlashFileAdapter("GIF-talk.gif")), true);
Playback.playMP3(source);
Playback.setPlaybackDoneCallback([](){
second_sentence();
});
delete statement;
statement = nullptr;
}
void speechPlay2(TTSError error, CompositeAudioFileSource* source){
synthesizing = false;
if(error != TTSError::OK){
Serial.printf("Text to speech error %d: %s\n", error, TTSStrings[(int) error]);
delete source;
delete statement;
statement = nullptr;
return;
}
LEDmatrix.startAnimation(new Animation(new SerialFlashFileAdapter("GIF-talk.gif")), true);
Playback.playMP3(source);
Playback.setPlaybackDoneCallback([](){});
delete statement;
statement = nullptr;
}
void first_sentence() {
Serial.println("start sentence 1");
if(synthesizing){
Serial.println("Another speech synthesis operation is already pending");
}else{
synthesizing = true;
delete statement;
statement = new PreparedStatement();
statement->addTTS("Hello! My name is Spencer!");
statement->prepare(speechPlay1);
}
Serial.println("end sentence 1");
}
void second_sentence() {
Serial.println("start sentence 2");
if(synthesizing){
Serial.println("Another speech synthesis operation is already pending");
}else{
synthesizing = true;
delete statement;
statement = new PreparedStatement();
statement->addTTS("I can't even speak twice !");
statement->prepare(speechPlay2);
}
Serial.println("end sentence 2");
}
void setup() {
Serial.begin(115200);
Serial.println();
Spencer.begin();
Spencer.loadSettings();
first_sentence();
}
void loop() {
LoopManager::loop();
}
but it only say the first sentence and throw me in the serial console:
start sentence 1
end sentence 1
start sentence 2
end sentence 2
HTTP code 400
Text to speech error 3: server response error
if it can help track the bug