3. TEDDY BEAR
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. Its cute as
can be (Figure
E
) and, after removing the heating
pad from its insides, it has just enough space for
all the electronics (Figure
F
). It is quite a fiddly
job to get everything to fit, but once done, it does
look adorable!
This step is very much optional — you can put
these electronics in any vessel you like.
BEAR IS A FOUR-LETTER WORD
To test your Swear Bear, power up the Raspberry
Pi and run the Python script. The bear will
announce, “The bear has awoken.” (We gave it a
proper British accent but you can change this in
the AIY Voice setup.)
Start speaking. The bear now listens to
everything you say, converts your speech to text,
analyzes it for any trace of profanity, and makes
sure there’s a very public record by publishing the
data to its ThingSpeak channel. Drop an F-bomb
and not only will the bear give you a stiff “Oh
dear,but everyone in the world will be able to
know about it.
DEEPER LEARNING: Profanity Shaming Bear
# Listen and recognize
print('Listening...')
spokenText = cloudClient.recognize()
print(spokenText)
# Check if anything was said
if spokenText is not None:
# Lets assume the best
profanity = False
# Secret data voice module console validator!
if spokenText.lower() == 'bears suck':
profanity = True
getStats()
# It happened, profanity!
if predict([str(spokenText)]):
say('Oh dear!')
profanity = True
# Now the cloud must know!
sendData(profanity, spokenText)
42 makercampus.com
E F
8 Bits and a Byte
M77_038-43_SS_SwearBear_F1.indd 42M77_038-43_SS_SwearBear_F1.indd 42 4/11/21 1:36 PM4/11/21 1:36 PM
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.216.32.116