AI voice system for low-latency speech interaction
SofiaVoice is a public RS4 Lab experiment covering an asynchronous STT → LLM → TTS pipeline with session-isolated conversation handling.
🇺🇸 English (this file) · 🇧🇷 Português do Brasil
- Overview
- Key Improvements in v2.0.0
- Performance Benchmarks
- Architecture
- Tech Stack
- Running Locally
- API Endpoints
- Contributing
- License
- Contact
SofiaVoice is a voice-system experiment developed by Rs4Machine within the RS4 Lab. It implements a conversational pipeline that receives audio, transcribes it, generates a response, and synthesizes speech.
The public v2.0 implementation focuses on asynchronous execution, a smaller audio payload, session-isolated state, and explicit API boundaries. The system is designed for measurement and iteration rather than opaque autonomy.
Official positioning: AI Systems Engineer focused on hybrid architectures (LLM + deterministic logic) to eliminate hallucinations and ensure auditability in production.
- Asynchronous Pipeline — Full async execution (
AsyncGroq+Edge-TTS) without blocking the event loop. - Neural TTS Migration — Replaced legacy
gTTSwith MicrosoftEdge-TTS(FranciscaNeural), reducing audio payload sizes by 52%. - Hardened Security — Strict CORS domain mapping, 10 MB payload limits (HTTP 413), and input sanitization against XSS.
- Session Isolation — Independent conversation state handling per request session.
| Metric / Stage | Baseline v1.0 (LLaMA 3.3 70B · gTTS) | v2.0 (openai/gpt-oss-20b · Edge-TTS) | Optimization Gain |
|---|---|---|---|
| STT Latency (Whisper V3) | ~0.84s | ~0.84s | — |
| LLM Latency (LLaMA 3.3 70B → openai/gpt-oss-20b) | ~0.70s | ~0.70s | — |
| TTS Engine Synthesis | ~4.41s | ~1.60s – 2.50s | ~40% faster |
| Audio Payload Size | 64.5 KB | 30.8 KB | 52% smaller payload |
| Execution Architecture | Synchronous / Blocking | Pure Async / Non-blocking | Zero thread blocking |
sofiavoice/
├── frontend/ → Next.js 15 (Vercel)
│ ├── app/sofia-voice/page.jsx → Main orchestrator
│ ├── components/SofiaVoice/ → Voice interface components
│ ├── hooks/useSofiaVoice.js → Web Audio API + API client
│ └── styles/ → Custom UI animations
│
└── backend/ → Python 3.14 + FastAPI (Render)
├── main.py → FastAPI instance, CORS & security middleware
├── config.py → Environment configuration
├── routers/voice.py → Async voice pipeline routes
└── services/
├── stt.py → Whisper Large v3 via Groq
├── llm.py → openai/gpt-oss-20b via AsyncGroq
└── tts.py → Edge-TTS (FranciscaNeural)
| Layer | Technology | Specification |
|---|---|---|
| Frontend | Next.js 15 + React 19 | App Router + Web Audio API |
| Styling | CSS Modules / Tokens | Rs4Machine design system |
| Backend | Python 3.14.2 + FastAPI | Asynchronous ASGI execution |
| Speech-to-Text | Groq API | Whisper Large v3 |
| Intelligence | Groq API | openai/gpt-oss-20b via AsyncGroq |
| Text-to-Speech | Edge-TTS | Microsoft neural voice (pt-BR-FranciscaNeural) |
| Deployment | Vercel (frontend) + Render (backend) | Public deployment |
cd backend
python -m venv .venv
# Linux/Mac
source .venv/bin/activate
# Windows
.venv\Scripts\activate
pip install -r requirements.txtCreate a .env file inside backend/:
GROQ_API_KEY=your_groq_api_key_here
ALLOWED_ORIGINS=http://localhost:3000Start the asynchronous API server:
uvicorn main:app --reload --port 8000Interactive API documentation: http://localhost:8000/docs
cd frontend
npm install
npm run devCreate a .env.local file inside frontend/:
NEXT_PUBLIC_API_URL=http://localhost:8000Open the application at: http://localhost:3000/sofia-voice
| Method | Route | Description | Status Code |
|---|---|---|---|
GET |
/health |
API operational check | 200 OK |
POST |
/api/transcribe |
Audio file → text transcription | 200 OK / 400 Bad Request |
POST |
/api/chat |
Text prompt → AI response | 200 OK / 400 Bad Request |
POST |
/api/speak |
Text prompt → neural Base64 audio | 200 OK / 400 Bad Request |
POST |
/api/voice |
Full end-to-end pipeline | 200 OK / 413 Payload Too Large |
Contributions, issues, and documentation improvements are welcome.
- Fork the project
- Create a feature branch (
git checkout -b feature/your-change) - Commit your changes using Conventional Commits
- Push the branch (
git push origin feature/your-change) - Open a Pull Request
This project is licensed under the MIT License — see LICENSE for details.
Raphael Mendes
AI Systems Engineer & Founder · Rs4Machine
SofiaVoice v2.0.0 · RS4 Lab · September 2026