A machine learning program for human laughter detection.
- Install Python 3.4.3 or later
- Install Python's SciPy package and related NumPy package
- If using Windows, access NumPy and SciPy wheels here
- Note your version of Python and architecture (i.e., 32-bit v. 64-bit)
- Install WEKA
- Run main.py under the python-training folder
- In the GUI, click "Browse" next to "File with laughter audio file names"
- Select the file containing a series of paths to laughter training files
- Click "Browse" next to "File with non-laughter audio file names"
- Select the file containing a series of paths to non-laughter training files
- Click "Prepare" to generate a wekaFile.arff file within the same directory as main.py
- Run WEKA using the following command:
java -Xmx512m -classpath /location/of/weka/jar/weka.jar weka.gui.GUIChooser
- In the GUI, click the "Explorer" button
- Under the "Preprocess" tab, click the "Open file..." button
- Select the wekaFile.arff file generated earlier
- Under the "Classify" tab, select "Choose" under "Classifier"
- To use K-nearest neigbors algorithm: under "lazy", select "IBk"
- Press "Start"
- After the classification is finished, right-click the output in "Result List" and click "Save Model"
- Run main.py under the python-testing folder
- Include the following params:
--phase 0
; for testing algorithm--audio /path/to/audio.wav
; the audio file you want to examine- .wav files only, not 24 bit depth (limitation of SciPy)
--arff /path/to/arff/result.arff
; the result .arff file from training
- Change file paths in Constants.java accordingly, relative to the values of your machine
- Compile and run the WavReader main class (include the weka.jar to your classpath)
- Run the main Java file
- In the GUI, select the audio file containig the laughter segments to be identified
- Click the "Get Laughter Segments" button
- You will be presented with a series of snippets identified as laughter, select each one that is correctly identified
- Click the retrain model process
- The re-trained model will be placed in the same directory as the old model (see Constants.java)
If you are using a Macintosh, you can install ffmpeg
using Homebrew
brew install ffmpeg
Using that application, you can do the following:
-
Split a wav file into segments
ffmpeg -i audio.wav -f segment -segment_time 0.5 -c copy parts/out%03d.wav
-
Find the exact duration of a wav file
ffmpeg -i audio.wav 2>&1 | grep Duration | awk '{print $2}' | tr -d ,
-
Cut for a given duration of a wav file
ffmpeg -i audio.wav -ss 00:00:07.100 -t 00:00:01.1 audio.wav
-
Convert .mp4 to .wav
ffmpeg -i sourcefile.mp4 destination.wav