Skip to content

Instantly share code, notes, and snippets.

@CodeWithOz
Last active December 19, 2025 13:53
Show Gist options
  • Select an option

  • Save CodeWithOz/d254c811d5a20c2083f593d0a856f875 to your computer and use it in GitHub Desktop.

Select an option

Save CodeWithOz/d254c811d5a20c2083f593d0a856f875 to your computer and use it in GitHub Desktop.
TTS logic for Listen Better demo
export function generateExplanationScript(
processedSentence: ProcessedSentenceResult
): string[] {
const { sentence, translatedText, verbs, vocabulary, idiomaticExpressions } =
processedSentence;
const explanationParts: string[] = [];
// start by reading out the sentence
explanationParts.push(
`${PRESENTERS.MARIE.name}: [cheerfully] Bonjour à tous et à toutes ! Aujourd'hui, nous allons apprendre à traduire la phrase suivante, dans trois, deux, un [short pause]: « [very slowly for emphasis] ${sentence} ».`
);
// pass to the other speaker
explanationParts.push(
`${PRESENTERS.MARIE.name}: [short pause] [warmly] Alors, Clément, qu'est-ce que tu penses de cette phrase ?`
);
// then read out the translation
explanationParts.push(
`${PRESENTERS.CLEMENT.name}: [warmly] Bien, cette phrase veut dire [short pause]: "[English explanation] ${translatedText}". [short pause] And what can you tell us about the verbs used in this sentence, Marie?`
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment