i have tried to dummy down you code so that i could test with just the google tts for now cause all i get is rebooting, so i am trying to get it working in a basic way 1st and then add it it my project. below is my code
`
#include "Arduino.h"
#include <Audio.h>
#include "esp_task_wdt.h"
Audio audio_play;
const int volume = 20;
// Digital I/O used
#define I2S_BCLK 5
#define I2S_DOUT 6
#define I2S_LRC 4
const char* TTS_GOOGLE_LANGUAGE = "en";
TaskHandle_t audioTaskHandle = NULL;
void setup() {
Serial.begin(115200);
audio_play.setPinout(I2S_BCLK, I2S_LRC, I2S_DOUT);
audio_play.setVolume(volume); // default 0...21
// Configure and initialize the watchdog timer
esp_task_wdt_config_t wdt_config = {
.timeout_ms = 30000, // 30 seconds timeout
.idle_core_mask = (1 << portNUM_PROCESSORS) - 1, // All cores will be monitored
.trigger_panic = true // Trigger a panic on timeout
};
esp_task_wdt_init(&wdt_config);
esp_task_wdt_add(NULL); // Add current task to WDT
// Create audio handling task
xTaskCreatePinnedToCore(audioLoopTask, "audioLoop", 8192, NULL, 1, &audioTaskHandle, 1);
}
void loop() {
String text = "Hey freddoh! What can I help you with today? This is a longer sentence to check splitting. And here's another one for word integrity. i want to thank everyone for calling me on my birthday this year. and if you forget me last year then, fine. you are no longer my friends. hahah just kidding";
speakTextInChunks(text, 93); // Using Google TTS with 93 characters max length
// Stop the loop after playing all segments once
while (true) {
delay(1000);
}
}
void audioLoopTask(void *pvParameters) {
for(;;) {
if (audio_play.isRunning()) {
audio_play.loop();
}
vTaskDelay(1); // Yield CPU
}
}
void speakTextInChunks(String text, int maxLength) {
int start = 0;
while (start < text.length()) {
int end = start + maxLength;
// Ensure we don't split in the middle of a word
if (end < text.length()) {
while (end > start && text[end] != ' ' && text[end] != '.' && text[end] != ',') {
end--;
}
}
// If no space or punctuation is found, just split at maxLength
if (end == start) {
end = start + maxLength;
}
String chunk = text.substring(start, end);
Serial.println("Starting to speak chunk...");
Serial.println(chunk);
Serial.println("Calling connecttospeech");
audio_play.connecttospeech(chunk.c_str(), TTS_GOOGLE_LANGUAGE);
Serial.println("Waiting for audio to finish...");
while (audio_play.isRunning()) {
vTaskDelay(1); // Changed to vTaskDelay for better multitasking
Serial.print("."); // Show activity
}
Serial.println("Finished playing chunk.");
delay(50); // Small delay between chunks to give system time to manage
start = end + 1; // Move to the next part, skipping the space
}
}
`
but all i am getting is a rebooting still
6:14:12.296 -> Rebooting... 16:14:12.329 -> ESP-ROM:esp32s3-20210327 16:14:12.329 -> Build:Mar 27 2021 16:14:12.329 -> rst:0xc (RTC_SW_CPU_RST),boot:0x8 (SPI_FAST_FLASH_BOOT) 16:14:12.329 -> Saved PC:0x4037aa8a 16:14:12.329 -> SPIWP:0xee 16:14:12.329 -> mode:DIO, clock div:1 16:14:12.329 -> load:0x3fce2820,len:0x1188 16:14:12.329 -> load:0x403c8700,len:0x4 16:14:12.329 -> load:0x403c8704,len:0xbf0 16:14:12.329 -> load:0x403cb700,len:0x30e4 16:14:12.329 -> entry 0x403c88ac 16:14:12.601 -> E (5) task_wdt: esp_task_wdt_init(515): TWDT already initialized 16:14:12.633 -> Starting to speak chunk... 16:14:12.633 -> Hey Chaddoh! What can I help you with today? This is a longer sentence to check splitting. 16:14:12.633 -> Calling connecttospeech 16:14:12.671 -> 16:14:12.708 -> assert failed: xQueueSemaphoreTake queue.c:1709 (( pxQueue )) 16:14:12.743 ->
can you tell me what you did to get that working? it would be greatly appreciated thanks
i have tried to dummy down you code so that i could test with just the google tts for now cause all i get is rebooting, so i am trying to get it working in a basic way 1st and then add it it my project. below is my code
`
#include "Arduino.h"
#include <Audio.h>
#include "esp_task_wdt.h"
Audio audio_play;
const int volume = 20;
// Digital I/O used
#define I2S_BCLK 5
#define I2S_DOUT 6
#define I2S_LRC 4
const char* TTS_GOOGLE_LANGUAGE = "en";
TaskHandle_t audioTaskHandle = NULL;
void setup() {
Serial.begin(115200);
audio_play.setPinout(I2S_BCLK, I2S_LRC, I2S_DOUT);
audio_play.setVolume(volume); // default 0...21
// Configure and initialize the watchdog timer
esp_task_wdt_config_t wdt_config = {
.timeout_ms = 30000, // 30 seconds timeout
.idle_core_mask = (1 << portNUM_PROCESSORS) - 1, // All cores will be monitored
.trigger_panic = true // Trigger a panic on timeout
};
esp_task_wdt_init(&wdt_config);
esp_task_wdt_add(NULL); // Add current task to WDT
// Create audio handling task
xTaskCreatePinnedToCore(audioLoopTask, "audioLoop", 8192, NULL, 1, &audioTaskHandle, 1);
}
void loop() {
String text = "Hey freddoh! What can I help you with today? This is a longer sentence to check splitting. And here's another one for word integrity. i want to thank everyone for calling me on my birthday this year. and if you forget me last year then, fine. you are no longer my friends. hahah just kidding";
speakTextInChunks(text, 93); // Using Google TTS with 93 characters max length
// Stop the loop after playing all segments once
while (true) {
delay(1000);
}
}
void audioLoopTask(void *pvParameters) {
for(;;) {
if (audio_play.isRunning()) {
audio_play.loop();
}
vTaskDelay(1); // Yield CPU
}
}
void speakTextInChunks(String text, int maxLength) {
int start = 0;
while (start < text.length()) {
int end = start + maxLength;
}
}
`
but all i am getting is a rebooting still
6:14:12.296 -> Rebooting... 16:14:12.329 -> ESP-ROM:esp32s3-20210327 16:14:12.329 -> Build:Mar 27 2021 16:14:12.329 -> rst:0xc (RTC_SW_CPU_RST),boot:0x8 (SPI_FAST_FLASH_BOOT) 16:14:12.329 -> Saved PC:0x4037aa8a 16:14:12.329 -> SPIWP:0xee 16:14:12.329 -> mode:DIO, clock div:1 16:14:12.329 -> load:0x3fce2820,len:0x1188 16:14:12.329 -> load:0x403c8700,len:0x4 16:14:12.329 -> load:0x403c8704,len:0xbf0 16:14:12.329 -> load:0x403cb700,len:0x30e4 16:14:12.329 -> entry 0x403c88ac 16:14:12.601 -> E (5) task_wdt: esp_task_wdt_init(515): TWDT already initialized 16:14:12.633 -> Starting to speak chunk... 16:14:12.633 -> Hey Chaddoh! What can I help you with today? This is a longer sentence to check splitting. 16:14:12.633 -> Calling connecttospeech 16:14:12.671 -> 16:14:12.708 -> assert failed: xQueueSemaphoreTake queue.c:1709 (( pxQueue )) 16:14:12.743 ->can you tell me what you did to get that working? it would be greatly appreciated thanks