ATQA (Autonomous TTS Quality Assurance Agent) is a Next.js application that reviews TTS audio pronunciation using Cloud Speech-to-Text and Vertex AI Gemini.
| Variable | Description | Example |
|---|---|---|
GOOGLE_CLOUD_PROJECT |
GCP project ID | my-atqa-project |
GOOGLE_CLOUD_LOCATION |
GCP region for AI services | us-central1 |
SPEECH_LOCATION |
Speech-to-Text V2 location (ja-JP + long model requires global) |
global |
GEMINI_MODEL |
Gemini model name | gemini-2.5-flash |
ALLOWED_AUDIO_HOSTS |
Comma-separated allowed CDN hosts | cdn.convly.jp |
ASR_CONFIDENCE_THRESHOLD |
Minimum STT confidence (0-1) | 0.75 |
- Node.js 22+
- pnpm 9+
- Google Cloud SDK with ADC configured
pnpm installgcloud auth application-default login
gcloud auth application-default set-quota-project YOUR_PROJECT_IDgcloud services enable speech.googleapis.com
gcloud services enable aiplatform.googleapis.comexport GOOGLE_CLOUD_PROJECT=your-project-id
export GOOGLE_CLOUD_LOCATION=us-central1
export SPEECH_LOCATION=global
export GEMINI_MODEL=gemini-2.5-flash
export ALLOWED_AUDIO_HOSTS=cdn.convly.jp
export ASR_CONFIDENCE_THRESHOLD=0.75pnpm devAccess at http://localhost:3000
pnpm testpnpm exec playwright install chromium
pnpm test:e2epnpm typecheckpnpm lintgcloud builds submit --tag gcr.io/PROJECT_ID/atqagcloud run deploy atqa \
--image gcr.io/PROJECT_ID/atqa \
--platform managed \
--region us-central1 \
--allow-unauthenticated \
--set-env-vars "GOOGLE_CLOUD_PROJECT=PROJECT_ID,GOOGLE_CLOUD_LOCATION=us-central1,SPEECH_LOCATION=global,GEMINI_MODEL=gemini-2.5-flash,ALLOWED_AUDIO_HOSTS=cdn.convly.jp,ASR_CONFIDENCE_THRESHOLD=0.75" \
--memory 2Gi \
--timeout 300The Cloud Run service account needs:
roles/speech.client- Cloud Speech-to-Textroles/aiplatform.user- Vertex AI
- STT failures: Return
inconclusive, no automatic retry - Gemini invalid output: One automatic retry, then
inconclusive - Audio fetch failures: Return
inconclusivewithAUDIO_FETCH_FAILED - Idempotency: In-memory deduplication per Cloud Run instance
- No persistence: All review state is session-only (browser memory)
- No logging of audio content: Audio is processed in-memory and discarded
- No credential exposure: Raw errors are converted to safe messages
Before production use, verify:
- APIs enabled: Speech-to-Text V2 and Vertex AI are active
- Credentials valid: ADC can access both services
- Model available:
GEMINI_MODELexists inGOOGLE_CLOUD_LOCATION - CDN accessible:
ALLOWED_AUDIO_HOSTSreturns valid audio
Verified against live GCP services with scripts/smoke-review.ps1 and the browser UI:
| Item | Result |
|---|---|
| Project / region | ai-agent-hackathon-497119 / Gemini us-central1, STT global |
| STT (Speech-to-Text V2) | ja-JP + model: "long", confidence 0.917 on doc-1 fixture audio |
| Gemini | gemini-2.5-flash, structured JSON verdict, latency ~8s per unit |
| End-to-end | doc-1 flagged review with AUDIO_PRONUNCIATION_SUSPECT: 「ITプロジェクト」 pronounced as 「aip Project」, evidence + transcript surfaced in UI |
Notes:
gemini-2.0-flashis retired (404 on Vertex AI). Usegemini-2.5-flash.- Speech-to-Text V2
_recognizer with ja-JP +longis only available in thegloballocation; regional endpoints (e.g.us-central1-speech.googleapis.com) reject it. - Diagnostic probes live in
scripts/(stt-probe.mjs,gemini-probe.mjs,gemini-review-probe.mjs,smoke-review.ps1).
- Check audio quality and format (MP3 expected)
- Verify
ASR_CONFIDENCE_THRESHOLDis appropriate - Background noise or overlapping speech reduces confidence
- Model may lack evidence for a definitive judgment
- Check STT transcript quality
- Verify expected reading is correct
- Verify URL is HTTPS and host is in
ALLOWED_AUDIO_HOSTS - Check CDN availability
- Redirects to non-allowed hosts are blocked (SSRF protection)
- A
206response withoutContent-Rangeis rejected by browsers; the proxy only returns 206 when the upstream providesContent-Range
- On non-HTTPS, non-localhost origins (e.g. LAN IP),
crypto.randomUUIDis unavailable; the client falls back to a random key. Failures are surfaced as a visible error message in the review panel