NiclaVision micro_speech example not working

I got the following problem when trying the micro_speech.py example code:

Traceback (most recent call last):
  File "<stdin>", line 20, in <module>
  File "ml/apps.py", line 52, in __init__
  File "ml/model.py", line 36, in __init__
OSError: [Errno 19] ENODEV
OpenMV 5c5946a; MicroPython f71dd03d; Arduino Nicla Vision with STM32H747
import time
from ml.apps import MicroSpeech

def callback(label, scores):
    print(f'\nHeard: "{label}" @{time.ticks_ms()}ms Scores: {scores}')

speech = MicroSpeech()

speech.listen(callback=callback, threshold=0.70)

To resolve this issue I tried to manually load the MicroSpeech object with the “audio_preprocessor.tflite” and “model.tflite”:

import time
from ml.apps import MicroSpeech
from ml.model import Model

def callback(label, scores):
    print(f'\nHeard: "{label}" @{time.ticks_ms()}ms Scores: {scores}')

speech = MicroSpeech(preprocessor=Model("audio_preprocessor.tflite"),micro_speech=Model("model.tflite"),labels=["Yes", "No"])

speech.listen(callback=callback, threshold=0.70)

What leaves me with the following error:

Traceback (most recent call last):
  File "<stdin>", line 9, in <module>
  File "ml/apps.py", line 95, in listen
IndexError: list index out of range
OpenMV 5c5946a; MicroPython f71dd03d; Arduino Nicla Vision with STM32H747

Here is the listen function from apps.py

def listen(self, timeout=0, callback=None, threshold=0.65, filter=["Yes", "No"]):
        self.start_audio_streaming()
        stat_ms = time.ticks_ms()
        while True:
            average_scores = np.mean(self.pred_history, axis=0)
            max_score_index = np.argmax(average_scores)
            max_score = average_scores[max_score_index]
            label = self.labels[max_score_index]                 # <---   line 95
            if max_score > threshold and label in filter:
                self.pred_history[:] = 0
                self.spectrogram[:] = 0
                if callback is None:
                    if timeout != -1:  # non-blocking mode
                        self.stop_audio_streaming()
                    return (label, average_scores)
                callback(label, average_scores)
            if timeout == -1:  # non-blocking mode
                return (None, average_scores)
            if timeout != 0 and (time.ticks_ms() - stat_ms) > timeout:
                self.stop_audio_streaming()
                return (None, average_scores)
            time.sleep_ms(1)

Ive already reset the firmware and the “audio_fft_1.py”-example works without problems.

I have no idea how I could approach this issue any further and would be happy if someone could help me out.

Fixed it by looking in the docs :sweat_smile:

import time
from ml.apps import MicroSpeech
from ml.model import Model

def callback(label, scores):
    print(f'\nHeard: "{label}" @{time.ticks_ms()}ms Scores: {scores}')

speech = MicroSpeech(preprocessor=Model("audio_preprocessor.tflite"),micro_speech=Model("model.tflite"), labels=["Silence","Unknown","Yes","No"])
speech.listen(callback=callback, threshold=0.8)