Introduction: The Swear Bear
Do you also swear too much?
Don't worry, this artificial intelligence powered, internet of things enabled swear jar is here to help!
How does it work?
Well, it listens to your every word and detects profanity (AI).
When caught, it instantly tells on you to a very public data stream (IoT), not only revealing the committed crime but also providing timestamped proof.
Supplies
Step 1: Project Video
Step 2: Hardware
It all starts with a Raspberry Pi, an AIY Voice kit and the LifePO4WERED Pi+. The Raspberry Pi orchestrates the data flow between the different platforms and provides computing power to our dirty language detection.
On top of our Raspberry Pi we add the LifePO4WERED Pi+, this module takes care of our power needs, and adds much appreciated portability.
Last but not least, we also add a Google AIY Voice Kit which supplies a microphone for recording and speakers for some interaction.
Both components have great support, here's guide on setting up the LifePO4WERED Pi+ and here's one on setting up the AIY Kit.
Step 3: AI and IoT
With all the hardware set up, we move on to the software.
To get the ball rolling, we first follow this guide on how to set up a custom voice interface using the AIY kit.
Next up, detecting profanity in the recorded text. Fortunately, a fantastic python library exists with, again, great documentation.
With the above all ready, we are now able to convert speech to text, and reliably catch any obscenity. This is a tremendous milestone, the artificial intelligence part is complete!
But, we also want to save all this data, and that's where ThingsSpeak comes to its own. As an open source Internet of Things platform it contains everything we need. It not only stores our results, but also allows for public sharing. And as luck would have it, they also have a superb tutorial.
Last not but least, just to make life a tad easier, you can find the full Python code in this article.
Attachments
Step 4: Bear
Looks can matter, and our creation should look as cute as it is evil.
And what better fit than a teddy bear? As luck would have it, we found a sweet little teddy waiting for us in the thrift store. It's cute as can be and, after removing the heating pad from its insides, it has a just enough space for all the electronics.
It is quite a fiddly job to get everything to fit, but once done, it does look absolutely adorable!
This step is very much optional, you can put these electronics in any vessel you like.
Step 5: Result
To test our great innovation, we activated it during filming, and the results are in!
You can browse all the data gathered during this 15 minute session right here.
And now, lets finish this questionable project with a fun fact:
28% of the recorded conversation contained profanity.
Well ****.

Runner Up in the
Battery Powered Contest
10 Comments
1 year ago
After reading about it in the latest issue of Make magazine, I'm trying this for the first time.
I've run into the following error when running the code with the most recent version of aiyprojects-raspbian (2021-04-02):
pi@aiyvoice1:~ $ python3 swearBearClean.py
/home/pi/.local/lib/python3.7/site-packages/scipy/__init__.py:140: UserWarning: A NumPy version >=1.16.5 and <1.23.0 is
required for this version of SciPy (detected version 1.16.2)
UserWarning)
RuntimeError: module compiled against API version 0xe but this version of numpy is 0xd
. . .
I'm not very familiar with Python, but it looks like the version of Numpy that is installed with raspbian (in the python3-numpy package) is too old for the version of Scipy that was installed when I ran "pip3 install profanity-check". I guess the version of Scipy installed by pip3 today is more recent than when the Swear Bear project was first created.
What would be the best way to fix this problem?
Reply 1 year ago
Yes, you're spot on, the library used is now les than working :)
There's a thread with somebody else running into the exact same issue:
https://www.hackster.io/8_Bits_and_a_Byte/the-swea...
To make life a little easier, here's the exact answer to your question :)
Did a bit of digging and it looks like we have two option:
https://rapidapi.com/collection/profanity-filter
Does this make any sense to you?
Cheers,
8 Bits
Reply 1 year ago
Hi,
Thanks for the reply.
Yes, that makes sense.
Since I have a limited vocabulary of swear words, I worked around the problem with profanity-check by replacing it with some hard-coded checks. I can't show the actual code on a family-friendly site, but something along the lines of:
if 'darn' in text:
you_swore = True
elif 'drat' in text:
you_swore = True
...
Crude (in both senses in the actual code), but effective.
The CloudSpeechClient's recognize API returns some unusual spellings for swear words ("daran" for "darn", say), so this approach has the advantage of correcting those misspellings and adding them to my swear tally. Gotta catch them all!
It occurred to me, though, that if I'm just looking for specific words then I can probably do the speech recognition offline on the Pi and avoid racking up charges from Google's Cloud Speech API. I haven't gone down that rabbit hole yet, since the cover story of that issue of Make Magazine raises the possibility of a Fart Detector, and one has to choose priorities.
Dan.
Reply 1 year ago
Sound like a very MacGyver-esk code solution, love it!
Keep up the creative solutions and ideas, makes the world a little more magical :)
2 years ago
Love this project!! Great job!
Reply 2 years ago
Thanks!
2 years ago
Awesome project, thanks for sharing!
Reply 2 years ago
Thanks, delighted to share :)
Question 2 years ago
That would be a great use for my teddy: @bear.fluffy
Do you think this also would work with different languages? Like Dutch.
Answer 2 years ago
Not quite sure, the python library seems to be trained on an English dataset. The Speech-To-Text doesn't work with Dutch just yet. The IoT service can save any language, as far as we know :)
It would be a delight to have an AI call people slappe pannekoek :)