Text-to-Avatar
Scripted avatar speech with Experience presenter mode.
What is it?
Text-to-avatar is not a separate API in Liforma today. It is what you get when
you run an Avatar Experience in presenter mode and call speak() with your script. The hosted player
handles TTS, lip-sync, and facial animation for each line.
Use this when you already know what the character should say and your app (not the managed LLM) owns the script — announcements, lesson intros, onboarding steps, or any predetermined dialogue.
When to use presenter mode
- Scripted lines from your app via
experience.speech.speak({ text }) - No automatic conversational loop — the character does not reason or reply on its own
- Optional microphone capture when you also need learner input (manual or listen-once flows)
For open-ended chat where the character listens, thinks, and responds dynamically, use conversation mode instead. See Experience API.
Svelte
Embed with <Experience>, set mode="presenter", and call speak() from onStarted (after the player unlocks audio) or via bind:this on an ExperienceHandle.
For speech-only flows with no microphone, set speechInputMode="off". For scripted
tutor lines plus explicit Start/Stop capture, use speechInputMode="manual" — see Guided Scripted Practice.
<script lang="ts">
import {
Experience,
type ExperienceHandle
} from '@liforma/client/svelte';
let experience: ExperienceHandle | undefined = $state();
async function speakIntro() {
await experience?.speech.speak({ text: 'Hello! Welcome to the lesson.' });
}
<\/script>
<Experience
bind:this={experience}
experienceId="exp_T0I7ACMQLBMPG6K"
mode="presenter"
speechInputMode="off"
onStarted={speakIntro}
/> JavaScript
Same pattern with the framework-neutral Experience class:
import { Experience } from '@liforma/client';
const experience = await Experience.startSession({
experienceId: 'exp_T0I7ACMQLBMPG6K',
mode: 'presenter',
speechInputMode: 'off'
});
experience.on('started', async () => {
await experience.speech.speak({ text: 'Hello! Welcome to the lesson.' });
});
await experience.attach({ container: '#avatar' }); Call speak() only after started (or from an on('started') handler). Speech methods reject if audio is not yet unlocked. Full speak options and events: Experience API.
Plain HTML
Load the CDN script and use <liforma-experience> for a basic embed. For
scripted speak() calls from host JavaScript, use the class API after the element
boots — see Web Component and JavaScript SDK.
When to use something else
- Audio only, no character — standalone TTS is documented under Text-to-Speech (not yet a separate shipped helper; TTS runs inside experiences today).
- Interactive dialogue — use conversation mode on an Avatar Experience.
- Custom “brain” in the browser — presenter mode with
conversationProcessor; see Custom Conversation Processor.