Skip to content

Recommendation Audio

API routeapp/api/generate-recommendation-audio/route.ts
TTS enginegemini-2.5-flash-preview-tts (via lib/gcp/tts.ts)
Storage pathrecommendation/{userId}/insight.wav
Triggered byapp/(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 page

Storage

recommendation/{userId}/insight.wav

The 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.

Released under the MIT License.