Repository navigation
Replace Relay Realtime SDK examples on TTS provider pages with Server SDK examples - #876
Conversation
… SDK examples Swap the deprecated @signalwire/realtime-api tab on the Azure, Cartesia, Deepgram, ElevenLabs, Google Cloud, OpenAI, and Amazon Polly pages for Python and TypeScript Relay client samples, and lead each SWML example with a Server SDK SWMLService server ahead of the existing YAML. Refs #600
hey-august
left a comment
There was a problem hiding this comment.
Approving. I re-ran the checks against signalwire-sdk==3.4.1 and @signalwire/sdk@2.0.5:
- All 21 Python samples compile, and all 21 TypeScript samples pass
tsc --strictas ES modules. - All 28 SWML servers return the same document as the YAML beside them, and a request without credentials gets
401. - The Relay payload matches what
mod_infrastructureaccepts:play[].paramstakestextandvoice(relay_apis.c:1265). The voice string goes through the same lookup the SWMLsay:path uses, and strings with:or-(amazon.Ruth:neural, the Cartesia UUID) pass validation. - The links and anchors resolve.
Two optional nits:
- Python 3.4.1 has
call.play_tts(text, voice=..., on_completed=...)(relay/call.py:580). It sends the same request and is closer to the oldplayTTS(). Only the TypeScript SDK lacks it. - The Python Relay sample nests
params, but the TypeScript one uses the flat item. The SDK converts both to the same request, but the two tabs look like they use different structures. Using one form in both would fix that.
# Conflicts: # fern/products/platform/pages/calling/voice/TTS/azure.mdx # fern/products/platform/pages/calling/voice/TTS/cartesia.mdx # fern/products/platform/pages/calling/voice/TTS/deepgram.mdx # fern/products/platform/pages/calling/voice/TTS/elevenlabs.mdx # fern/products/platform/pages/calling/voice/TTS/google.mdx # fern/products/platform/pages/calling/voice/TTS/openai.mdx # fern/products/platform/pages/calling/voice/TTS/polly.mdx
Every TTS provider page now builds the TypeScript `tts` play item as
`{ type: "tts", params: { text, voice } }`, matching the Python tab and
the Relay wire format. @signalwire/sdk 2.0.5 passes an item that already
has `params` through unchanged, so the request is the same as before.
Refs #876.
|
@hey-august Thanks for the re-run and the approval. I took nit 2 and kept
Checks, against
|
Summary
@signalwire/realtime-apicall.playTTS()fragment) on seven TTS provider pages with a WebSocket (Relay) tab. The tab holds complete Python and TypeScript Relay client handlers that answer a call and play the page's greeting with that provider's voice string.aiagent withlanguages, andset: say_voice+play) now follows Python and TypeScriptSWMLServiceservers that serve that same document. The YAML stays as it was.TTS/index.mdx(open PRs fix(swml): align the SWML method reference with platform behavior #852 and Add Speak text on a call guide #789 change it).Pages:
fern/products/platform/pages/calling/voice/TTS/azure.mdx: https://signalwire.com/docs/platform/voice/tts/azurefern/products/platform/pages/calling/voice/TTS/cartesia.mdx: https://signalwire.com/docs/platform/voice/tts/cartesiafern/products/platform/pages/calling/voice/TTS/deepgram.mdx: https://signalwire.com/docs/platform/voice/tts/deepgramfern/products/platform/pages/calling/voice/TTS/elevenlabs.mdx: https://signalwire.com/docs/platform/voice/tts/elevenlabsfern/products/platform/pages/calling/voice/TTS/google.mdx: https://signalwire.com/docs/platform/voice/tts/gcloudfern/products/platform/pages/calling/voice/TTS/openai.mdx: https://signalwire.com/docs/platform/voice/tts/openaifern/products/platform/pages/calling/voice/TTS/polly.mdx: https://signalwire.com/docs/platform/voice/tts/amazon-pollyCloses #880
Refs #600
Verification
All checks ran against the pinned
signalwire-sdk==3.4.1and@signalwire/sdk@2.0.5, installed in a scratch directory.py_compileandpyflakespass on all 21.tsc --strictpasses on all 21. This also confirms that the one@ts-expect-erroris needed, because an unused directive fails the compile.pythonand TypeScript as.mjsundernode, and fetched/swmlwith basic auth. Every document matches the YAML beside it. A request without credentials gets401.ttsitem. I sent thecalling.playrequest from each SDK through a stub client. Both send the same payload,{"type": "tts", "params": {"text": ..., "voice": "<engine>.<voice>"}}. That is the same payload the deprecated@signalwire/realtime-apiplayTTS({ text, voice })built./docs/server-sdks, plus/docs/platform/voice/make-and-receive-calls#answer-a-call-via-swmland#answer-a-call-via-websocket-relay, checked by hand against the slugs and headings.yarn fern-md-check: all MDX files are valid.Notes for reviewers
aisample. In 2.0.5 theaiverb'spromptis typedstring | Array, but the verb needs{ text }. The sample uses a commented// @ts-expect-errorabove thepromptline, so it still type-checks.SWMLServiceand notAgentBasefor the AI agent. The PythonAgentBase.add_language()splitsamazon.Ruth:neuralintovoice,engine, andmodel, andengineis deprecated in the SWML reference.SWMLServicesends the voice string exactly as written.playTTS()in the pinned TypeScript SDK. The TypeScript Server SDK reference documentsplayTTS(), but@signalwire/sdk@2.0.5doesn't have it. Python 3.4.1 does haveplay_tts(), but both Relay samples useplay()with the same nested{ type: "tts", params: { text, voice } }item, so the two tabs match each other and the Relay wire format (the same choicespeak-text.mdxmakes).play: { url: "say:..." }. The YAML uses theplay: "say:..."string shorthand. Both mean the same thing.signalwire-sdk3.7.5,@signalwire/sdk3.7.1). I kept the house pins because bumps go to every guide in one PR.