Skip to content

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.

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 play

The browser sends recorded speech to the speech service, sends the transcript as a normal message, and turns each reply into audio.

  1. Start the session on your server with sdkStart. Besides sessionId and the session token (avatarToken), it returns avatarServiceUrl and the agent’s voice settings: ttsVoice, ttsLang, sttLanguageCode, sttAlternativeLanguageCodes, speakingRate, vadThreshold.
  2. Transcribe each utterance with POST /stt on avatarServiceUrl, authorised with the session token.
  3. Send the transcript with sdkSendMessage, exactly like typed text.
  4. Speak each AiResponseEvent from sessionEvents with POST /tts and play the audio. Replies already come back short and list-free, because the platform adds spoken-reply rules to the prompt (see Spoken replies).
  5. 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 an InterruptedEvent.

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.