An interactive RPG game with dual-stream architecture featuring browser speech recognition and AI-generated audio responses.
- Browser Speech Recognition: Fast, local speech-to-text using browser APIs
- Dual-Stream Architecture: Separate text and audio streaming for optimal performance
- Real-time TTS: OpenAI text-to-speech with streaming audio playback
- Session Management: Persistent game sessions with conversation history
- Immersive Interface: Full-screen fantasy-themed UI
- Frontend: Vanilla JavaScript with Browser Speech Recognition API
- Backend: Express.js with OpenAI integration
- Streaming: Server-Sent Events for real-time text and audio
- Deployment: Vercel serverless functions
- A Vercel account
- An OpenAI API key
-
Clone and setup:
git clone <your-repo> cd audiorpg
-
Install Vercel CLI:
npm i -g vercel
-
Set up environment variables:
- Copy
.env.exampleto.env.local - Add your OpenAI API key to
.env.local
- Copy
-
Deploy:
vercel
-
Configure environment variables in Vercel:
- Go to your Vercel dashboard
- Select your project
- Go to Settings > Environment Variables
- Add:
OPENAI_API_KEY: Your OpenAI API keyMODEL:gpt-4o-mini(optional, defaults to this)
OPENAI_API_KEY: Required - Your OpenAI API keyMODEL: Optional - OpenAI model to use (default: gpt-4o-mini)
-
Install dependencies:
npm install
-
Set up environment:
cp .env.example .env # Edit .env with your OpenAI API key -
Run locally:
npm start
├── api/
│ ├── index.js # Vercel serverless function
│ └── package.json # API dependencies
├── public/
│ └── index.html # Frontend application
├── sessions.js # Session management
├── summarizer.js # Story summarization
├── vercel.json # Vercel configuration
└── package.json # Main project file
GET /api/text-stream?message=<text>- Stream text responsesGET /api/audio-stream?text=<text>- Stream audio responsesGET /api/health- Health check
- Browser Speech Recognition API (no model loading)
- Separated text/audio streams for parallel processing
- Efficient sentence-based TTS chunking
- Client-side audio queue management