The AI Dictionary Book
From the outside, it's just an old hardcover book sitting on a shelf. Press its bookmark button, hold up an apple, a bottle, or a pair of scissors, and it looks the object over, speaks its name and a simple meaning out loud, and prints both on a tiny glowing screen tucked into the cover.
A dictionary that looks things up for you
This AI Dictionary Book hides a real Raspberry Pi Camera in the spine of an old hollowed-out hardcover book, along with a small screen and speaker built right into the cover. Press its look-up button, and an onboard AI model figures out what object you're holding up, then both speaks and displays the word's name and a short, simple meaning — like a dictionary that does the looking-up for you. Everything runs locally on the Raspberry Pi, so it's a great hands-on project for learning about cameras, on-device object recognition, simple databases of definitions, and giving an ordinary object a second life as an electronics build.
What you'll need
This project uses a Raspberry Pi as the brain, a handful of common electronics parts, and one good book you don't mind repurposing.
Electronics
- 1x Raspberry Pi 4 (2GB or more)
- 1x Raspberry Pi Camera Module (v2 or v3)
- 1x 1.3" I2C OLED display (SH1106 or SSD1306)
- 1x push button (the "look-up" button)
- 1x MAX98357A I2S amplifier + small speaker
- 5V/3A USB-C power supply
- MicroSD card (16GB or more)
- Jumper wires and a small perfboard
Book & enclosure
- 1x large hardcover book, bought specifically to repurpose
- Craft knife and a metal ruler
- PVA glue (to stiffen the hollowed pages)
- A small strip of ribbon or fabric for the bookmark button
- Foam board offcuts to support the electronics inside
Software
- Raspberry Pi OS (64-bit)
- Python 3 with picamera2 and OpenCV
- tflite-runtime
- A pretrained TFLite object detection model (COCO SSD MobileNet)
- pyttsx3 for offline text-to-speech
How the book "knows" what it's looking at
There's no internet lookup involved — a small pretrained AI model already knows the shape of about 90 everyday objects, and a tiny built-in dictionary supplies the simple definitions.
Press the button
Pressing the look-up button tells the Raspberry Pi to capture a fresh photo right now, instead of scanning constantly.
The AI names it
A small pretrained model compares the photo to shapes it already knows and returns its best guess with a confidence score.
Look up the meaning
The code checks that word against a small built-in dictionary of simple definitions stored right on the Pi.
Show and tell
The word and its meaning appear on the OLED screen while the speaker reads both out loud.
Circuit diagram
Everything connects straight to the Raspberry Pi's own camera port, I2C pins, one GPIO pin for the button, and its I2S pins for sound — no extra microcontroller needed.
Step-by-step build instructions
Prepare the book first, then wire the electronics, then get the software working — test each part before gluing anything down for good.
Hollow out the book
Glue the outer pages together in batches, let them dry, then cut a rectangular cavity deep enough to hold the Raspberry Pi and wiring.
Cut the camera opening
Cut a small hole near the top edge of the book, angled so the camera can see objects placed on the table in front of it.
Cut the OLED window
Cut a neat rectangular window in the front cover sized to fit the OLED screen, and glue the screen in place from behind.
Mount the look-up button
Fix the push button on the cover like a little bookmark tab, with its ribbon poking out for an easy press.
Place the speaker
Tuck the small speaker and its amplifier board inside the back cover, facing a few small holes cut for sound to escape.
Wire everything to the Raspberry Pi
Connect the camera, OLED, button, and speaker amplifier following the circuit diagram above.
Set up the Raspberry Pi
Flash Raspberry Pi OS onto the SD card, then enable the Camera and I2C and I2S interfaces using raspi-config.
Install the software
Install picamera2, OpenCV, tflite-runtime, and pyttsx3, then download a pretrained TFLite object detection model and its label file.
Add the dictionary
Add a simple definition for each object you want it to explain, following the pattern in the code below.
Test the full device
Run the complete script and test it on an apple, a book, a bottle, and a pair of scissors, pressing the button each time.
Close it up
Once everything works reliably, tidy the wiring inside and close the book's cavity for good, leaving the button, screen, and camera accessible.
The code
This Python script waits for a button press, captures a photo, identifies the object, looks up a simple meaning, and shares both out loud and on screen.
# AI Dictionary Book - Raspberry Pi # Press the button to identify an object and hear its name and meaning import time import numpy as np import cv2 from picamera2 import Picamera2 import tflite_runtime.interpreter as tflite import pyttsx3 from board import SCL, SDA import busio from adafruit_ssd1306 import SSD1306_I2C from PIL import Image, ImageDraw, ImageFont from gpiozero import Button # ---------- Look-up button ---------- lookup_button = Button(17, pull_up=True, bounce_time=0.05) # ---------- OLED screen ---------- i2c = busio.I2C(SCL, SDA) oled = SSD1306_I2C(128, 64, i2c) def show_text(lines): image = Image.new("1", (oled.width, oled.height)) draw = ImageDraw.Draw(image) font = ImageFont.load_default() y = 0 for line in lines: draw.text((0, y), line, font=font, fill=255) y += 12 oled.image(image) oled.show() def show_idle(): show_text(["AI Dictionary", "Press the button", "to look something", "up!"]) # ---------- Offline mini dictionary ---------- # Add more words here any time you like dictionary = { "apple": "A round fruit that grows on trees and is good to eat.", "book": "Pages of words or pictures bound together for reading.", "bottle": "A container with a narrow neck used for holding liquid.", "scissors": "A tool with two blades used for cutting paper or fabric.", } def lookup(word): return dictionary.get(word, "I know the name, but not its meaning yet.") # ---------- Offline text-to-speech ---------- tts = pyttsx3.init() def speak(word, meaning): tts.say(word + ". " + meaning) tts.runAndWait() # ---------- Load the pretrained object detection model ---------- interpreter = tflite.Interpreter(model_path="detect.tflite") interpreter.allocate_tensors() input_details = interpreter.get_input_details() output_details = interpreter.get_output_details() height, width = input_details[0]['shape'][1:3] with open("labelmap.txt") as f: labels = [line.strip() for line in f.readlines()] # ---------- Camera ---------- picam2 = Picamera2() picam2.configure(picam2.create_preview_configuration(main={"size": (640, 480)})) picam2.start() def wrap(text, width_chars=18): words = text.split() lines, current = [], "" for w in words: if len(current) + len(w) + 1 <= width_chars: current = (current + " " + w).strip() else: lines.append(current) current = w if current: lines.append(current) return lines def look_up_object(): frame = picam2.capture_array() img = cv2.resize(frame, (width, height)) input_data = np.expand_dims(img, axis=0) interpreter.set_tensor(input_details[0]['index'], input_data) interpreter.invoke() classes = interpreter.get_tensor(output_details[1]['index'])[0] scores = interpreter.get_tensor(output_details[2]['index'])[0] best_score, best_label = 0, None for i in range(len(scores)): if scores[i] > best_score: best_score = scores[i] best_label = labels[int(classes[i])] if best_score > 0.6 and best_label: meaning = lookup(best_label) show_text([best_label.upper()] + wrap(meaning)) speak(best_label, meaning) else: show_text(["Hmm, I couldn't", "recognize that.", "Try again!"]) print("Dictionary ready. Press the button to look something up!") show_idle() while True: lookup_button.wait_for_press() show_text(["Looking..."]) look_up_object() time.sleep(2) show_idle()
dictionary, or, once you're comfortable, connect the Pi to Wi-Fi and swap lookup() for a call to a free online dictionary API so it can define almost any word it recognizes.⚡ Safety first
- Ask an adult to help with cutting the book pages and any wiring or soldering.
- Use a book bought specifically for crafting, never a borrowed or library book.
- Always shut down the Raspberry Pi properly and unplug it before changing any wiring.
- Let the glued pages dry fully before cutting, so the cavity holds its shape safely.
- Everything runs locally on the Pi with no cloud connection needed for recognition — good for privacy.
Frequently asked questions
Does it know the meaning of every word it recognizes?
Only the ones you've added to its built-in dictionary. It's easy to add more definitions any time, and there's a note in the code about connecting it to an online dictionary later if you want it to know almost any word.
Do I need a special book?
No — any sturdy hardcover book works well, as long as it's one you're happy to repurpose permanently.
Does it need an internet connection?
No. Object recognition, the dictionary, and the text-to-speech all run locally on the Raspberry Pi.
Which Raspberry Pi model works best?
A Raspberry Pi 4 gives the smoothest recognition speed. A Raspberry Pi Zero 2 W can run it too, just a little slower.
Why does it sometimes get the object wrong?
Lighting, distance, and how much of the object fills the camera's view all affect accuracy — try holding items closer in good light, and adjust the confidence number in the code if needed.

Comments
Post a Comment