The offline recognition part in TensorflowJS readme mentions that we need to "obtain the spectrogram of an audio snippet through a certain means, e.g., by loading the data from a .wav file or synthesizing the spectrogram programmatically".
Can anyone please explain how to obtain spectrogram from wav file in javascript? I am unable to find a way.
To further explain, I'll show what I did and what the problem is:
let buffer = fs.readFilSync('zero1.wav');
let input = wav.decode(buffer);
# To make size of input equal to 9976 as per the restrictions of TensorflowJS i.e.
# (1,43,232): 1*43*232 = 9976 in size
input = input['channelData'][0].slice(1000, 10976)
const x = tf.tensor(inp, [1].concat(recognizer.modelInputShape().slice(1)));
const output = await recognizer.recognize(x);
When using the above (And note that zero1.wav is a file obtained from the training data, so should give high accuracy output), I am getting the following ambiguous output -
This only means that the input to the recognizer.recognize() is incorrect.
So, how should I convert my wav file to spectrogram and input it to recognizer.recognize() ?
Please let me know if any clarification is required. Any help is appreciated