Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
a520b90
Merge pull request #441 from micio86dev/release/1.62.0
micio86dev Nov 20, 2026
03d1894
Merge pull request #443 from micio86dev/hotfix/1.62.1
micio86dev Nov 20, 2026
18a4384
test(live): pin the failed-tick carry and cover the sweeper loop and …
micio86dev Nov 20, 2026
a7a87c6
docs(odd): track live-connect multi-guest, tier choice and cloned voice
micio86dev Nov 20, 2026
13b5492
feat(live): one host and up to three guests on the same invitation
micio86dev Nov 20, 2026
77603e5
feat(live): host and guest screens for one host and up to three guests
micio86dev Nov 20, 2026
e45316a
feat(live): host picks the translation tier, Premium falls back to St…
micio86dev Nov 20, 2026
c2df847
Merge branch 'feature/live-connect-tiers-server' into feature/live-co…
micio86dev Nov 20, 2026
9196322
feat(live): Enhanced tier with the host's cloned voice for Live Connect
micio86dev Nov 20, 2026
1b48a93
feat(live): host picks the translation tier on the setup screen
micio86dev Nov 20, 2026
ac3d37e
Merge branch 'feature/live-connect-tiers-client' into feature/live-co…
micio86dev Nov 20, 2026
786a10b
feat(live): Enhanced tier on the phone, with the host's cloned voice
micio86dev Nov 20, 2026
473c72b
feat(i18n): translate the 38 new Live Connect strings into the 83 loc…
micio86dev Nov 20, 2026
03cea3d
docs(odd): close out live-connect multi-guest, tiers and Enhanced tra…
micio86dev Nov 20, 2026
ea807b9
fix(live): a guest refused the Enhanced fallback keeps the conversati…
micio86dev Nov 20, 2026
1d6a08c
fix(live): cap opening charges, narrow the text echo guard, host-only…
micio86dev Nov 20, 2026
55a612a
Merge branch 'feature/live-connect-verify-fixes' into feature/live-co…
micio86dev Nov 20, 2026
60c59c8
test(e2e): the live journeys run without the echo filter (the mock an…
micio86dev Nov 20, 2026
953f7b5
test(live): data tests take a read lock and DDL re-runs the write loc…
micio86dev Nov 20, 2026
d46d978
Merge pull request #444 from micio86dev/feature/live-connect-multi-gu…
micio86dev Nov 20, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion client/e2e/live.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ test('a used link says session_full, an expired one invite_expired, a junk one i
await pickLanguage(second.page, 'lg', 'French');
await second.page.locator('#lg-consent').check();
await second.page.locator('#lg-join-btn').click();
await expect(second.page.locator('#lg-status')).toHaveText(en.liveErrSessionFull);
await expect(second.page.locator('#lg-status')).toHaveText(en.liveErrConversationFull);
await expect(second.page.locator('#lg-session')).toBeHidden();

// An invitation nobody used before it ran out.
Expand Down
4 changes: 4 additions & 0 deletions client/e2e/support/live-server.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ export async function startLiveStack(opts = {}) {
// Live Connect on, with the shortest billing interval so a few seconds of speech charge.
LIVE_CONNECT_ENABLED: '1',
LIVE_TOKEN_KEY,
// The mock upstream answers BOTH phones with the same sentence, which is exactly what the
// server's echo filter exists to drop; these journeys test the screens, not the filter
// (covered by tests/live_echo.rs and live_ws.rs), so it is off here.
LIVE_ECHO_FILTER: '0',
USAGE_UPDATE_INTERVAL: '2',
// The real rate is a fraction of a cent per tick, which an organisation (whole credits, one
// credit = one cent) would only be charged after about a minute. A deliberately high rate makes a
Expand Down
67 changes: 55 additions & 12 deletions client/src/pages/live.astro
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,52 @@ const T = (k: string): string => (en as Record<string, string>)[k] ?? '';
<a class="btn-primary lc-action" href="/" data-i18n="signIn">{T('signIn')}</a>
</section>

<!-- 1. SETUP. One choice (my language), one switch (transcript), one button. -->
<!-- 1. SETUP. My language, the translation tier, how many guests, one switch (transcript), one button. -->
<section class="lc-stack" id="lh-setup" hidden>
<div class="card lc-card-setup">
<div class="field">
<span class="field-label" data-i18n="liveYourLang">{T('liveYourLang')}</span>
<div id="lh-lang"></div>
</div>

<!-- The translation tier: filled by page-host.ts from GET /api/live/engines (Standard only
until it answers). Native radios inside labels, so arrow keys and names come free. -->
<div class="field lc-tiers" id="lh-tier-field">
<span class="field-label" id="lh-tier-label" data-i18n="liveTier">{T('liveTier')}</span>
<div class="lc-tier-list" id="lh-tiers" role="radiogroup" aria-labelledby="lh-tier-label"></div>
<small class="lc-hint" id="lh-tier-hint"></small>
<!-- Enhanced only (page-host.ts shows what applies): the host's cloned voice speaks the
translations on the guests' phones. The consent sentence is part of the checkbox's label,
so it is read out with it, and the box is never pre-checked. -->
<div class="lc-voice" id="lh-voice-field" hidden>
<label class="lc-check" for="lh-voice-clone">
<input type="checkbox" id="lh-voice-clone" />
<span>
<span data-i18n="liveVoiceClone">{T('liveVoiceClone')}</span>
<small class="lc-hint" data-i18n="liveVoiceCloneConsent">{T('liveVoiceCloneConsent')}</small>
</span>
</label>
</div>
<div class="lc-voiceprep" id="lh-voiceprep" hidden>
<span class="field-label" data-i18n="voicePrepTitle">{T('voicePrepTitle')}</span>
<p class="lc-note" data-i18n="voicePrepPrompt">{T('voicePrepPrompt')}</p>
<p class="lc-note" data-i18n="voicePrepSample">{T('voicePrepSample')}</p>
<progress id="lh-voiceprep-meter" class="lc-meter" max="1" value="0" hidden aria-label={T('voicePrepRecording')}></progress>
<button id="lh-voiceprep-record" class="btn-ghost" type="button" data-i18n="voicePrepRecord">{T('voicePrepRecord')}</button>
<p id="lh-voiceprep-status" class="lc-hint" role="status" aria-live="polite"></p>
</div>
</div>

<fieldset class="field lc-guests" id="lh-guests-field">
<legend class="field-label" data-i18n="liveGuests">{T('liveGuests')}</legend>
<div class="lc-seg">
<label class="lc-seg-opt"><input type="radio" name="lh-guests" value="1" checked /><span>1</span></label>
<label class="lc-seg-opt"><input type="radio" name="lh-guests" value="2" /><span>2</span></label>
<label class="lc-seg-opt"><input type="radio" name="lh-guests" value="3" /><span>3</span></label>
</div>
<small class="lc-hint" id="lh-guests-hint" aria-live="polite"></small>
</fieldset>

<label class="lc-check">
<input type="checkbox" id="lh-transcript" />
<span>
Expand All @@ -73,19 +111,24 @@ const T = (k: string): string => (en as Record<string, string>)[k] ?? '';

<!-- 2 + 3. INVITE while nobody has joined, then the conversation itself. -->
<section class="lc-stack" id="lh-session" hidden>
<!-- Several guests: how many seats are taken, kept even when the invitation is hidden. -->
<p class="lc-seats" id="lh-seats" role="status" aria-live="polite" hidden></p>
<div class="card lc-invite" id="lh-invite" hidden>
<h2 class="lc-title lc-invite-title" data-i18n="liveInviteTitle">{T('liveInviteTitle')}</h2>
<p class="lc-note" data-i18n="liveInviteHint">{T('liveInviteHint')}</p>
<img id="lh-qr" class="lc-qr" alt={T('liveQrAlt')} width="280" height="280" hidden />
<label class="field-label lc-link-label" for="lh-link" data-i18n="liveInviteLink">{T('liveInviteLink')}</label>
<div class="lc-link-row">
<input id="lh-link" class="lc-link" type="text" readonly dir="ltr" />
</div>
<div class="lc-link-actions">
<button id="lh-copy" class="btn-primary" type="button" data-i18n="copy">{T('copy')}</button>
<button id="lh-share" class="btn-ghost" type="button" data-i18n="liveShare" hidden>{T('liveShare')}</button>
<button id="lh-invite-toggle" class="btn-ghost lc-invite-toggle" type="button" aria-expanded="false" aria-controls="lh-invite-body" hidden data-i18n="liveInviteMore">{T('liveInviteMore')}</button>
<div class="lc-invite-body" id="lh-invite-body">
<h2 class="lc-title lc-invite-title" id="lh-invite-title" data-i18n="liveInviteTitle">{T('liveInviteTitle')}</h2>
<p class="lc-note" data-i18n="liveInviteHint">{T('liveInviteHint')}</p>
<img id="lh-qr" class="lc-qr" alt={T('liveQrAlt')} width="280" height="280" hidden />
<label class="field-label lc-link-label" for="lh-link" data-i18n="liveInviteLink">{T('liveInviteLink')}</label>
<div class="lc-link-row">
<input id="lh-link" class="lc-link" type="text" readonly dir="ltr" />
</div>
<div class="lc-link-actions">
<button id="lh-copy" class="btn-primary" type="button" data-i18n="copy">{T('copy')}</button>
<button id="lh-share" class="btn-ghost" type="button" data-i18n="liveShare" hidden>{T('liveShare')}</button>
</div>
<p class="lc-note" id="lh-invite-expires" data-i18n="liveInviteExpires">{T('liveInviteExpires')}</p>
</div>
<p class="lc-note" data-i18n="liveInviteExpires">{T('liveInviteExpires')}</p>
</div>
<div id="lh-room"></div>
</section>
Expand Down
82 changes: 3 additions & 79 deletions client/src/scripts/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { type LangMeta, LANGUAGES, langMeta } from './langmap';
// In-call modules are lazy-loaded at pre-join (spec 0105) — keep only their TYPES here so the
// landing entry chunk doesn't statically pull them in; the runtime values come from the
// `CallModules` namespaces returned by `loadCallModules()`.
import type { CartesiaManager, CartesiaSession } from './cartesia';
import type { CartesiaManager } from './cartesia';
import { type CallModules, loadCallModules } from './call-modules';
import { loadRemoteI18n } from './content';
import { setupScheduling } from './meetings';
Expand Down Expand Up @@ -66,6 +66,7 @@ import { ttsManager } from './tts/manager';
import { registerVoxIfInstalled } from './tts/register';
import type { ChatManager, ChatPayload } from './chat';
import { CHAT_MAX_HEIGHT, counterLabel, counterState, insertAt, recTimeLabel, resizeBox } from './chat-input';
import { recordVoiceSample } from './voice-sample';
import { checkUploadFile, cloneVoice, fetchAiPricing, fetchEnhancedSession, fileUploadEnabled, generateAiQuiz, saveQuizHistory, sendInvites, UPLOAD_ACCEPT, UPLOAD_MAX_BYTES, uploadChatFile } from './api';
import { buildInviteLink, MAX_INVITE_EMAILS, parseRoomParam, validateInviteEmails } from './invite';
import {
Expand Down Expand Up @@ -737,19 +738,7 @@ function ensureCartesiaManager(): CartesiaManager {
cartesiaManager = new callMods!.cartesia.CartesiaManager({
fetchSession: async () => {
const s = await fetchEnhancedSession();
if (!s) return null;
return {
token: s.token,
expiresAt: s.expires_at,
cartesiaVersion: s.cartesia_version,
sttEndpoint: s.stt.endpoint,
sttModel: s.stt.model,
sttModelsByLang: s.stt.models_by_lang ?? {},
ttsEndpoint: s.tts.endpoint,
ttsModel: s.tts.model,
voiceCloningEnabled: s.voice_cloning_enabled,
defaultVoiceId: s.default_voice_id ?? undefined,
} satisfies CartesiaSession;
return s ? callMods!.cartesia.toCartesiaSession(s) : null;
},
// Cartesia does STT + TTS but not translation — route each finalized segment through
// the server's Groq translator over the room WS (spec 0108).
Expand Down Expand Up @@ -876,71 +865,6 @@ function setVoicePrepState(s: VoicePrepState): void {
s === 'recording' ? t('voicePrepRecording') : s === 'saving' ? t('voicePrepSaving') : '';
}

/** Record a short mic sample, resolving once ≥3 s of actual speech is captured (energy
* threshold, not raw time), or null if too little speech by the time ceiling. */
function recordVoiceSample(
stream: MediaStream,
onProgress?: (fraction: number) => void,
): Promise<Blob | null> {
return new Promise((resolve) => {
let recorder: MediaRecorder;
try {
const mime = ['audio/webm;codecs=opus', 'audio/mp4', 'audio/webm'].find((ty) =>
MediaRecorder.isTypeSupported?.(ty),
);
recorder = new MediaRecorder(stream, mime ? { mimeType: mime } : undefined);
} catch {
resolve(null);
return;
}
const chunks: BlobPart[] = [];
recorder.ondataavailable = (e) => {
if (e.data.size) chunks.push(e.data);
};
const Ctx =
window.AudioContext ??
(window as unknown as { webkitAudioContext: typeof AudioContext }).webkitAudioContext;
const ctx = new Ctx();
const analyser = ctx.createAnalyser();
analyser.fftSize = 512;
ctx.createMediaStreamSource(stream).connect(analyser);
const buf = new Float32Array(analyser.fftSize);
let speechMs = 0;
let elapsedMs = 0;
const TICK = 100;
const SPEECH_RMS = 0.02; // energy floor that counts as speech (not room noise)
const MIN_SPEECH_MS = 3000; // Cartesia IVC wants ≥3 s of actual speech
const MAX_MS = 8000; // hard ceiling so we never hold the join hostage
recorder.onstop = () => {
const type = recorder.mimeType || 'audio/webm';
resolve(speechMs >= MIN_SPEECH_MS && chunks.length ? new Blob(chunks, { type }) : null);
};
const timer = setInterval(() => {
analyser.getFloatTimeDomainData(buf);
let sum = 0;
for (const v of buf) sum += v * v;
if (Math.sqrt(sum / buf.length) > SPEECH_RMS) speechMs += TICK;
onProgress?.(Math.min(1, speechMs / MIN_SPEECH_MS));
elapsedMs += TICK;
if (speechMs >= MIN_SPEECH_MS + 500 || elapsedMs >= MAX_MS) {
clearInterval(timer);
void ctx.close().catch(() => {});
try {
recorder.stop();
} catch {
resolve(null);
}
}
}, TICK);
try {
recorder.start();
} catch {
clearInterval(timer);
resolve(null);
}
});
}

/** Show the voice-prep panel for eligible users (signed-in, cloning on, client-direct engine)
* in its initial state: a "ready" outcome + Re-record when a clone already exists, otherwise
* a prompt to record. Called on pre-join entry and whenever the chosen engine changes. */
Expand Down
104 changes: 104 additions & 0 deletions client/src/scripts/cartesia.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import {
accumulate,
CartesiaManager,
closeSttGraph,
openSttGraph,
parseTtsFrame,
toCartesiaSession,
ttsRequest,
type CartesiaManagerOptions,
type CartesiaSession,
IDLE_FLUSH_MS,
Expand Down Expand Up @@ -826,3 +831,102 @@ describe('CartesiaManager', () => {
tts.onclose?.({ code: 1000 }); // stale close after teardown → ignored
});
});

// ---- Shared with Live Connect (spec 0121 S5): the pieces Meet's manager is built from ----------

describe('toCartesiaSession', () => {
it('maps the server answer exactly as Meet\'s fetchSession always did', () => {
const out = toCartesiaSession({
token: 'T',
expires_at: 123,
cartesia_version: '2026-03-01',
stt: { endpoint: 'wss://s', model: 'ink-whisper', models_by_lang: { en: 'ink-2' } },
tts: { endpoint: 'wss://t', model: 'sonic-3.5' },
voice_cloning_enabled: true,
default_voice_id: 'D',
});
expect(out).toEqual({
token: 'T',
expiresAt: 123,
cartesiaVersion: '2026-03-01',
sttEndpoint: 'wss://s',
sttModel: 'ink-whisper',
sttModelsByLang: { en: 'ink-2' },
ttsEndpoint: 'wss://t',
ttsModel: 'sonic-3.5',
voiceCloningEnabled: true,
defaultVoiceId: 'D',
});
});

it('defaults the optional parts: no per-language models, no default voice', () => {
const out = toCartesiaSession({
token: 'T',
expires_at: 1,
cartesia_version: 'v',
stt: { endpoint: 'e', model: 'm' },
tts: { endpoint: 'e', model: 'm' },
voice_cloning_enabled: false,
default_voice_id: null,
});
expect(out.sttModelsByLang).toEqual({});
expect(out.defaultVoiceId).toBeUndefined();
});
});

describe('ttsRequest / parseTtsFrame', () => {
it('builds the one-shot Sonic request (raw PCM16 at 24 kHz, one context, no continuation)', () => {
expect(JSON.parse(ttsRequest(SESSION, 'V', 'Hello', 'it', 'ctx-1'))).toEqual({
model_id: 'sonic-3.5',
transcript: 'Hello',
voice: { mode: 'id', id: 'V' },
output_format: { container: 'raw', encoding: 'pcm_s16le', sample_rate: 24000 },
language: 'it',
context_id: 'ctx-1',
continue: false,
});
});

it('parses chunk / done / error frames and rejects binary or malformed ones', () => {
expect(parseTtsFrame(JSON.stringify({ type: 'chunk', context_id: 'c', data: 'AAA' }))).toEqual({ type: 'chunk', contextId: 'c', data: 'AAA' });
expect(parseTtsFrame(JSON.stringify({ type: 'done', context_id: 'c' }))).toEqual({ type: 'done', contextId: 'c', data: undefined });
expect(parseTtsFrame('nope')).toBeNull();
expect(parseTtsFrame(new ArrayBuffer(1))).toBeNull();
});
});

describe('openSttGraph / closeSttGraph', () => {
beforeEach(() => installMocks());

it('wires a 16 kHz capture graph that hands every chunk to the callback, and tears down cleanly', async () => {
const chunks: ArrayBuffer[] = [];
const graph = await openSttGraph(fakeStream(), (c) => chunks.push(c));
expect(graph).not.toBeNull();
const node = workletNodes[0];
const buf = new ArrayBuffer(4);
node.port.onmessage?.({ data: buf });
expect(chunks).toEqual([buf]);
closeSttGraph(graph as never);
expect(node.port.onmessage).toBeNull();
});

it('returns null and leaves nothing open when cancelled while the worklet loads, or when the track vanished', async () => {
expect(await openSttGraph(fakeStream(), () => {}, () => true)).toBeNull();
expect(workletNodes).toHaveLength(0);
expect(await openSttGraph(fakeStream([]), () => {})).toBeNull();
});

it('throws on a real failure so the caller can handle it', async () => {
mockCfg.sourceThrows = true;
await expect(openSttGraph(fakeStream(), () => {})).rejects.toThrow('source fail');
});

it('closing a partial or already-closed graph never throws', () => {
closeSttGraph({});
closeSttGraph({
node: { port: { onmessage: null }, disconnect: () => { throw new Error('x'); } } as never,
src: { disconnect: () => { throw new Error('y'); } } as never,
ctx: { close: () => Promise.reject(new Error('z')) } as never,
});
});
});
Loading
Loading