Voice Interface
A spoken conversation uses the same session and events as a text chat, plus speech-to-text before each turn and text-to-speech after each reply. The <vai-avatar> component does all of it for you: microphone capture, voice-activity detection, transcription, speech playback, lip-sync and barge-in. Use it unless you need your own voice UI.
Try it: play.wetel.dev/sdk/demo.html runs a voice session with a 3D avatar. Its page source is the reference implementation of every step below.
The pipeline, if you build your own
Section titled “The pipeline, if you build your own”In short: the browser sends recorded speech to the speech service for a transcript, sends that transcript as a normal message, and turns the reply text into audio to play.
sequenceDiagram participant U as Browser participant AS as avatar-service (REST) participant API as Wetel GraphQL API
U->>AS: POST /stt (recorded speech) AS-->>U: transcript U->>API: sdkSendMessage(transcript) API-->>U: AiResponseEvent on sessionEvents U->>AS: POST /tts (reply text) AS-->>U: audio to playThe browser sends recorded speech to the speech service, sends the transcript as a normal message, and turns each reply into audio.
- Start the session on your server with
sdkStart. BesidessessionIdand the session token (avatarToken), it returnsavatarServiceUrland the agent’s voice settings:ttsVoice,ttsLang,sttLanguageCode,sttAlternativeLanguageCodes,speakingRate,vadThreshold. - Transcribe each utterance with
POST /sttonavatarServiceUrl, authorised with the session token. - Send the transcript with
sdkSendMessage, exactly like typed text. - Speak each
AiResponseEventfromsessionEventswithPOST /ttsand play the audio. Replies already come back short and list-free, because the platform adds spoken-reply rules to the prompt (see Spoken replies). - Barge-in: when the user starts talking over the agent, stop playback at once and call
interruptSession(sessionId)with the session token. The server cancels the reply in progress and publishes anInterruptedEvent.
Select AvatarSpeakEvent and InterruptedEvent in your subscription as well as AiResponseEvent; a union member you do not select never arrives. See Events and Subscriptions.
Phone calls do not use this pipeline: see Telephony.
See also: Avatar and 3D rendering, Avatar service REST API, Choosing languages and voices, Live demos.