Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

micro_speech example not detecting YES/NO on esp32-s3 Zero (TFMIC-44) #101

Open
3 tasks done
bibidentuhanoi opened this issue Nov 29, 2024 · 0 comments
Open
3 tasks done

Comments

@bibidentuhanoi
Copy link

Checklist

  • Checked the issue tracker for similar issues to ensure this is not a duplicate
  • Read the documentation to confirm the issue is not addressed there and your configuration is set correctly
  • Tested with the latest version to ensure the issue hasn't been fixed

How often does this bug occurs?

always

Expected behavior

I expected it to detect "Yes" or "No" when I spoke into the i2s mic

Actual behavior (suspected bug)

It kept it printing out: Detected unknown even when there was no sound.

Error logs or terminal output

I (26) boot: ESP-IDF v5.3.1 2nd stage bootloader
I (27) boot: compile time Nov 29 2024 21:32:40
I (27) boot: Multicore bootloader
I (30) boot: chip revision: v0.2
I (34) qio_mode: Enabling default flash chip QIO
I (39) boot.esp32s3: Boot SPI Speed : 80MHz
I (44) boot.esp32s3: SPI Mode       : QIO
I (48) boot.esp32s3: SPI Flash Size : 2MB
I (53) boot: Enabling RNG early entropy source...
I (58) boot: Partition Table:
I (62) boot: ## Label            Usage          Type ST Offset   Length
I (69) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (77) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (84) boot:  2 factory          factory app      00 00 00010000 00100000
I (92) boot: End of partition table
I (96) esp_image: segment 0: paddr=00010020 vaddr=3c050020 size=16bd0h ( 93136) map
I (118) esp_image: segment 1: paddr=00026bf8 vaddr=3fc91b00 size=02934h ( 10548) load
I (121) esp_image: segment 2: paddr=00029534 vaddr=40374000 size=06ae4h ( 27364) load
I (130) esp_image: segment 3: paddr=00030020 vaddr=42000020 size=440fch (278780) map
I (175) esp_image: segment 4: paddr=00074124 vaddr=4037aae4 size=06fc8h ( 28616) load
I (186) boot: Loaded app from partition at offset 0x10000
I (187) boot: Disabling RNG early entropy source...
I (199) cpu_start: Multicore app
I (208) cpu_start: Pro cpu start user code
I (208) cpu_start: cpu freq: 160000000 Hz
I (208) app_init: Application information:
I (211) app_init: Project name:     micro_speech
I (216) app_init: App version:      1
I (220) app_init: Compile time:     Nov 29 2024 21:31:12
I (226) app_init: ELF file SHA256:  5fb3635e6...
I (232) app_init: ESP-IDF:          v5.3.1
I (236) efuse_init: Min chip rev:     v0.0
I (241) efuse_init: Max chip rev:     v0.99
I (246) efuse_init: Chip rev:         v0.2
I (251) heap_init: Initializing. RAM available for dynamic allocation:
I (258) heap_init: At 3FCAAAF8 len 0003EC18 (251 KiB): RAM
I (264) heap_init: At 3FCE9710 len 00005724 (21 KiB): RAM
I (270) heap_init: At 3FCF0000 len 00008000 (32 KiB): DRAM
I (277) heap_init: At 600FE100 len 00001EE8 (7 KiB): RTCRAM
I (284) spi_flash: detected chip: generic
I (288) spi_flash: flash io: qio
W (291) spi_flash: Detected size(4096k) larger than the size in the binary image header(2048k). Using the size in the binary image header.
W (305) i2s(legacy): legacy i2s driver is deprecated, please migrate to use driver/i2s_std.h, driver/i2s_pdm.h or driver/i2s_tdm.h
I (317) sleep: Configure to isolate all GPIO pins in sleep state
I (324) sleep: Enable automatic switching of GPIO sleep configuration
I (331) main_task: Started on CPU0
I (341) main_task: Calling app_main()
I (361) feature_provider: InitializeMicroFeatures successful
I (391) TF_LITE_AUDIO_PROVIDER: Audio Recording started
Detected unknown, score: 0.87
Detected unknown, score: 0.95
Detected unknown, score: 0.88
Detected unknown, score: 0.93
Detected unknown, score: 0.95
Detected unknown, score: 0.90
Detected unknown, score: 0.85
Detected unknown, score: 0.89
Detected unknown, score: 0.96
Detected unknown, score: 0.99

Steps to reproduce the behavior

1.Download this example via vs-code esp-idf extension component menu
2. change the i2s pin config
3. compile and flash it

Project release version

1.3.2

System architecture

Intel/AMD 64-bit (modern PC, older Mac)

Operating system

Windows

Operating system version

Window 11

Shell

PowerShell

Additional context

I was using the INMP441 Microphone Module and tried to make the example work by changing the i2s pin config in the audio_provider.cc here is what I have changed:

#define I2S_WS 3
#define I2S_SD 1
#define I2S_SCK 2
i2s_pin_config_t pin_config = {
     .bck_io_num = I2S_SCK,
     .ws_io_num = I2S_WS,
     .data_out_num = -1,
     .data_in_num = I2S_SD};

but after compiling and flashing it I have a problem like above. at first I though I have wiring problem but after checking with this code from dronebotworkshop, I can confirm the microphone is fine:

// Include I2S driver
#include <driver/i2s.h>

// Connections to INMP441 I2S microphone
#define I2S_WS 3
#define I2S_SD 1
#define I2S_SCK 2

// Use I2S Processor 0
#define I2S_PORT I2S_NUM_0

// Define input buffer length
#define bufferLen 64
int16_t sBuffer[bufferLen];

void i2s_install() {
  // Set up I2S Processor configuration
  const i2s_config_t i2s_config = {
    .mode = i2s_mode_t(I2S_MODE_MASTER | I2S_MODE_RX),
    .sample_rate = 44100,
    .bits_per_sample = i2s_bits_per_sample_t(16),
    .channel_format = I2S_CHANNEL_FMT_ONLY_LEFT,
    .communication_format = i2s_comm_format_t(I2S_COMM_FORMAT_STAND_I2S),
    .intr_alloc_flags = 0,
    .dma_buf_count = 8,
    .dma_buf_len = bufferLen,
    .use_apll = false
  };

  i2s_driver_install(I2S_PORT, &i2s_config, 0, NULL);
}

void i2s_setpin() {
  // Set I2S pin configuration
  const i2s_pin_config_t pin_config = {
    .bck_io_num = I2S_SCK,
    .ws_io_num = I2S_WS,
    .data_out_num = -1,
    .data_in_num = I2S_SD
  };

  i2s_set_pin(I2S_PORT, &pin_config);
}

void setup() {

  // Set up Serial Monitor
  Serial.begin(115200);
  Serial.println(" ");

  delay(1000);

  // Set up I2S
  i2s_install();
  i2s_setpin();
  i2s_start(I2S_PORT);


  delay(500);
}

void loop() {

  // False print statements to "lock range" on serial plotter display
  // Change rangelimit value to adjust "sensitivity"
  int rangelimit = 3000;
  Serial.print(rangelimit * -1);
  Serial.print(" ");
  Serial.print(rangelimit);
  Serial.print(" ");

  // Get I2S data and place in data buffer
  size_t bytesIn = 0;
  esp_err_t result = i2s_read(I2S_PORT, &sBuffer, bufferLen, &bytesIn, portMAX_DELAY);

  if (result == ESP_OK)
  {
    // Read I2S data buffer
    int16_t samples_read = bytesIn / 8;
    if (samples_read > 0) {
      float mean = 0;
      for (int16_t i = 0; i < samples_read; ++i) {
        mean += (sBuffer[i]);
      }

      // Average the data reading
      mean /= samples_read;

      // Print to serial plotter
      Serial.println(mean);
    }
  }
}

image

@github-actions github-actions bot changed the title micro_speech example not detecting YES/NO on esp32-s3 Zero micro_speech example not detecting YES/NO on esp32-s3 Zero (TFMIC-44) Nov 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant