Skip to content

fix(tts): preserve generation settings when finalizing a context - #118

Open
Apeksha9389 wants to merge 1 commit into
cartesia-ai:mainfrom
Apeksha9389:fix/tts-context-finalization-settings
Open

Apeksha9389 wants to merge 1 commit into
cartesia-ai:mainfrom
Apeksha9389:fix/tts-context-finalization-settings

Conversation

@Apeksha9389

Copy link
Copy Markdown

A context can select its voice, model, output format and generation options on push()/send(), but no_more_inputs() builds its final packet from constructor defaults. For example, a sonic-3.6 utterance using PCM16 at 16 kHz and a per-request voice finishes with sonic-latest, float32 at 44.1 kHz and the default voice. Constructor defaults also replace explicit per-call overrides on finalization.

Keep a copy of each successfully sent generation request. Finalize with its synthesis settings, an empty transcript and continue=false; omit the one-shot flush flag. Repeated finalization remains a no-op, constructor defaults retain their normal behavior, and finalization before any input keeps the existing path. Apply the same handling to sync and async contexts.

Four regression tests fail on current main and pass with the fix. They use actual loopback WebSocket servers and the public Cartesia/AsyncCartesia connection APIs, covering contexts with and without defaults and per-call overrides. All 104 library tests pass on Python 3.12 with websockets 15.0.1. Changed-file Ruff lint/format, targeted MyPy/Pyright and git diff --check pass.

The generated REST API suite and live Cartesia synthesis were not run. The full uv sync hit a build-dependency download timeout; checks use the source tree with the required runtime/test dependencies. Only the hand-maintained lib/ implementation and tests are changed.

AI disclosure: prepared with OpenAI Codex assistance; the reported reproductions and checks were executed locally.

This branch has not been deployed

No deployments
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