How bodhi132/voiceai works
1. Repository shape
- This is a two-tier application: a Next.js client in client/ and a FastAPI Python backend in backend/.
- The backend owns all AI/audio processing; the frontend is mostly a presentation and upload/results shell.
2. Frontend boundary
- client/app/page.tsx is the entry upload/recording surface.
- client/app/results/page.tsx renders the scored pronunciation report.
- client/app/loading/page.tsx and components/LoadingScreen.tsx indicate a dedicated waiting state while the backend processes audio.
- The UI is built with the Next.js App Router and appears designed as a mostly client-side workflow around a single assessment request.
3. Backend entrypoint and orchestration
- backend/main.py is the API entrypoint and likely coordinates the full assessment pipeline.
- The backend is structured as a set of services rather than a large monolith, which is important for diagramming the internal flow.
4. Audio processing pipeline
- The backend depends on FFmpeg for audio normalization/conversion before analysis.
- This is the first preprocessing boundary: user audio is cleaned into a consistent format before transcription or phoneme extraction.
5. Transcription and word timing
- backend/services/transcription.py uses the Groq Whisper API to transcribe speech and get word-level timestamps.
- This stage also verifies that the audio is English, which acts as an early gate before deeper analysis.
6. Expected pronunciation generation
- backend/services/expected_phonemes.py derives the canonical pronunciation for each word.
- The readme indicates a dual strategy: CMUdict for known words and g2p_en as a fallback for proper nouns or out-of-vocabulary words.
- backend/vocab.json likely supports phoneme vocabulary normalization/mapping.
7. Actual pronunciation extraction
- backend/services/phonemes.py extracts phonetic output from the audio itself using a Wav2Vec2-based model.
- backend/export_onnx.py is a key deployment artifact: it converts the larger PyTorch model into a compressed INT8 ONNX version so inference can run on CPU-constrained infrastructure.
8. Scoring logic
- backend/services/scoring.py compares expected vs. actual phonemes using Levenshtein distance at the word level.
- The output is a per-word pronunciation score, so the unit of analysis is not just the utterance, but each spoken token.
9. Feedback generation
- backend/services/feedback.py turns scores and phonetic error patterns into coaching feedback.
- The readme says this is generated with Groq Llama 3, making the feedback stage separate from both transcription and scoring.
10. End-to-end data flow
- The main pipeline is: upload audio → normalize audio → transcribe + timestamp words → derive expected phonemes → extract actual phonemes → score words → generate coaching feedback → return structured results.
- The frontend then consumes the final response and displays it in the results dashboard.
11. External service boundaries
- The repo depends on two Groq-powered cloud functions:
- Whisper-large-v3 for transcription/timestamps
- Llama 3 for personalized coaching text
- These are the only major external AI services; phoneme inference is intentionally local/on-CPU via ONNX.
12. Deployment and build pipeline
- .github/workflows/main_voiceai-backend.yml is a significant architectural component because it handles the heavy model preparation step in CI.
- The design is optimized for constrained backend hosting: model export happens in GitHub Actions, while the deployed backend only serves the lightweight ONNX runtime path.
13. Operational split
- The frontend and backend are independently deployable, with the readme describing the frontend on Render and the backend on Azure App Service.
- Architecturally, this means the client talks to the backend over HTTP and does not embed ML logic locally.
14. Diagramming hint
- A good architecture diagram should show three clear zones: Next.js UI, FastAPI AI pipeline, and Groq cloud APIs, with the backend as the control plane that fans out into transcription, phoneme analysis, scoring, and feedback generation.
Main entry points: main.py API entry · expected_phonemes.py Expected phonemes · feedback.py Feedback · phonemes.py Actual phonemes
Components 16
Next.js client
Upload, waiting, and results UI
- Upload · Entry surface for recording or uploading audio
client/app/page.tsx - Loading page · Dedicated waiting route during backend processing
client/app/loading/page.tsx - Loading UI · Shared loading state shown while scoring runs
client/components/LoadingScreen.tsx - Results · Displays pronunciation scores and coaching output
client/app/results/page.tsx
FastAPI backend
Assessment API and AI/audio pipeline
- API entry · HTTP entrypoint and pipeline coordinator
backend/main.py - Transcription · Normalizes speech into words and timestamps
backend/services/transcription.py - Expected phonemes · Builds canonical pronunciations from vocabulary and fallbacks
backend/services/expected_phonemes.py - Vocab map · Pronunciation vocabulary and normalization data
backend/vocab.json - Actual phonemes · Extracts phonetic output from the audio signal
backend/services/phonemes.py - Scoring · Compares expected and actual phonemes per word
backend/services/scoring.py - Feedback · Turns score patterns into coaching advice
backend/services/feedback.py - FFmpeg · Audio normalization and conversion boundary
Groq cloud
External transcription and coaching APIs
- Whisper API · Cloud transcription and word timing
- Llama 3 API · Cloud-generated personalized coaching text
Build pipeline
Model export and deployment prep
- ONNX export · Converts the model to compressed CPU-friendly ONNX
backend/export_onnx.py - CI workflow · Prepares and exports backend model artifacts
.github/workflows/main_voiceai-backend.yml
Connections 17
- Upload → API entry: submit audio · Client sends the assessment request to the API
- Upload → Loading page: wait state · UI transitions into the dedicated processing screen
- Loading page → Loading UI: renders · Loading route uses the shared waiting UI
- API entry → FFmpeg: normalize · Audio is converted to a consistent analysis format
- API entry → Transcription: transcribe · Pipeline starts with speech-to-text and timing
- API entry → Expected phonemes: derive target · Builds expected pronunciations for each word
- API entry → Actual phonemes: infer phonemes · Runs local phoneme extraction on the cleaned audio
- API entry → Scoring: score words · Compares expected and actual pronunciations
- API entry → Feedback: coach · Generates feedback from score patterns
- Transcription → Whisper API: Whisper large-v3 · Uses Groq-hosted transcription service
- Expected phonemes → Vocab map: lookup · Uses pronunciation vocabulary and normalization data
- Expected phonemes → Actual phonemes: compare basis · Expected pronunciations feed phoneme comparison
- Scoring → Feedback: score signals · Per-word errors inform coaching generation
- Feedback → Llama 3 API: Llama 3 · Uses Groq-hosted language model for coaching text
- CI workflow → ONNX export: build artifact · CI prepares the CPU-friendly model export
- ONNX export → Actual phonemes: runtime model · Deployment uses the exported ONNX path
- Results → API entry: fetch results · Results page reads the structured assessment response