|
| 1 | +## ElatoAI: Realtime Voice AI Models on FastAPI |
| 2 | + |
| 3 | +`server-fastapi` is the simplest self-hosted Elato backend for people who want a normal Python server instead of an edge runtime. |
| 4 | + |
| 5 | +Use this if you want: |
| 6 | + |
| 7 | +- a FastAPI server you can run on your own machine or VM |
| 8 | +- a classic `STT -> LLM -> TTS` voice pipeline |
| 9 | +- a smaller provider surface that is easy to understand |
| 10 | +- the same ESP32 transport shape as the rest of Elato |
| 11 | + |
| 12 | +If you are new to the project, read these first: |
| 13 | + |
| 14 | +- `/Users/akashdeepdeb/Desktop/Projects/ElatoAI/README.md` |
| 15 | +- `/Users/akashdeepdeb/Desktop/Projects/ElatoAI/server/README.md` |
| 16 | + |
| 17 | +## The Simple Provider Set |
| 18 | + |
| 19 | +To keep onboarding straightforward, the classic FastAPI route is centered around a small set of providers. |
| 20 | + |
| 21 | +### LLM |
| 22 | + |
| 23 | +- `openai` |
| 24 | +- `claude` |
| 25 | +- `gemini` |
| 26 | +- `grok` |
| 27 | + |
| 28 | +### STT |
| 29 | + |
| 30 | +- `deepgram` |
| 31 | +- `whisper` |
| 32 | + |
| 33 | +### TTS |
| 34 | + |
| 35 | +- `elevenlabs` |
| 36 | +- `cartesia` |
| 37 | +- `deepgram` |
| 38 | +- `openai` |
| 39 | + |
| 40 | +The code still uses the `models/llm`, `models/stt`, and `models/tts` layout, but the active registry is intentionally trimmed so the default experience stays simple. |
| 41 | + |
| 42 | +## Default Setup |
| 43 | + |
| 44 | +The default classic route is: |
| 45 | + |
| 46 | +- STT: `deepgram` |
| 47 | +- LLM: `openai` |
| 48 | +- TTS: `elevenlabs` |
| 49 | + |
| 50 | +That gives people one obvious path to get running before they start swapping providers. |
| 51 | + |
| 52 | +## Project Layout |
| 53 | + |
| 54 | +```text |
| 55 | +server-fastapi/ |
| 56 | +├── bot.py |
| 57 | +├── classic_route.py |
| 58 | +├── esp32_transport.py |
| 59 | +├── server.py |
| 60 | +├── env.example |
| 61 | +└── models/ |
| 62 | + ├── llm/ |
| 63 | + ├── stt/ |
| 64 | + └── tts/ |
| 65 | +``` |
| 66 | + |
| 67 | +## How The FastAPI Server Fits Into Elato |
| 68 | + |
| 69 | +Elato has three backend options right now: |
| 70 | + |
| 71 | +- `/Users/akashdeepdeb/Desktop/Projects/ElatoAI/server/deno` |
| 72 | +- `/Users/akashdeepdeb/Desktop/Projects/ElatoAI/server/cloudflare` |
| 73 | +- `/Users/akashdeepdeb/Desktop/Projects/ElatoAI/server-fastapi` |
| 74 | + |
| 75 | +A clean way to think about them is: |
| 76 | + |
| 77 | +- `Deno`: edge-first, mature provider integrations |
| 78 | +- `Cloudflare`: Workers + Durable Objects + Workers AI |
| 79 | +- `FastAPI`: normal Python server, easy to self-host, easy to reason about |
| 80 | + |
| 81 | +## Quick Start |
| 82 | + |
| 83 | +### 1. Create or activate your Python environment |
| 84 | + |
| 85 | +Use whatever you prefer. If you already use `uv`, that is a good default. |
| 86 | + |
| 87 | +### 2. Install dependencies |
| 88 | + |
| 89 | +This repo uses `pyproject.toml`, so install from that environment rather than a `requirements.txt` file. |
| 90 | + |
| 91 | +With `uv`: |
| 92 | + |
| 93 | +```bash |
| 94 | +cd /Users/akashdeepdeb/Desktop/Projects/ElatoAI/server-fastapi |
| 95 | +uv sync |
| 96 | +``` |
| 97 | + |
| 98 | +Or with plain pip in your venv: |
| 99 | + |
| 100 | +```bash |
| 101 | +cd /Users/akashdeepdeb/Desktop/Projects/ElatoAI/server-fastapi |
| 102 | +pip install -e . |
| 103 | +``` |
| 104 | + |
| 105 | +### 3. Create your env file |
| 106 | + |
| 107 | +Copy the example values from: |
| 108 | + |
| 109 | +- `/Users/akashdeepdeb/Desktop/Projects/ElatoAI/server-fastapi/env.example` |
| 110 | + |
| 111 | +Minimum example for the default route: |
| 112 | + |
| 113 | +```env |
| 114 | +DEEPGRAM_API_KEY=your_deepgram_api_key |
| 115 | +OPENAI_API_KEY=your_openai_api_key |
| 116 | +ELEVENLABS_API_KEY=your_elevenlabs_api_key |
| 117 | +
|
| 118 | +CURRENT_VOICE_ROUTE=classic |
| 119 | +CLASSIC_STT_PROVIDER=deepgram |
| 120 | +CLASSIC_LLM_PROVIDER=openai |
| 121 | +CLASSIC_TTS_PROVIDER=elevenlabs |
| 122 | +
|
| 123 | +ESP32_INPUT_SAMPLE_RATE=16000 |
| 124 | +BROWSER_INPUT_SAMPLE_RATE=16000 |
| 125 | +AUDIO_OUTPUT_SAMPLE_RATE=24000 |
| 126 | +PIPELINE_AUDIO_IN_SAMPLE_RATE=16000 |
| 127 | +PIPELINE_AUDIO_OUT_SAMPLE_RATE=24000 |
| 128 | +
|
| 129 | +ALLOWED_ORIGINS=* |
| 130 | +HOST=0.0.0.0 |
| 131 | +PORT=7860 |
| 132 | +``` |
| 133 | + |
| 134 | +### 4. Run the server |
| 135 | + |
| 136 | +If you use `uv`: |
| 137 | + |
| 138 | +```bash |
| 139 | +cd /Users/akashdeepdeb/Desktop/Projects/ElatoAI/server-fastapi |
| 140 | +uv run server.py |
| 141 | +``` |
| 142 | + |
| 143 | +If you use your activated venv directly: |
| 144 | + |
| 145 | +```bash |
| 146 | +cd /Users/akashdeepdeb/Desktop/Projects/ElatoAI/server-fastapi |
| 147 | +python server.py |
| 148 | +``` |
| 149 | + |
| 150 | +### 5. Point your ESP32 at the FastAPI backend |
| 151 | + |
| 152 | +Update the firmware config so your hardware connects to this server instead of the Deno or Cloudflare backend. |
| 153 | + |
| 154 | +The ESP32 route is: |
| 155 | + |
| 156 | +```text |
| 157 | +/ws/esp32 |
| 158 | +``` |
| 159 | + |
| 160 | +For browser or Next.js testing, the server also exposes: |
| 161 | + |
| 162 | +- `/ws/browser` |
| 163 | +- `/ws/nextjs` |
| 164 | + |
| 165 | +## How Provider Selection Works |
| 166 | + |
| 167 | +The classic route reads three env vars: |
| 168 | + |
| 169 | +- `CLASSIC_STT_PROVIDER` |
| 170 | +- `CLASSIC_LLM_PROVIDER` |
| 171 | +- `CLASSIC_TTS_PROVIDER` |
| 172 | + |
| 173 | +So changing providers is just an env change. |
| 174 | + |
| 175 | +Examples: |
| 176 | + |
| 177 | +### OpenAI + Deepgram + ElevenLabs |
| 178 | + |
| 179 | +```env |
| 180 | +CLASSIC_STT_PROVIDER=deepgram |
| 181 | +CLASSIC_LLM_PROVIDER=openai |
| 182 | +CLASSIC_TTS_PROVIDER=elevenlabs |
| 183 | +``` |
| 184 | + |
| 185 | +### Whisper + Claude + Cartesia |
| 186 | + |
| 187 | +```env |
| 188 | +CLASSIC_STT_PROVIDER=whisper |
| 189 | +CLASSIC_LLM_PROVIDER=claude |
| 190 | +CLASSIC_TTS_PROVIDER=cartesia |
| 191 | +``` |
| 192 | + |
| 193 | +### Deepgram + Gemini + OpenAI TTS |
| 194 | + |
| 195 | +```env |
| 196 | +CLASSIC_STT_PROVIDER=deepgram |
| 197 | +CLASSIC_LLM_PROVIDER=gemini |
| 198 | +CLASSIC_TTS_PROVIDER=openai |
| 199 | +``` |
| 200 | + |
| 201 | +## Unified Experience Across Elato |
| 202 | + |
| 203 | +A simple way to keep the product understandable is: |
| 204 | + |
| 205 | +- keep the Next.js frontend focused on character creation and device management |
| 206 | +- keep the ESP32 firmware focused on one transport protocol |
| 207 | +- let users choose one backend runtime: |
| 208 | + - Deno |
| 209 | + - Cloudflare |
| 210 | + - FastAPI |
| 211 | +- inside each backend, expose the same conceptual knobs: |
| 212 | + - `STT` |
| 213 | + - `LLM` |
| 214 | + - `TTS` |
| 215 | + |
| 216 | +That means the hardware story stays stable: |
| 217 | + |
| 218 | +- one firmware |
| 219 | +- one websocket-style mental model |
| 220 | +- three server deployment choices |
| 221 | + |
| 222 | +The cleanest unification strategy is not “every backend supports every provider.” |
| 223 | +It is: |
| 224 | + |
| 225 | +- every backend should expose the same categories |
| 226 | +- each backend should have one recommended default stack |
| 227 | +- advanced users can swap providers later |
| 228 | + |
| 229 | +## Recommended Defaults |
| 230 | + |
| 231 | +If you want a simple opinionated experience for users, keep one default combo per backend. |
| 232 | + |
| 233 | +Suggested defaults: |
| 234 | + |
| 235 | +- `Deno`: OpenAI realtime |
| 236 | +- `Cloudflare`: Workers AI STT/TTS + OpenAI LLM |
| 237 | +- `FastAPI`: Deepgram + OpenAI + ElevenLabs |
| 238 | + |
| 239 | +That gives users one obvious starting point without taking away flexibility. |
| 240 | + |
| 241 | +## Important Files |
| 242 | + |
| 243 | +If you want to change the FastAPI backend, start here: |
| 244 | + |
| 245 | +- `/Users/akashdeepdeb/Desktop/Projects/ElatoAI/server-fastapi/server.py` |
| 246 | +- `/Users/akashdeepdeb/Desktop/Projects/ElatoAI/server-fastapi/classic_route.py` |
| 247 | +- `/Users/akashdeepdeb/Desktop/Projects/ElatoAI/server-fastapi/esp32_transport.py` |
| 248 | +- `/Users/akashdeepdeb/Desktop/Projects/ElatoAI/server-fastapi/models/llm/__init__.py` |
| 249 | +- `/Users/akashdeepdeb/Desktop/Projects/ElatoAI/server-fastapi/models/stt/__init__.py` |
| 250 | +- `/Users/akashdeepdeb/Desktop/Projects/ElatoAI/server-fastapi/models/tts/__init__.py` |
| 251 | + |
| 252 | +## Current Notes |
| 253 | + |
| 254 | +- The filesystem still contains many scaffolded provider modules from the earlier broader experiment. |
| 255 | +- The active provider registry is now intentionally much smaller. |
| 256 | +- That means the codebase stays extensible, but the user-facing default path stays simple. |
0 commit comments