This application uses the on-board MEMS microphone to collect audio samples, analyze them using a pre-trained neural network and send their classification on the serial port. A desktop python script takes care of reading the results.
- STM32F4 Discovery board (project has been developed using STM32F407VGT6)
- For sound clasification (normal usage):
- Python 3. You can check your version with
python --V
- pyserial:
pip install pyserial
- A RS232-USB cable
- Python 3. You can check your version with
- For neural network training:
- Python 3, pyserial and RS232-USB cable as in previous case
- Keras 2.2.4:
pip install keras==2.2.4
- Tensorflow 2.0.0-alpha0:
pip install tensorflow==2.0.0-alpha0
- GCC
- For pre-trained Keras model to C conversion:
- STMCubeMX
- X-CUBE-AI: can be installed from within STMCubeMX
- For embedded software compilation:
- Miosix toolchain
- GNU ARM embedded toolchain (just for the linker)
- For sound classification (normal usage):
- Connect the serial cable pins to PA2 (board TX) and PA3 (board RX)
- Connect the board through USB cable
- Launch the client with
python client.py serial_port_name
, replacingserial_port_name
with the name of the serial port (i.e /dev/tty, COM1) - Press the board user button, do the desired sounds and press again the button to stop recording
- For neural network training:
- Compile the FFT extraction program with
gcc FFT_extract.c -o FFT_extract
- Connect the cables as in previous case
- Launch the FFT reciever with
python FFT_receive.py serial_port_name
- Press the user button, do the desired sounds and press again the button to stop recording
- The results will be in the file
fft.csv
. They must be manually classified according to what they are: one last column has to be added and it must contain value 0 for silence, 1 for whistle or 2 for clap - Go into the
neural-network
folder, place the new data intraining_data.csv
and runpython trainer.py
. The pre-trained model will output to filemodel.h5
- Compile the FFT extraction program with
- For pre-trained Keras model to C library conversion: everything is explained in the
docs/x-cube-ai.pdf
file, provided by ST. - For embedded software compilation: use command
make
in themiosix-kernel
folder or compile using your preferred CMake compatible IDE