PWA that captures a photo of printed text, transcribes it, detects the language, and speaks it aloud using the OS speech engine.
Live: https://reader-app.pages.dev — API: https://reader-app-api.ohrytskov20230516.workers.dev
reader-app/
├── src/ # React app (the PWA)
├── worker/ # Cloudflare Worker (Gemini integration)
│ ├── src/index.ts
│ └── wrangler.toml
└── index.html
pnpm install
cd worker && pnpm install && cd ..
# worker
cd worker
echo "GEMINI_API_KEY=<your-key>" > .dev.vars
pnpm dev
# frontend (in another shell)
echo "VITE_API_URL=http://localhost:8787" > .env.local
pnpm devcd worker
pnpm wrangler secret put GEMINI_API_KEY
pnpm wrangler deploy
cd ..
echo "VITE_API_URL=https://reader-app-api.<account>.workers.dev" > .env.production
pnpm build
pnpm wrangler pages deploy dist --project-name=reader-appPOST /
Content-Type: application/json
{ "imageBase64": "<base64-no-prefix>", "mimeType": "image/jpeg" }
→ 200 { "text": "...", "language": "uk" }
→ 400 { "error": "missing_image" | "invalid_json" }
→ 502 { "error": "ai_failed" | "ai_no_answer" | "ai_bad_format" }
Gemini is asked with a JSON-schema-enforced response, so language is a 2-letter ISO 639-1 code.