ESP-SR Basic Example does not work

Hi, I am trying to upload the basic example of esp-sr on my esp32-s3 (esp32-s3 DevkitC 1 N16R8), the upload is done correctly but in the serial I see this

[   517][V][esp32-hal-uart.c:510] uartBegin(): UART0 not installed. Starting installation
[   526][V][esp32-hal-uart.c:575] uartBegin(): UART0 initialization done.
[   533][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type GPIO (1) successfully set to 0x42061958
[   544][V][esp32-hal-periman.c:160] perimanSetPinBus(): Pin 40 successfully set to type GPIO (1) with bus 0x29
[   554][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type GPIO (1) successfully set to 0x42061958
[   565][V][esp32-hal-periman.c:160] perimanSetPinBus(): Pin 41 successfully set to type GPIO (1) with bus 0x2a
[   575][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type I2S_STD_BCLK (13) successfully set to 0x42002f3c
[   587][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type I2S_STD_WS (14) successfully set to 0x42002f3c
[   598][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type I2S_STD_DIN (16) successfully set to 0x42002f3c
[   611][V][esp32-hal-periman.c:160] perimanSetPinBus(): Pin 17 successfully set to type I2S_STD_BCLK (13) with bus 0x3fc9aaf8
[   622][V][esp32-hal-periman.c:160] perimanSetPinBus(): Pin 47 successfully set to type I2S_STD_WS (14) with bus 0x3fc9aaf8
[   633][V][esp32-hal-periman.c:160] perimanSetPinBus(): Pin 16 successfully set to type I2S_STD_DIN (16) with bus 0x3fc9aaf8
[   645][D][esp32-hal-sr.c:338] sr_start(): init model
[   650][D][esp32-hal-sr.c:346] sr_start(): load wakenet 'wn9_hiesp'
Guru Meditation Error: Core  1 panic'ed (StoreProhibited). Exception was unhandled.

(I have the Core Debug Level in Verbose)

I share with you the code although it is the same of the example without modification


#include "ESP_I2S.h"
#include "ESP_SR.h"

#define I2S_PIN_BCK 17
#define I2S_PIN_WS  47
#define I2S_PIN_DIN 16

#define LIGHT_PIN 40
#define FAN_PIN   41

I2SClass i2s;

// Generated using the following command:
// python3 tools/gen_sr_commands.py "Turn on the light,Switch on the light;Turn off the light,Switch off the light,Go dark;Start fan;Stop fan"
enum {
  SR_CMD_TURN_ON_THE_LIGHT,
  SR_CMD_TURN_OFF_THE_LIGHT,
  SR_CMD_START_FAN,
  SR_CMD_STOP_FAN,
};
static const sr_cmd_t sr_commands[] = {
  {0, "Turn on the light", "TkN nN jc LiT"},
  {0, "Switch on the light", "SWgp nN jc LiT"},
  {1, "Turn off the light", "TkN eF jc LiT"},
  {1, "Switch off the light", "SWgp eF jc LiT"},
  {1, "Go dark", "Gb DnRK"},
  {2, "Start fan", "STnRT FaN"},
  {3, "Stop fan", "STnP FaN"},
};

void onSrEvent(sr_event_t event, int command_id, int phrase_id) {
  switch (event) {
    case SR_EVENT_WAKEWORD: Serial.println("WakeWord Detected!"); break;
    case SR_EVENT_WAKEWORD_CHANNEL:
      Serial.printf("WakeWord Channel %d Verified!\n", command_id);
      ESP_SR.setMode(SR_MODE_COMMAND);  // Switch to Command detection
      break;
    case SR_EVENT_TIMEOUT:
      Serial.println("Timeout Detected!");
      ESP_SR.setMode(SR_MODE_WAKEWORD);  // Switch back to WakeWord detection
      break;
    case SR_EVENT_COMMAND:
      Serial.printf("Command %d Detected! %s\n", command_id, sr_commands[phrase_id].str);
      switch (command_id) {
        case SR_CMD_TURN_ON_THE_LIGHT:  digitalWrite(LIGHT_PIN, HIGH); break;
        case SR_CMD_TURN_OFF_THE_LIGHT: digitalWrite(LIGHT_PIN, LOW); break;
        case SR_CMD_START_FAN:          digitalWrite(FAN_PIN, HIGH); break;
        case SR_CMD_STOP_FAN:           digitalWrite(FAN_PIN, LOW); break;
        default:                        Serial.println("Unknown Command!"); break;
      }
      ESP_SR.setMode(SR_MODE_COMMAND);  // Allow for more commands to be given, before timeout
      // ESP_SR.setMode(SR_MODE_WAKEWORD); // Switch back to WakeWord detection
      break;
    default: Serial.println("Unknown Event!"); break;
  }
}

void setup() {
  Serial.begin(115200);

  pinMode(LIGHT_PIN, OUTPUT);
  digitalWrite(LIGHT_PIN, LOW);
  pinMode(FAN_PIN, OUTPUT);
  digitalWrite(FAN_PIN, LOW);

  i2s.setPins(I2S_PIN_BCK, I2S_PIN_WS, -1, I2S_PIN_DIN);
  i2s.setTimeout(1000);
  i2s.begin(I2S_MODE_STD, 16000, I2S_DATA_BIT_WIDTH_16BIT, I2S_SLOT_MODE_STEREO);

  ESP_SR.onEvent(onSrEvent);
  ESP_SR.begin(i2s, sr_commands, sizeof(sr_commands) / sizeof(sr_cmd_t), SR_CHANNELS_STEREO, SR_MODE_WAKEWORD);
}

void loop() {}

I have downloaded the libraries from the github repository, latest version of the esp32 core.

Maybe start with basic sketches to make sure you know how to do an upload, and that the right drivers are installed, etc.

Yes, I already done that

Have you also checked that the Boards 3 migration isn't an issue?

You have a runtime error you need to handle. I don't know the lingo, but you need to provide an exception handler where you can place some debug prints.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.