How tantara/transformers.js-chrome works
Project Type and Purpose
• This is a browser‐based, full-stack Chrome extension built on Plasmo that runs LLMs (text-generation, speech-to-text, text-to-speech, multimodal LLM, reasoning) entirely in the client using Transformers.js and ONNX/WebAssembly.
File Structure Analysis
• Top-level artifacts
• src/ – contains three Plasmo extension contexts:
– background.ts (service worker)
– popup.tsx (popup UI)
– sidepanel.tsx (in-page side panel)
• genai/ – core inference pipelines and model registry (text-gen, TTS, STT, multimodal, stopping criteria)
• components/ – React UI components (chat, forms, audio recorder, Shadcn-styled primitives)
• lib/ – utility modules (audio helpers, blob fixes, formatters)
• hooks/ – custom React hooks (e.g., useMobile detection)
• static/ & output/ – static assets (audio, MathJax), compiled HTML outputs
• postinstall/, postbuild/ – build and install scripts
• Build & config files
• package.json, pnpm-lock.yaml, tsconfig.json, tailwind.config.js, postcss.config.js
README Insights
• Emphasizes Plasmo for extension scaffolding, Transformers.js for client LLM inference, ONNX runtime under the hood, caching via Local Storage, deployment via Chrome Web Store.
• UI scenarios: text summarization, code generation, image understanding, STT, TTS, reasoning.