spatius_avatar_python extension receives agent speech audio inside that graph, sends it to Spatius, and configures Motion Server to publish synchronized audio and motion data into the configured Agora channel.
If you start a managed Agora Convo AI agent through the REST API, use Convo AI Agent instead. In that path, Spatius is configured through the Convo AI properties.avatar provider block.
spatius_avatar_python
TEN extension source in the TEN Framework repository.
How it works
- Your TEN graph runs the voice agent pipeline.
- The TTS stage sends PCM audio frames to
spatius_avatar_pythonthroughpcm_frame. spatius_avatar_pythonstarts a Spatius server session withAgoraEgressConfig.- Motion Server publishes synchronized avatar audio and motion data into the Agora channel.
- Your client joins the same channel and renders the avatar with
AgoraProvider.
| TEN input | Purpose |
|---|---|
audio_frame_in: pcm_frame | Agent speech audio sent to Spatius. |
data_in: tts_audio_end | End-of-speech signal. The extension sends EOF to Spatius. |
cmd_in: flush | Interruption signal. The extension interrupts the current avatar speech. |
Configure
Required fields
| Field | Required | Description |
|---|---|---|
params.spatius_api_key | Yes | Your Spatius API key. Keep it server-side. |
params.spatius_app_id | Yes | Your Spatius app ID. |
params.spatius_avatar_id | Yes | Avatar to use. |
params.agora_appid | Yes | Agora App ID. |
params.agora_channel | Yes | Agora channel where Motion Server publishes avatar output. |
params.agora_uid | Yes | Numeric Agora UID used by the avatar publisher. Must parse as an integer. |
params.agora_token | Conditional | Agora RTC token for the avatar publisher UID. Required unless params.agora_appcert is provided. |
params.agora_appcert | Conditional | Agora App Certificate. If params.agora_token is empty, the extension generates an RTC token from this value. |
Optional fields
| Field | Default | Description |
|---|---|---|
params.region | SDK default | Spatius region. See Regions. |
params.sample_rate | 24000 | Audio sample rate expected by the extension. Audio frames with other sample rates are rejected by the base extension. |
params.session_expire_minutes | 30 | Lifetime for the Spatius server session and generated Agora token privilege window. |
dump | false | Write inbound audio to disk for debugging. |
dump_path | Empty | Directory for audio dumps when dump is enabled. |
channel | Empty | Alias used by the extension to populate params.agora_channel when present. |
Token behavior
spatius_avatar_python accepts either a prebuilt Agora RTC token or an App Certificate:
- If
params.agora_tokenis set, the extension uses it directly. - If
params.agora_tokenis empty andparams.agora_appcertis set, the extension generates a token forparams.agora_uid,params.agora_channel, andparams.session_expire_minutes.
Graph wiring notes
Placespatius_avatar_python after the stage that produces final avatar speech audio. It expects PCM audio frames at the configured sample rate and sends those bytes to Spatius without resampling.
Use the same Agora channel on both sides:
| Component | Channel field |
|---|---|
| TEN extension | params.agora_channel |
| Client | player.connect({ channel }) or the platform equivalent |
new_avatar_session() from the Spatius Python SDK and configures:
yieldAudioData() or yieldFramesData() manually; AgoraProvider owns the channel-to-renderer data flow.
Next steps
Overview
Review the end-to-end Agora Convo AI architecture.
Convo AI Agent
Configure Spatius in the managed Convo AI start-agent request.
Client
Join the Agora channel and render avatar output with
AgoraProvider.