Recommendation Audio
| API route | app/api/generate-recommendation-audio/route.ts |
| TTS engine | gemini-2.5-flash-preview-tts (via lib/gcp/tts.ts) |
| Storage path | recommendation/{userId}/insight.wav |
| Triggered by | app/(dashboard)/profile/page.tsx — after LearningAdvisor recommendation loads |
What it does
Converts the LearningAdvisor's recommendation text to speech and plays it on the Profile page so kids can hear their personalized recommendation spoken aloud. The audio is uploaded to GCS and overwritten each time a new recommendation is generated.
The text spoken is encouragement + " " + readingInsight — both fields from the LearningRecommendation object.
Flow
Profile page loads LearningAdvisor recommendation
│
▼
recText = `${recommendation.encouragement} ${recommendation.readingInsight}`
│
▼
POST /api/generate-recommendation-audio { text: recText, userId }
│
▼
synthesizeSpeech(text, "Aoede", "en") ← language is hardcoded "en"
│
▼
uploadAndSign(buffer, "recommendation/{userId}/insight.wav", "audio/wav")
│
▼
{ audioUrl } → cached in sessionStorage, then played on Profile pageStorage
recommendation/{userId}/insight.wavThe file is overwritten each time — only the most recent recommendation audio is kept. There is no versioning.
Voice & language
- Voice: Aoede
- Language: hardcoded
"en"— the recommendation audio is always in English regardless of the story language, because the LearningAdvisor always generates its output in English.
