How omwanere/image-to-speech-transcript works
Project Type and Purpose
• This is a Python-based embedded application that:
• Captures an image via USB webcam or mobile-phone IP stream
• Performs OCR on the image (pytesseract + Tesseract engine)
• Converts extracted text to speech (espeak)
• Is triggered and controlled by a GPIO-connected physical button
File Structure
• Top-level scripts:
• Image_To_Speech_Transcript_Webcam.py (USB webcam variant)
• Image_To_Speech_Transcript.py (mobile-stream variant)
• Support assets:
• images/ (for documentation screenshots)
• No submodules or separate “src” folders—everything runs in a single runtime process.
Extract Key Architecture Insights from README
• Dual camera inputs: local USB webcam vs remote IP stream
• Shared workflow:
1. Wait for button press
2. Start live preview
3. On next button press, capture image → OCR → clean text → TTS
• Mobile-stream version adds: image preprocessing (resize, grayscale, filtering) + text cleaning
Main Components & Their Interactions
a. Hardware Layer
• Button (GPIO input on Raspberry Pi)
• Camera(s):
• USB Webcam (cv2.VideoCapture(0))
• Mobile-phone IP stream (cv2.VideoCapture(“http://<ip>:<port>/video”))
• Speaker or audio output device (for espeak)
b. Software Modules (all running on the Raspberry Pi)
1. GPIO Controller
• Sets up BUTTON_PIN, listens for presses
2. Preview Module
• Initializes camera stream, displays live feed via OpenCV window
3. Module
• Grabs a single frame, saves it as captured_image.jpg
4. (Mobile only) Preprocessing Module
• Resizes, converts to grayscale, applies filters, adaptive thresholding
5. OCR Module
• Calls pytesseract.image_to_string (with optional config flags)
6. Text Cleaning Module (Mobile only)
• Regex to strip special characters
7. TTS Module
• Invokes espeak with given voice and speed parameters
c. External Dependencies
• Tesseract OCR engine + language data
• IP Webcam mobile app (for mobile-stream variant)
Architectural Patterns & Principles
• Single‐threaded sequential workflow triggered by hardware interrupt (button press)
• Clear separation of concerns in code: input acquisition → processing → output
• Reuse of common functions across both scripts (capture_image, text_to_speech)
• Configurable parameters (BUTTON_PIN, IP/port, TTS voice/speed, OCR language)