ARM-software / ML-KWS-for-MCU

Keyword spotting on Arm Cortex-M Microcontrollers
Apache License 2.0
1.14k stars 417 forks source link

how to generate new input wav_data.h #21

Closed fabiovito closed 6 years ago

fabiovito commented 6 years ago

Hi, how can i generate a new input audio example "wav_data.h"? thanks.

navsuda commented 6 years ago

Hi @fabiovito, wav_data.h consists of raw audio data in 16-bit format. You can read the .wav file in python and write to .h file. The following code should work fine.

import wave audio = wave.open("your wav file") signal = audio.readframes(-1) signal = np.fromstring(signal, 'Int16') with open("wav_data.h",'ab') as f: np.savetxt(f,signal,fmt="%d",delimiter=",",newline=",")

gamnes commented 6 years ago

Hi @navsuda, would you be able to provide some more wav_data.h files to use for testing with the simple_test example? And what should the output of the default wav_data.h file be? Thanks:)

navsuda commented 6 years ago

Hi @gamnes, The output with default wav_data.h is "right". With the provided python script, you should be able to generate any number of examples by providing any audio file from the speech commands dataset.

navsuda commented 6 years ago

Closing the issue due to inactivity, please reopen it if you still face the issue.