Loading...
const answer = await generateAnswer(question);
const audio = await synthesize(answer);
play(audio);for await (const sentence of streamSentences(question)) {
const spoken = stripMarkdown(sentence);
queueAudio(await synthesize(spoken));
}Synthesizing sentence by sentence without Markdown starts playback sooner and avoids reading symbols aloud.
SSML is an XML markup language for speech that controls pauses, emphasis, pronunciation and speed. Support for its tags differs between TTS engines.
Use a pronunciation dictionary or SSML phoneme tags if the engine supports them, or rewrite the word in the text the way it should sound.
The text still contains Markdown or code. Strip formatting or ask the model to answer in plain spoken sentences before sending text to TTS.