Speech Builder
Kotlin DSL builder for constructing structured speech with automatic SSML generation.
This builder provides a type-safe, readable way to compose complex speech sequences including pauses, prosody changes, emphasis, spell-out, and structured say-as interpretations.
Basic usage
tts.speak {
text("Bonjour.")
pause(400)
slow { text("Ceci est important.") }
}Rich example
tts.speak {
paragraph {
sentence { text("Bienvenue sur notre application.") }
sentence {
text("Votre code est ")
spellOut("AB12")
text(".")
}
}
pause(600)
withPreset(SpeechPreset.CALM) {
text("Merci et à bientôt.")
}
}See also
Functions
Wraps content in an SSML <emphasis> tag.
Wraps content with rate="fast".
Wraps content with pitch="+3st" (higher).
Wraps content with volume="loud".
Wraps content with pitch="-3st" (lower).
Wraps content in an SSML <p> (paragraph) tag.
Sets pitch in semitones relative to default.
Sets rate as a percentage of normal speed.
Shortcut for emphasis(level = "reduced").
Wraps content in an SSML <s> (sentence) tag.
Wraps content with rate="slow".
Wraps content with volume="soft".
Shortcut for emphasis(level = "strong").
Applies a SpeechPreset's prosody (rate, pitch, volume) to the enclosed content.
Wraps content with rate="x-fast".
Wraps content with volume="x-loud".
Wraps content with rate="x-slow".
Wraps content with volume="x-soft".