Skip to content

Instantly share code, notes, and snippets.

@neerajnagi
Last active July 11, 2016 06:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neerajnagi/f0d5c9bdbc2c53e0ac4c5ada5d0b7eed to your computer and use it in GitHub Desktop.
Save neerajnagi/f0d5c9bdbc2c53e0ac4c5ada5d0b7eed to your computer and use it in GitHub Desktop.
spectrum based gauge

directory structure

map.txt
1.wav,2.wav,.......

map.txt will contain label for each wav file

146583845232.wav, 0
1465838452998.wav, 1
1465838491413.wav, 1
1465838489799.wav, 0
....

R code will support two functions

##1) Training

Rscript main.R -train /path/to/sample_folder

description

this will do following step
1) read map.txt and group the wav files  in group 1 and group 0
2) maintain one list object per group
3) maintain meanspec vector of each wav in that list
4) dump the list objects in filesystem, in the sample_folder. Lets say rDump is its name.

##2) Prediction

Rscript main.R -predict /path/to/xyz.wav

description

this will do following step
1) read list object from rDump(filesystem) 
2) create meanspec vector of xyz.wav.
3) within each group correlate xyz.wav's meanspec vector.
4) take 90percentile value of those values in each group
5) whichever group has highest value, declare that as prediction.
@neerajnagi
Copy link
Author

meanspec parameters

ovlp=0, from=0 ,to=5 , wn="hanning" , wl=4096

newwave

use median

@neerajnagi
Copy link
Author

multi class version

directory structure

map.txt
1.wav,2.wav,.......

map.txt will contain label for each wav file

146583845232.wav, 0
1465838452998.wav, 0
1465838491413.wav, 1
1465838489799.wav, 1
1465838452325.wav, 2
1465838432998.wav, 2
1465838671413.wav, 3
1465838488999.wav, 3
....

R code will support two functions

1) Training

Rscript main.R -train /path/to/sample_folder

description

this will do following step
1) read map.txt and group the wav files  in N distinct groups
2) maintain one list object per group
3) maintain meanspec vector of each wav in that list
4) dump the vector/arrray/list of  list objects in filesystem, in the sample_folder. Lets say rDump is its name. In first version we dumped 1.rds and 2.rds ,  this time lets not dump classwise instead use maybe vector or array or list of  list objects, whichever is suitable.

2) Prediction

Rscript main.R -predict /path/to/xyz.wav

description

this will do following step
1) read list objects from rDump(filesystem) 
2) create meanspec vector of xyz.wav.
3) within each group correlate xyz.wav's meanspec vector.
4) take 90percentile value of those values in each group
5) whichever group has highest value, declare that as prediction.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment