AI Segments are configured in the Customize area for each video (Customize V2). You need an ElevenLabs API key saved on your workspace before the player can generate audio.
What you can do
- Define one or more segments with start and end time (in seconds).
- Assign an ElevenLabs voice per segment using a Voice ID from your ElevenLabs account.
- Write a prompt template that can include placeholders filled from data you pass on the page.
- Control voice volume and optionally duck (lower) the main video audio while the AI voice plays.
- Preload audio shortly before each segment so playback feels instant when the viewer reaches that part of the video.
Prerequisites
- TrackPlay player v2 / Customize V2 for the video you want to enhance.
- An ElevenLabs account and an API key (API keys in ElevenLabs).
- Optional: Voice IDs from ElevenLabs for each voice you want to use (Voices or your cloned voices).
Step 1: Connect ElevenLabs
You can connect ElevenLabs from Integrations or from Workspace settings (both save the same workspace API key).From Integrations (recommended)
- Open your TrackPlay dashboard and go to Integrations.
- Click Add integration (or find ElevenLabs on the grid).
- Click Connect on ElevenLabs, then Configure.
- Paste your ElevenLabs API key and click Save.
From Workspace settings
- Go to Settings → ElevenLabs (or your workspace’s ElevenLabs page).
- Paste your API key and save.
Step 2: Configure AI Segments on a video
- Open the video → Customize (V2).
- Open the AI Segments tab.
- Turn Enable AI Segments on.
- Set Preload seconds (how many seconds before each segment’s start time the player begins requesting/generated audio). Default is often 30 seconds.
- Click Add segment and configure:
- Save / Deploy the video so the updated options are baked into the player build.
Personalized prompts with trackplay_data
The player can replace placeholders in your prompt using window.trackplay_data on the page where the video is embedded.
Example prompt:
- Use
{key}wherekeymatches a property ontrackplay_data. - If a key is missing, the placeholder may be left as-is in the text.
Viewer experience: sound and autoplay
To respect browser rules and avoid wasting generation when the viewer cannot hear audio:- The player does not request or play AI segment audio while the main video is muted (typical muted autoplay state).
- After the viewer unmutes (or otherwise enables audible playback), the player can preload and play AI segments as configured.
How generation and delivery work (overview)
- When a viewer is in range to need a segment, the player calls TrackPlay’s events infrastructure (
e.trackplay.io) withsegment_id, currentvideo_time, session/device IDs, andtrackplay_data(dynamic fields for your prompt). - The server loads voice ID and prompt template from your saved video settings (not from the browser). It checks that
video_timeis inside the segment’s preload window, then builds the spoken line by filling{placeholders}fromtrackplay_data. Same pattern as on the page. - You cannot send arbitrary text or a different voice from the client; that prevents abuse (e.g. via
curl). - The service uses your workspace’s ElevenLabs API key, then caches audio by voice + resolved text so repeat views don’t re-bill ElevenLabs.
- Cached audio is served from TrackPlay’s CDN; viewers receive a URL to the MP3.
You do not put your ElevenLabs API key in the embed or in
trackplay_data. Only your dashboard stores the key.Analytics events
The player reports AI segment activity like other video analytics (via the same pipeline as your workspace events). Useful fields typically include segment id and start/end times so you can analyze how often segments load and play. (Exact field names in your analytics UI may vary as the product evolves.)Troubleshooting
“No audio” or segments never play
- Confirm ElevenLabs is connected and the integration status is ready after saving the key.
- Confirm AI Segments is enabled and the video was deployed after changes.
- Ensure the viewer has unmuted the video if you use muted autoplay.
- Check Voice ID and prompt in ElevenLabs (invalid voice or empty prompt can cause failures).
Audio late or missing on first watch
- Increase Preload seconds so generation can finish before the segment starts (especially for longer lines).
- First-ever generation for a given text+voice can take longer than cached playback.
Placeholders not replaced
- Verify
window.trackplay_datais set and keys match{placeholder}names exactly. - Keys with empty values may be skipped.
Testing on localhost
- Playback verification ties requests to analytics events in Elasticsearch. Right at the beginning of playback, events may still be buffered before they appear in search. TrackPlay allows generation for a short window after
video_time0 in that case, as long as workspace, video, session, and device IDs are valid and rate limits pass. - If you self-host the events server, you can tune
AI_SEGMENT_EARLY_PLAYBACK_MAX_VIDEO_TIME(seconds, default60, clamped to a maximum of180; set0to disable the bypass). The window is deliberately tight. A wider one turns the endpoint into free unauthenticated text-to-speech for anyone who finds it.
Related documentation
- Integration configuration: overview of all integrations.
- Dynamic options: runtime player options.
- Domain whitelist: allowed embed domains.
- Video events: player-side event hooks.
