ZenDen

Generate personalized meditations on-demand straight from your Farcaster client for $0.01 USDC.

ZenDen

Created At

ETHGlobal Buenos Aires

Project Description

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.

How it's Made

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 startup
  • OpenAI streaming (gpt-5-nano) generates text sentence-by-sentence via regex detection
  • Each sentence is converted to speech via OpenAI TTS and scheduled sequentially using AudioContext.currentTime
  • Writes 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 response

Web3 Integration:

  • x402 Payments: x402-express middleware protects /stream. Client uses x402-fetch with a custom hook; requires type assertion for Wagmi wallet client compatibility
  • Farcaster: SDK for mini-app context, Wagmi for wallet connections

Notable Hacks:

  • Pre-loads entire ambient files into memory for instant playback
  • Async generators for sentence-by-sentence flow control with timeout handlers
  • Graceful handling of client disconnects (EPIPE/ECONNRESET) in FFmpeg streams

Partner Technologies:

  • Coinbase x402: $0.01 USDC micropayments
background image mobile

Join the mailing list

Get the latest news and updates