h-yassin-ai/Kutub-Automator

0

stars

3

commits

Python

primary language

Jul 20, 2026

updated

README

Kutub Automator

An end-to-end multi-source data ingestion, speech-to-text (ASR), document OCR parsing, and text synthesis platform built with Python, PyTorch, NVIDIA NeMo, Hugging Face VLMs, and Gradio.

Kutub Automator automates the collection, document parsing, transcription, cleaning, and indexing of complex media streams and historical book scans.


🚀 Complete Feature Breakdown

1. 📥 Multi-Source Data Ingestion & Scraping

  • Telegram Channel Crawler (modules/telegram_scraper.py):

    • Asynchronous crawler built on Telethon for crawling target Telegram channels and groups.
    • Automated file discovery (Audio, Video, PDF scans) with workspace caching to eliminate duplicate downloads.
    • Interactive authentication workflow with phone code verification and persistent session management.
  • Facebook Video Downloader (modules/fb_downloader.js):

    • Node.js helper script for extracting video media streams from Facebook links.

2. 🎙️ High-Precision Arabic Speech-to-Text (ASR) Engine

  • NVIDIA NeMo Integration (modules/transcription_engine.py):
    • Local GPU inference using NVIDIA NeMo's stt_ar_fastconformer_hybrid_large_pc_v1.0 model.
    • Audio pre-processing pipeline powered by pydub, soundfile, and librosa.
    • Automatic audio splitting and chunking to handle multi-hour lectures without CUDA memory overflow.
    • Export capabilities for raw text, time-coded SRT subtitles, and structured JSON logs.

3. 📄 Document Parsing & Vision-Language OCR

  • PyMuPDF PDF Renderer (modules/unlimited_ocr.py):

    • Converts PDF document pages into high-DPI image caches on the fly using fitz (PyMuPDF).
    • Batch processing with safety caps (max 15 pages per batch) to prevent model hallucination.
  • Baidu Unlimited-OCR VLM Integration:

    • Runs Baidu's Unlimited-OCR Vision-Language Model locally in bfloat16 precision.
    • Live Token Streaming Patch: Custom monkey-patching of TPSTextStreamer for real-time live token streaming to the Gradio web UI.
    • Regex Cleaning Pipeline: Automatically strips VLM coordinate tags (<|det|>...<|/det|>), reference markers, and cleans page breaks.
  • Qari Arabic OCR Engine (modules/qari_ocr.py):

    • Specialized OCR fallback engine tailored for printed and historical Arabic text layouts.

4. 🔊 Text-To-Speech (TTS) Synthesis

  • Higgs TTS Engine (modules/higgs_tts.py):
    • Integrated speech synthesis module for generating audio output from transcribed text.

5. 🖥️ Interactive Control Center & System Engineering

  • Gradio Web Dashboard (app.py):

    • Unified web dashboard with tabbed interfaces for Telegram Scraping, Audio ASR, Unlimited-OCR, Qari OCR, and TTS.
  • Windows & System Stability Patches:

    • Low-level SSL context patching to bypass certificate errors on local networks.
    • Process-wide temporary directory file lock cleanup patches to prevent WinError 32 file locking on Windows.
    • High-precision logging with file and line tracking.

🛠️ System Architecture

graph TD
    subgraph Ingestion Layer
        A1[Telegram Channels] -->|Telethon Scraper| B[Workspace Download Cache]
        A2[Facebook Videos] -->|Node.js Downloader| B
        A3[Local PDF Scans & Audio] --> B
    end

    subgraph Processing Engine
        B -->|Audio Streams| C[Audio Splitter & Resampler]
        C --> D[NVIDIA NeMo FastConformer ASR]
        
        B -->|PDF Documents| E[PyMuPDF Renderer]
        E -->|Page Images| F[Baidu Unlimited-OCR VLM]
        E -->|Page Images| G[Qari OCR Engine]
        
        F --> H[Live Streamer Patch]
    end

    subgraph Post-Processing & Output
        D --> I[SRT Subtitles / Timed Logs]
        H --> J[Regex Tag Stripper & Text Normalizer]
        G --> J
        J --> K[Clean Text / Dataset Export]
        K -->|Optional| L[Higgs TTS Speech Synthesis]
    end

    subgraph User Interface
        M[Gradio Multi-Tab Web UI] <--> Ingestion Layer
        M <--> Processing Engine
        M <--> Post-Processing & Output
    end

💻 Tech Stack

  • Language: Python 3.10+
  • Deep Learning Frameworks: PyTorch (CUDA), Hugging Face Transformers, Accelerated Peft, Triton.
  • Specialized ML Toolkits: NVIDIA NeMo Toolkit (nemo_toolkit[asr]), Unsloth, Baidu Unlimited-OCR.
  • Document & Image Processing: PyMuPDF (fitz), Pillow, OpenCV, Librosa, SoundFile, Pydub.
  • Web UI & Networking: Gradio, Telethon (Telegram API), Requests, HTTPX, Node.js.

⚙️ Quick Start

  1. Clone the repository:

    git clone https://github.com/h-yassin-ai/Al-Kutub-Automator.git
    cd Al-Kutub-Automator
    
  2. Install dependencies:

    pip install -r requirements.txt
    
  3. Configure environment: Create a .env file in the project root:

    TG_API_ID=your_telegram_api_id
    TG_API_HASH=your_telegram_api_hash
    TG_PHONE=your_phone_number
    HF_TOKEN=your_huggingface_token
    
  4. Launch the dashboard:

    python app.py
    

Contributors

h-yassin-ai

3 commits

h-yassin-ai/Kutub-Automator

0

stars

3

commits

Python

primary language

Jul 20, 2026

updated

README

Kutub Automator

An end-to-end multi-source data ingestion, speech-to-text (ASR), document OCR parsing, and text synthesis platform built with Python, PyTorch, NVIDIA NeMo, Hugging Face VLMs, and Gradio.

Kutub Automator automates the collection, document parsing, transcription, cleaning, and indexing of complex media streams and historical book scans.


🚀 Complete Feature Breakdown

1. 📥 Multi-Source Data Ingestion & Scraping

  • Telegram Channel Crawler (modules/telegram_scraper.py):

    • Asynchronous crawler built on Telethon for crawling target Telegram channels and groups.
    • Automated file discovery (Audio, Video, PDF scans) with workspace caching to eliminate duplicate downloads.
    • Interactive authentication workflow with phone code verification and persistent session management.
  • Facebook Video Downloader (modules/fb_downloader.js):

    • Node.js helper script for extracting video media streams from Facebook links.

2. 🎙️ High-Precision Arabic Speech-to-Text (ASR) Engine

  • NVIDIA NeMo Integration (modules/transcription_engine.py):
    • Local GPU inference using NVIDIA NeMo's stt_ar_fastconformer_hybrid_large_pc_v1.0 model.
    • Audio pre-processing pipeline powered by pydub, soundfile, and librosa.
    • Automatic audio splitting and chunking to handle multi-hour lectures without CUDA memory overflow.
    • Export capabilities for raw text, time-coded SRT subtitles, and structured JSON logs.

3. 📄 Document Parsing & Vision-Language OCR

  • PyMuPDF PDF Renderer (modules/unlimited_ocr.py):

    • Converts PDF document pages into high-DPI image caches on the fly using fitz (PyMuPDF).
    • Batch processing with safety caps (max 15 pages per batch) to prevent model hallucination.
  • Baidu Unlimited-OCR VLM Integration:

    • Runs Baidu's Unlimited-OCR Vision-Language Model locally in bfloat16 precision.
    • Live Token Streaming Patch: Custom monkey-patching of TPSTextStreamer for real-time live token streaming to the Gradio web UI.
    • Regex Cleaning Pipeline: Automatically strips VLM coordinate tags (<|det|>...<|/det|>), reference markers, and cleans page breaks.
  • Qari Arabic OCR Engine (modules/qari_ocr.py):

    • Specialized OCR fallback engine tailored for printed and historical Arabic text layouts.

4. 🔊 Text-To-Speech (TTS) Synthesis

  • Higgs TTS Engine (modules/higgs_tts.py):
    • Integrated speech synthesis module for generating audio output from transcribed text.

5. 🖥️ Interactive Control Center & System Engineering

  • Gradio Web Dashboard (app.py):

    • Unified web dashboard with tabbed interfaces for Telegram Scraping, Audio ASR, Unlimited-OCR, Qari OCR, and TTS.
  • Windows & System Stability Patches:

    • Low-level SSL context patching to bypass certificate errors on local networks.
    • Process-wide temporary directory file lock cleanup patches to prevent WinError 32 file locking on Windows.
    • High-precision logging with file and line tracking.

🛠️ System Architecture

graph TD
    subgraph Ingestion Layer
        A1[Telegram Channels] -->|Telethon Scraper| B[Workspace Download Cache]
        A2[Facebook Videos] -->|Node.js Downloader| B
        A3[Local PDF Scans & Audio] --> B
    end

    subgraph Processing Engine
        B -->|Audio Streams| C[Audio Splitter & Resampler]
        C --> D[NVIDIA NeMo FastConformer ASR]
        
        B -->|PDF Documents| E[PyMuPDF Renderer]
        E -->|Page Images| F[Baidu Unlimited-OCR VLM]
        E -->|Page Images| G[Qari OCR Engine]
        
        F --> H[Live Streamer Patch]
    end

    subgraph Post-Processing & Output
        D --> I[SRT Subtitles / Timed Logs]
        H --> J[Regex Tag Stripper & Text Normalizer]
        G --> J
        J --> K[Clean Text / Dataset Export]
        K -->|Optional| L[Higgs TTS Speech Synthesis]
    end

    subgraph User Interface
        M[Gradio Multi-Tab Web UI] <--> Ingestion Layer
        M <--> Processing Engine
        M <--> Post-Processing & Output
    end

💻 Tech Stack

  • Language: Python 3.10+
  • Deep Learning Frameworks: PyTorch (CUDA), Hugging Face Transformers, Accelerated Peft, Triton.
  • Specialized ML Toolkits: NVIDIA NeMo Toolkit (nemo_toolkit[asr]), Unsloth, Baidu Unlimited-OCR.
  • Document & Image Processing: PyMuPDF (fitz), Pillow, OpenCV, Librosa, SoundFile, Pydub.
  • Web UI & Networking: Gradio, Telethon (Telegram API), Requests, HTTPX, Node.js.

⚙️ Quick Start

  1. Clone the repository:

    git clone https://github.com/h-yassin-ai/Al-Kutub-Automator.git
    cd Al-Kutub-Automator
    
  2. Install dependencies:

    pip install -r requirements.txt
    
  3. Configure environment: Create a .env file in the project root:

    TG_API_ID=your_telegram_api_id
    TG_API_HASH=your_telegram_api_hash
    TG_PHONE=your_phone_number
    HF_TOKEN=your_huggingface_token
    
  4. Launch the dashboard:

    python app.py
    

Contributors

h-yassin-ai

3 commits

Languages

Python

98.8%