This project is inspired by the movie Demolition Man and the future society it envisions. The movie is set in the 2030's when crime has been completely eradicated inside a tightly controlled society. Swearing is a violation of the 'verbal morality statues' and its enforcement is done through monitoring devices mounted in each room. These verbal morality statute monitors are a running joke in the movie as characters use profanity and trigger violations. This project is an attempt to recreate the verbal morality statute monitor from Demolition Man.
For hardware, this project uses a Raspberry Pi model B running the latest version of the Raspbian OS. The model B Pi is preferred because it has multiple USB ports (good for connecting both a wifi chip, and USB microphone), however the project will likely also work on a model A Pi. Connected to the Raspberry Pi are a USB microphone, amplifier and speaker, thermal printer, a SPST toggle switch, and some red LEDs.
For software, the project source code is available on github here. Make sure to install the following dependencies using apt-get by executing:
sudo apt-get install build-essential autoconf libtool automake bison swig python-dev libasound2-dev gcc-4.7 g++-4.7 libasound2-dev
The swear detection is done using the PocketSphinx library, an excellent open source speech recognition engine. The in development next version of PocketSphinx has support for keyword spotting, which is the detection of certain keywords being uttered in everyday speech. You will need to download the subversion trunk of the library, compile, and install the SphinxBase and PocketSphinx subprojects on the Pi. You will also need to install the wiringPi library which is used to access GPIO pins on the Pi.
To compile the project, invoke 'make DemoManMonitor'. You can also invoke 'make runtests' to run a few unit tests for the code. Once the code is compiled you will need to make sure you have some speech model data available in the project directory. Create a folder called 'models' and copy in the appropriate models for your language from PocketSphinx's pocketsphinx\model directory. I copied in the hmm/en_US/hub4wsj_sc_8k folder, lm/en_US/cmu07a.dic, and
To connect the printer, connect the red and black power pins from the printer to power supply positive and ground respectively (do not try to power the printer from the Pi!). Connect the printer serial RX pin (yellow) to the TX pin on the Pi (GPIO 14). Leave the printer TX pin unconnected as it outputs 5V which is unsafe for the Pi RX pin to receive (and data doesn't need to be read from the printer in this application). Note when you power on the Pi the printer might start printing garbage so disconnect the RX pin on boot and connect it before running the software.
Connect the quiet mode switch to any GPIO pin on the Pi, I used wiring Pi pin 0 (which is Pi BCM pin 17). If using an SPST toggle switch, the middle pin goes to the GPIO pin, while one outer pin goes to 3.3V po