Skip to content

Instantly share code, notes, and snippets.

@Im0rtality
Created November 22, 2015 13:29
Show Gist options
  • Save Im0rtality/92106b2c7a382598af59 to your computer and use it in GitHub Desktop.
Save Im0rtality/92106b2c7a382598af59 to your computer and use it in GitHub Desktop.
#!/bin/sh
# pass dir name of bin files as parameter
for file in $1*.bin.txt
do
letter=`echo $file | awk -F. '{print $1}'| awk -F/ '{print $2}'`
cat $file | sed "1d;$ d" | sort -r | awk -v OFS=', ' '{$1=""; $15="'$letter'"; print $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15}'
# to limit samples per class use line below instead
# cat $file | sed "1d;$ d" | sort -r | head -n 2000 | awk -v OFS=', ' '{$1=""; $15="'$letter'"; print $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15}'
done
#!/bin/sh
# pass filename of WAV file as 1st param
# vectorize WAV
HCopy -T 1 -C bin/config.txt $1 $1.bin
# convert to text file
HList -i 13 $1.bin > $1.bin.txt
# convert to CSV
cat $1.bin.txt | sed "1d;$ d" | awk -v OFS=', ' '{$1=""; print $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14}' > $1.csv
# cleanup temp files
rm $1.bin $1.bin.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment