Skip to content

feat: support speed, stability and similarity_boost in TtsOverrides - #65

Open
Darnasis wants to merge 1 commit into
elevenlabs:mainfrom
Darnasis:feat/tts-speed-stability-overrides
Open

feat: support speed, stability and similarity_boost in TtsOverrides#65
Darnasis wants to merge 1 commit into
elevenlabs:mainfrom
Darnasis:feat/tts-speed-stability-overrides

Conversation

@Darnasis

Copy link
Copy Markdown

Problem

conversation_config_override.tts accepts voice_id, speed, stability and similarity_boost, and agents expose a Security → Overrides toggle for each one. The Kotlin SDK can only express voice_id:

data class TtsOverrides(
    val voiceId: String? = null
)
ovr.tts?.voiceId?.let { ttsObj.put("voice_id", it) }

So on Android the other three are unreachable even with the toggles enabled — there is no way to start a conversation at a different speed. The Python/JS SDKs and the docs' own override examples all support the full block, so this reads as an Android gap rather than an intentional limit.

Concretely: we build a voice tutor whose users set a speech-rate preference. We can apply their chosen voice, but not their chosen speed, purely because the field cannot be expressed.

Change

  • TtsOverrides gains speed, stability and similarityBoost, all nullable, defaulting to null — source- and binary-compatible for existing callers, who keep constructing TtsOverrides(voiceId = ...) unchanged.
  • ConversationOverridesBuilder serializes them with the documented snake_case keys, keeping the existing omit-when-null behaviour so a partially-populated TtsOverrides never widens into explicit nulls (the docs specifically ask callers to omit rather than send nulls).

Tests

Adds ConversationOverridesBuilderTest — as far as I can tell the first coverage of constructOverrides:

  • each field serializes, with correct similarity_boost snake_case mapping
  • all four together
  • omit-when-null: a TtsOverrides(speed = 1.1) emits exactly one key
  • an entirely empty TtsOverrides emits no tts object at all (existing behaviour, now pinned)
  • agent overrides still serialize alongside tts

org.json was already a testImplementation dependency, so no build changes were needed.

./gradlew :elevenlabs-sdk:testDebugUnitTest passes (7/7 new, existing suite green).

Notes

Happy to adjust naming (similarityBoost follows the existing camelCase-in-Kotlin / snake_case-on-the-wire convention used by voiceId and firstMessage) or to narrow the change to speed alone if you'd prefer a smaller surface.

`conversation_config_override.tts` accepts `voice_id`, `speed`, `stability` and
`similarity_boost`, and agents expose a Security -> Overrides toggle for each.
The Kotlin SDK could only express `voice_id`, so the other three were unreachable
from Android even with the toggles enabled — there was no way to start a
conversation at a different speed.

- TtsOverrides gains speed, stability and similarityBoost (all nullable).
- ConversationOverridesBuilder serializes them, keeping the existing
  omit-when-null behaviour so a partially-populated TtsOverrides never widens
  into explicit nulls.

Adds ConversationOverridesBuilderTest, the first coverage of constructOverrides:
per-field serialization, snake_case key mapping, omit-when-null, an entirely
empty TtsOverrides emitting no `tts` object, and agent overrides still
serializing alongside tts. org.json was already a test dependency, so no build
changes were needed.

`./gradlew :elevenlabs-sdk:testDebugUnitTest` passes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant