fix: pin consent_attestation on the Desktop client-direct TTS path

resolve_client_voice_config() now asserts tts.extra_body is {} when no
tts.openai extras are set and {consent_attestation: ...} when it is, and
the Desktop synthesizeSpeechClientDirect test asserts the spread field
reaches the openai speech request body. Removing either wiring
(extra_body kwarg in _resolve_tts_client_config, or the ...tts.extra_body
spread in voice-client-direct.ts) now turns the respective test red.
This commit is contained in:
teknium1
2026-09-19 01:26:03 -07:00
committed by Teknium
parent f16083763a
commit 935eef50ef
2 changed files with 12 additions and 1 deletions

View File

@@ -230,7 +230,10 @@ describe('synthesizeSpeechClientDirect', () => {
const fetchMock = vi.fn(async () => new Response(bytes, { status: 200 }))
vi.stubGlobal('fetch', fetchMock)
const audio = await synthesizeSpeechClientDirect(openaiTts, 'Hello there.')
const audio = await synthesizeSpeechClientDirect(
{ ...openaiTts, extra_body: { consent_attestation: 'I own this voice' } },
'Hello there.'
)
expect(new Uint8Array(audio)).toEqual(new Uint8Array([1, 2, 3]))
@@ -242,6 +245,8 @@ describe('synthesizeSpeechClientDirect', () => {
expect(body.voice).toBe('nova')
expect(body.input).toBe('Hello there.')
expect(body.speed).toBeUndefined()
// Server-resolved tts.openai extras (consent_attestation for cloned voices) reach the wire.
expect(body.consent_attestation).toBe('I own this voice')
})
it('speaks the elevenlabs tts shape with the voice in the path', async () => {

View File

@@ -139,6 +139,12 @@ def test_edge_tts_relays_openai_goes_direct(voice_home, monkeypatch):
assert tts["api_key"] == "sk_direct789"
assert tts["voice"] == "nova"
assert tts["model"]
# Unset tts.openai extras stay off the wire; set ones ride the direct config verbatim.
assert tts["extra_body"] == {}
voice_home({"tts": {"provider": "openai",
"openai": {"voice": "nova", "consent_attestation": "I own this voice"}}})
assert _resolve()["tts"]["extra_body"] == {"consent_attestation": "I own this voice"}
def test_elevenlabs_tts_direct_carries_voice_and_model(voice_home, monkeypatch):