ZenDen
Generate personalized meditations on-demand straight from your Farcaster client for $0.01 USDC.
Problem Statement
Zen Den is a Web3 meditation platform that generates personalized meditation episodes on demand using AI.Core Features: AI-generated meditation content from user prompts (e.g., "gratitude", "sleep", "anxiety relief")Real-time audio streaming: OpenAI TTS converts sentences to speech as they’re generated.Six voice options (Alloy, Echo, Fable, Onyx, Nova, Shimmer) and 13 ambient background tracks.FFmpeg transcodes mixed audio to MP3 in real time.
Solution
Architecture: Turbo repo with TypeScript. Backend: Express + tRPC. Frontend: React + React Router.Real-Time Audio Streaming: Uses web-audio-engine for a Node.js-compatible AudioContext that pipes to streams.Flow:Pre-loads all 13 ambient WAV files (30–94MB) into memory at startupOpenAI streaming (gpt-5-nano) generates text sentence-by-sentence via regex detectionEach sentence is converted to speech via OpenAI TTS and scheduled sequentially using AudioContext.currentTimeWrites a WAV header with 0 frames (unknown length), pipes through PassThrough, and uses FFmpeg to transcode WAV→MP3 in real time, streaming to the HTTP responseWeb3 Integration:x402 Payments: x402-express middleware protects /stream. Client uses x402-fetch with a custom hook; requires type assertion for Wagmi wallet client compatibilityFarcaster: SDK for mini-app context, Wagmi for wallet connectionsNotable Hacks:Pre-loads entire ambient files into memory for instant playbackAsync generators for sentence-by-sentence flow control with timeout handlersGraceful handling of client disconnects (EPIPE/ECONNRESET) in FFmpeg streamsPartner Technologies:Coinbase x402: $0.01 USDC micropayments
Hackathon
ETHGlobal Buenos Aires
2025
Contributors
- danimbrogno
39 contributions
- cursoragent
7 contributions