Skip to content

htm-community/nupic.critic

Repository files navigation

Requirements

Get anomalies from audio input in 3 easy steps!

NuPIC Critic plot screenshot

1. Generate NuPIC Input From WAV

./convert_wav.py <path/to/wav>

There are several options for this, which you can see with the --help flag. You can control the FFT histogram sample rate, the number of histogram buckets, and the output directory where the file is written.

The resulting folder contains files formatted for NuPIC model input.

Options

  • --buckets,-b: [default 10] Number of frequency buckets to split the input when applying the FFT.
  • --sample-rate,-s: [default 5] How many samples to take per second.
  • --output_directory,-o: [default "output"] Directory to write the NuPIC input files.
  • --verbose,-v: [default False] Print debugging statements.
  • --loop,-l: [default 1] How many times to loop the WAV file (for reinforcing a pattern in NuPIC while training).
  • --plot,-p: [default False] Plot WAV spectrogram in matplotlib instead of writing NuPIC input files.

2. Run NuPIC

./run.py <path/to/input/directory> [options]

Runs all the prepared data in the input directory. Expects this directory to have been created by the convert_wav.py script above.

  • --model_params,-m: [default "grok_anomaly"] Name of the model params to use (without the '_model_params.py'). You won't need to set this unless you really know what you are doing.
  • --plot,-p: [default False] Plots the output instead of writing to file.
  • --verbose,-v: [default False] Print debugging statements.
  • --save,-s: [default False] Will checkpoint the model after running so it can be reused later.
  • --resurrect,-r: [default False] Uses specified model checkpoint instead of creating a new model using the model parameters. Learning will be automatically disabled on this model.

3. Plot the Results

./plotter.py <path/to/nupic/output/directory> [options]

Plots the results. Use --wav to pass in a WAV file to play at the same time. There are several options for this, which you can see with the --help flag.

  • --wav,-w: [default None] Path to a WAV file to play synced to the plot.
  • --maximize,-m: [default False] Maximize plot window.
  • --use_anomaly_score,-a: [default False] Use the anomalyScore from NuPIC instead of the anomalyLikelihood.
  • --anomaly_threshold,-t: [default 0.9] Value the anomaly likelihood(s) must breach before being marked as anomalous in the chart.

As an example, if you would like to flag a region as anomalous if the NuPIC anomaly likelihoods for 5 frequency bins are above 0.8, you would use the following options:

./plotter.py path/to/nupic/output -t 0.8 -g 5

Live Demo on YouTube

Notes

Could be applicable to this heart sound challenge.

About

Music critic hack from 2014 Spring Hackathon

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •