soniox: add reduce_silence option to TTS - #6798
Conversation
Soniox TTS v2 (tts-rt-v2) supports the reduce_silence parameter, which shortens the pauses between words independently of the speed parameter. Expose it on soniox.TTS via the constructor and update_options. The flag is only sent in the WebSocket config message when enabled, so existing configurations produce byte-identical config messages. The server validates model support (supports_silence_reduction) and rejects it on models that lack it, per the Soniox API reference.
chenghao-mou
left a comment
There was a problem hiding this comment.
thanks for the PR! left one data validation comment.
| @@ -88,6 +88,7 @@ def __init__( | |||
| sample_rate: int = DEFAULT_SAMPLE_RATE, | |||
There was a problem hiding this comment.
Only supported on models with supports_silence_reduction: true - see List models. Setting it to true on any other model returns an invalid_request error. See Reduce silence.
we should validate the model option here when it is True.
There was a problem hiding this comment.
Done in da9b084 - added a _validate_reduce_silence() check that raises ValueError from both the constructor and update_options (validated against the effective model/flag combination there, before any state is mutated). Implemented as a blocklist of the models that report supports_silence_reduction: false in the List models API (tts-rt-v1, tts-rt-v1-preview), so future models keep working without a plugin update and the server stays the final validator for unknown models. Covered by a new test, and updated the existing one which was enabling reduce_silence on the default v1-preview model.
Per review feedback: reduce_silence is only accepted on models that report supports_silence_reduction in the List models API, so raise a ValueError from the constructor and update_options instead of letting the server return invalid_request mid-session. Known unsupported models (tts-rt-v1, tts-rt-v1-preview) are blocklisted so future models keep working without a plugin update.
Summary
Soniox TTS v2 (
tts-rt-v2) supports areduce_silenceparameter that shortens the pauses between words, independently ofspeed(docs). This PR exposes it onsoniox.TTS:reduce_silence: bool = Falseconstructor argumentupdate_options()as wellThe server validates model support itself (
supports_silence_reductionin the models listing) and returnsinvalid_requeston models that lack it, so no client-side model gating is needed.Test plan
test_reduce_silence_propagates_to_optionscovers the constructor default,update_options, and the constructor opt-intts-rt-v2:reduce_silence: trueaccepted and audibly effective