TTSConfig¶
This docs was updated at: 2026-02-23
com.paragon.messaging.whatsapp.config.TTSConfig ยท Record
Configuration for Text-to-Speech in WhatsApp messaging.
Controls whether and how often responses are sent as audio messages instead of text messages.
Usage Example¶
// Disabled TTS (default)
TTSConfig config = TTSConfig.disabled();
// TTS with 30% chance of audio response
TTSConfig config = TTSConfig.builder()
.provider(elevenLabsProvider)
.speechChance(0.3)
.languageCode("pt-BR")
.defaultVoiceId("voice123")
.build();
Since: 2.1
Fields¶
TTSConfig¶
Canonical constructor with validation.
Methods¶
disabled¶
Creates a disabled TTS configuration.
No audio responses will be generated.
Returns
disabled TTS configuration
alwaysAudio¶
Creates a TTS configuration that always responds with audio.
Parameters
| Name | Description |
|---|---|
provider |
the TTS provider |
Returns
always-audio TTS configuration
builder¶
Creates a new builder for TTSConfig.
Returns
new builder
isEnabled¶
Checks if TTS is enabled.
Returns
true if a provider is configured and speechChance is greater than 0
shouldUseAudio¶
Checks if TTS should be used for a given random value.
Call this with random.nextDouble() to determine if audio should be sent.
Parameters
| Name | Description |
|---|---|
randomValue |
random value between 0.0 and 1.0 |
Returns
true if audio should be used
provider¶
Sets the TTS provider.
Parameters
| Name | Description |
|---|---|
provider |
the TTS provider |
Returns
this builder
speechChance¶
Sets the probability of responding with audio.
Parameters
| Name | Description |
|---|---|
chance |
probability between 0.0 (never) and 1.0 (always) |
Returns
this builder
defaultVoiceId¶
Sets the default voice ID for synthesis.
Parameters
| Name | Description |
|---|---|
voiceId |
provider-specific voice identifier |
Returns
this builder
languageCode¶
Sets the language code for synthesis.
Parameters
| Name | Description |
|---|---|
code |
language code (e.g., "pt-BR", "en-US") |
Returns
this builder
build¶
Builds the TTSConfig.
Returns
the built configuration