Originally published byDev.to
Building an HSK Speaking Test AI: Real-time Tone Grading with Gemini
I built a free Mandarin speaking assessment tool that grades tone + grammar in real time. Here's the engineering behind it.
The Problem
HSK (Chinese proficiency test) has a speaking component (HSKK), but most learners can't self-assess their level. Online tutors are expensive. Generic AI conversation tools don't grade tones.
So I built ToneTutor: a 3-minute spoken-HSK test that estimates your speaking level and identifies weak points.
The Tech Stack
Frontend:
- Web Audio API (record user voice β PCM β LINEAR16)
- React + TypeScript (real-time transcript display)
Backend:
- FastAPI (Python) on Google Cloud Run
- Gemini 2.5 Flash (real-time conversation + transcript grading)
- Firestore (user sessions + results)
The Challenge:
Web Audio API records as WebM. Gemini expects LINEAR16 (WAV). iOS Safari doesn't support WebM. So:
- Transcode WebM β PCM in browser (Web Audio context)
- Send raw PCM bytes to backend
- Backend wraps PCM in WAV header β sends to Gemini Speech-to-Text
- Gemini analyzes transcript + provides HSK level estimate
The Grading Loop
python
async def grade_session(transcript: str):
prompt = """
Rate this Mandarin response on HSK 1-6 scale.
Assess: tone accuracy, grammar, vocabulary range.
Provide: level estimate + weak points.
"""
response = await gemini.generate_content(prompt, stream=True)
return parse_hsk_level(response)
Results
- 3-min test
- Real-time feedback
- Shareable HSK score card
- Free (limited sessions)
Open source coming soon. Built because I'm a native speaker + voice actor frustrated with generic tools.
Try it: tonetutor.tefusiang.com (free for 3 sessions)
Curious about the speech-to-text pipeline or tone grading logic? Ask below.
πΊπΈ
More news from United StatesUnited States
NORTH AMERICA
Related News

Mattress Firm Coupons: Save up to $600
4h ago
π I Built a Dropshipping Automation Pipeline β Here's What I Learned (and What I'd Do Differently)
11h ago
How I Cut My LLM API Bill by 40x: A Freelancer's Migration Story
11h ago
Cursor AI Review 2026: The AI-Native Code Editor
8h ago

Another Model Rewrote My Memories. Here's How I Caught It.
8h ago