[Model] Integrate AURA into Full-Duplex Runtime (#7633)
This commit is contained in:
1 parent
d397a2f547
commit
62b15142bd
77 files changed
+7695
-457
No files matched your search
@@ -9,6 +9,7 @@ This implements [RFC #7222](https://github.com/vllm-project/vllm-omni/issues/722
|
||||
| `minicpm-native` | Model-controlled listen/speak, continuous audio input | Frames accompany audio | Yes |
|
||||
| `qwen3-turn --stt` (default) | User presses **Send turn** | No | No |
|
||||
| `qwen3-turn --vad` | Server detects trailing silence; speech interrupts replies | Sampled frames with each spoken turn | Yes |
|
||||
| `aura-ptt` | Hold **Hold to talk**; release commits. Hold also stops local playback | Sticky frames with speech; vision-follow every 2 frames only while unlocked (locked from PTT release until text-final / listen) | Yes |
|
||||
|
||||
Qwen3 VAD uses an engine-owned duplex plugin: microphone upload continues
|
||||
while replies stream, and speech can interrupt generation and playback. The
|
||||
@@ -29,6 +30,38 @@ The compatibility wrapper serves the shared assets with `minicpm-native`.
|
||||
The current native query, `extra_body`, reference voice, continuous microphone
|
||||
upload, camera frames and playback acknowledgements are retained.
|
||||
|
||||
## AURA: push-to-talk duplex
|
||||
|
||||
AURA has no client VAD. Start the duplex serve, then the thin wrapper:
|
||||
|
||||
```bash
|
||||
bash examples/online_serving/aura_omni/run_duplex_smoke_serve.sh
|
||||
|
||||
python -m examples.online_serving.aura_omni.realtime_web \
|
||||
--ws-backend ws://127.0.0.1:8099 --model aurateam/AURA --port 7862
|
||||
```
|
||||
|
||||
Or select the profile on the shared host:
|
||||
|
||||
```bash
|
||||
python -m examples.online_serving.realtime_web --profile aura-ptt \
|
||||
--ws-backend ws://127.0.0.1:8099 --model aurateam/AURA --port 7862
|
||||
```
|
||||
|
||||
Open the UI, start a session, optionally enable **Camera**, then **hold**
|
||||
**Hold to talk** to stream `is_speech=true` PCM (with sticky camera frames).
|
||||
**Release** to `input_audio_buffer.commit`. Holding the button stops playback
|
||||
in the browser only; the in-flight response is not cancelled on the server.
|
||||
With the camera on, frames are still captured at 2 fps. While the button is
|
||||
up they are committed once per two frames (`is_speech=false` + silent PCM).
|
||||
Both frames of that commit are sent and packed as one video (`<|video_pad|>`).
|
||||
Turns still open from this client commit, not from a server-side auto trigger.
|
||||
but only after the prior spoken turn unlocks (text-final or `response.listen`).
|
||||
Release itself locks vision immediately so a follow-up frame cannot abort the
|
||||
just-committed speech turn on Stage0/1 (`max_num_seqs=1`). Audio still playing
|
||||
does not hold the next vision turn once text is done.
|
||||
MiniCPM / Qwen profiles do not set `pushToTalk`, so the PTT control stays hidden.
|
||||
|
||||
## Qwen3: explicit-turn STT adapter
|
||||
|
||||
Start the backend, then the UI in a second terminal:
|
||||
@@ -49,6 +82,7 @@ accepts only model selection, so system-prompt controls are hidden in this mode.
|
||||
The adapter follows the shipped `qwen3_omni/openai_realtime_client.py` and
|
||||
`vllm_omni/entrypoints/openai/realtime_connection.py`:
|
||||
|
||||
|
||||
1. Explicit `duplex=0` selects the legacy STT handler on a turn deployment.
|
||||
It does not enable STT on a duplex deployment.
|
||||
2. Send `{type: "session.update", model: ...}` and `commit(final=false)`.
|
||||
@@ -181,7 +215,7 @@ conversation API. This demo does not add WebRTC, semantic VAD, or tool calling.
|
||||
|
||||
## Shared host options
|
||||
|
||||
The shared entry point can select either profile explicitly:
|
||||
The shared entry point can select a profile explicitly:
|
||||
|
||||
```bash
|
||||
python -m examples.online_serving.realtime_web --profile qwen3-turn \
|
||||
@@ -193,7 +227,7 @@ python -m examples.online_serving.realtime_web --profile qwen3-turn \
|
||||
- `--public-realtime-url`: optional browser-visible WebSocket URL; otherwise the
|
||||
static host proxies `/v1/realtime` on the same origin.
|
||||
- `--host`, `--port`: UI bind address and port (default port 7862).
|
||||
- `--ref-audio`: required for MiniCPM; rejected for Qwen3.
|
||||
- `--ref-audio`: required for MiniCPM; rejected for Qwen3 and AURA.
|
||||
|
||||
Microphone and camera access require `localhost` or HTTPS. For a remote backend,
|
||||
use an SSH tunnel to the UI host or an HTTPS reverse proxy with WebSocket support.
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
<div class="call-actions">
|
||||
<button id="callButton" class="primary" type="button">Start session</button>
|
||||
<button id="sendTurnButton" class="secondary" type="button" hidden disabled>Send turn</button>
|
||||
<button id="pttButton" class="secondary" type="button" hidden disabled>Hold to talk</button>
|
||||
<button id="muteButton" class="secondary" type="button" disabled>Mute</button>
|
||||
<button id="cameraButton" class="secondary" type="button" disabled>Camera</button>
|
||||
<video id="cameraPreview" muted playsinline style="display:none;width:96px;height:72px;border-radius:8px;object-fit:cover;background:#000"></video>
|
||||
@@ -75,6 +76,7 @@
|
||||
<script src="static/profiles/common.js?v=__FULL_DUPLEX_APP_VERSION__"></script>
|
||||
<script src="static/profiles/minicpm_native.js?v=__FULL_DUPLEX_APP_VERSION__"></script>
|
||||
<script src="static/profiles/qwen3_turn.js?v=__FULL_DUPLEX_APP_VERSION__"></script>
|
||||
<script src="static/profiles/aura_ptt.js?v=__FULL_DUPLEX_APP_VERSION__"></script>
|
||||
<script src="static/app.js?v=__FULL_DUPLEX_APP_VERSION__"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -5,6 +5,7 @@
|
||||
const profile = window.OmniRealtimeProfiles[config.profile || 'minicpm-native'](config);
|
||||
const callButton = document.getElementById('callButton');
|
||||
const sendTurnButton = document.getElementById('sendTurnButton');
|
||||
const pttButton = document.getElementById('pttButton');
|
||||
const muteButton = document.getElementById('muteButton');
|
||||
const cameraButton = document.getElementById('cameraButton');
|
||||
const cameraPreview = document.getElementById('cameraPreview');
|
||||
@@ -28,6 +29,7 @@
|
||||
const ECHO_GUARD_MS = 300;
|
||||
const INITIAL_PLAYBACK_BUFFER_MS = 400;
|
||||
const SESSION_CLOSE_TIMEOUT_MS = 1000;
|
||||
const SILENT_PCM_SAMPLES = 160;
|
||||
|
||||
const PROMPT_PRESETS = profile.presets;
|
||||
document.title = profile.title;
|
||||
@@ -36,7 +38,21 @@
|
||||
document.getElementById('profileDescription').textContent = profile.description;
|
||||
document.getElementById('policyLabel').textContent = profile.policy;
|
||||
cameraButton.hidden = !profile.camera;
|
||||
if (profile.cameraPreviewLarge) {
|
||||
cameraPreview.classList.add('camera-preview-large');
|
||||
// Inline, so a cached stylesheet cannot leave the 96×72 HTML default.
|
||||
cameraPreview.style.width = '100%';
|
||||
cameraPreview.style.height = 'auto';
|
||||
cameraPreview.style.maxHeight = '480px';
|
||||
cameraPreview.style.flex = '0 0 100%';
|
||||
const cameraActions = cameraPreview.closest('.call-actions');
|
||||
if (cameraActions) {
|
||||
cameraActions.style.flexWrap = 'wrap';
|
||||
cameraActions.style.gridColumn = '1 / -1';
|
||||
}
|
||||
}
|
||||
sendTurnButton.hidden = !profile.clientCommit;
|
||||
pttButton.hidden = !profile.pushToTalk;
|
||||
promptPreset.replaceChildren();
|
||||
for (const name of [...Object.keys(PROMPT_PRESETS), 'custom']) {
|
||||
const option = document.createElement('option');
|
||||
@@ -64,6 +80,12 @@
|
||||
let cameraStream = null;
|
||||
let cameraTimer = null;
|
||||
let cameraPendingFrame = null;
|
||||
let cameraLastFrame = null;
|
||||
// AURA vision clock only. Other profiles leave this empty and never read it.
|
||||
let visionFollowQueue = [];
|
||||
let visionTurnLocked = false;
|
||||
let suppressedPlaybackId = null;
|
||||
let pttHeld = false;
|
||||
const cameraCanvas = document.createElement('canvas');
|
||||
let playbackRate = OUTPUT_RATE;
|
||||
let pendingCapture = [];
|
||||
@@ -87,6 +109,8 @@
|
||||
const interruptedResponses = new Set();
|
||||
const pendingEvents = new Set();
|
||||
let assistantTextChannel = null;
|
||||
const assistantRowByResponse = new Map();
|
||||
let lastClosedAssistantText = '';
|
||||
let connectionReady = false;
|
||||
let turnCounter = 0;
|
||||
let stopping = null;
|
||||
@@ -134,7 +158,7 @@
|
||||
assistantTextChannel = null;
|
||||
if (profile.halfDuplex) pendingCapture = [];
|
||||
sendTurnButton.disabled = !profile.clientCommit;
|
||||
setModel(profile.waiting);
|
||||
if (!pttHeld) setModel(profile.waiting);
|
||||
}, ECHO_GUARD_MS);
|
||||
}
|
||||
|
||||
@@ -240,6 +264,7 @@
|
||||
current.value = finalText;
|
||||
current.text.textContent = finalText;
|
||||
}
|
||||
if (role === 'assistant' && current.value) lastClosedAssistantText = current.value;
|
||||
current.row.classList.remove('turn-live');
|
||||
if (role === 'user') liveUserTurn = null;
|
||||
else liveAssistantTurn = null;
|
||||
@@ -317,11 +342,67 @@
|
||||
}
|
||||
|
||||
function microphoneUploadEnabled() {
|
||||
return running && connectionReady && !muted && (!profile.halfDuplex || !assistantActive);
|
||||
if (!running || !connectionReady || muted) return false;
|
||||
if (profile.pushToTalk) return pttHeld;
|
||||
return !profile.halfDuplex || !assistantActive;
|
||||
}
|
||||
|
||||
function queueVisionFrame(frame) {
|
||||
visionFollowQueue.push(frame);
|
||||
if (visionFollowQueue.length > 2) visionFollowQueue.shift();
|
||||
}
|
||||
|
||||
function commitVisionFollow() {
|
||||
// Two frames still gate the turn (client commit). Both frames are one clip;
|
||||
// the server packs them as a single <|video_pad|>, same as Native.
|
||||
const frames = visionFollowQueue.slice();
|
||||
visionFollowQueue = [];
|
||||
const silent = new Int16Array(SILENT_PCM_SAMPLES);
|
||||
const event = profile.append(int16ToBase64(silent), frames, { isSpeech: false });
|
||||
socket.send(JSON.stringify(event));
|
||||
for (const message of profile.commitMessages()) socket.send(JSON.stringify(message));
|
||||
}
|
||||
|
||||
function releaseVisionTurn(responseId) {
|
||||
if (!profile.visionFollowWhileSpeaking || !visionTurnLocked) return;
|
||||
if (responseId && currentResponseId && responseId !== currentResponseId) return;
|
||||
visionTurnLocked = false;
|
||||
}
|
||||
|
||||
function suppressLocalPlayback() {
|
||||
// Hold-to-talk cuts the speaker only. The in-flight response stays on the server.
|
||||
if (currentResponseId) suppressedPlaybackId = currentResponseId;
|
||||
if (playbackNode) playbackNode.port.postMessage({ type: 'clear' });
|
||||
playbackComplete = true;
|
||||
responseHasAudio = false;
|
||||
setPlayback('Idle');
|
||||
}
|
||||
|
||||
function playbackSuppressed(responseId) {
|
||||
return Boolean(suppressedPlaybackId) && responseId === suppressedPlaybackId;
|
||||
}
|
||||
|
||||
function flushCapture() {
|
||||
if (!socket || socket.readyState !== WebSocket.OPEN || pendingCapture.length === 0) return;
|
||||
if (!socket || socket.readyState !== WebSocket.OPEN) return;
|
||||
|
||||
// AURA: capture stays 2 fps, but a turn opens only every 2 frames, and
|
||||
// not until the previous response's text is done (or it listened).
|
||||
// Playback still running is not the lock. PTT speech is not batched here.
|
||||
if (profile.pushToTalk && profile.visionFollowWhileSpeaking && !pttHeld) {
|
||||
if (cameraPendingFrame) {
|
||||
queueVisionFrame(cameraPendingFrame);
|
||||
cameraPendingFrame = null;
|
||||
}
|
||||
if (!visionTurnLocked && visionFollowQueue.length >= 2) commitVisionFollow();
|
||||
return;
|
||||
}
|
||||
|
||||
if (profile.pushToTalk && !pttHeld) {
|
||||
pendingCapture = [];
|
||||
return;
|
||||
}
|
||||
|
||||
if (pendingCapture.length === 0) return;
|
||||
if (!microphoneUploadEnabled()) {
|
||||
pendingCapture = [];
|
||||
return;
|
||||
@@ -335,11 +416,44 @@
|
||||
}
|
||||
pendingCapture = [];
|
||||
const pcm = resampleInt16(merged, captureRate, profile.inputSampleRate || INPUT_RATE);
|
||||
const appendEvent = profile.append(int16ToBase64(pcm), cameraPendingFrame);
|
||||
const frame = cameraPendingFrame || (profile.stickyCamera ? cameraLastFrame : null);
|
||||
cameraPendingFrame = null;
|
||||
const appendEvent = profile.pushToTalk
|
||||
? profile.append(int16ToBase64(pcm), frame, { isSpeech: true })
|
||||
: profile.append(int16ToBase64(pcm), frame);
|
||||
socket.send(JSON.stringify(appendEvent));
|
||||
}
|
||||
|
||||
function setPttHeld(held) {
|
||||
if (!profile.pushToTalk || !running || pttHeld === held) return;
|
||||
if (held) {
|
||||
pttHeld = true;
|
||||
suppressLocalPlayback();
|
||||
pttButton.classList.toggle('is-active', true);
|
||||
pttButton.textContent = 'Release to send';
|
||||
setModel('Talking');
|
||||
appendLog('PTT down');
|
||||
return;
|
||||
}
|
||||
// Flush remaining speech while still held, then commit.
|
||||
flushCapture();
|
||||
if (socket && socket.readyState === WebSocket.OPEN) {
|
||||
for (const event of profile.commitMessages()) socket.send(JSON.stringify(event));
|
||||
}
|
||||
// Lock vision before clearing pttHeld. Stage0/1 are max_num_seqs=1: a
|
||||
// vision-follow commit in the gap before response.begin aborts the speech
|
||||
// turn (server sees a new ephemeral and kills the prior ASR request).
|
||||
if (profile.visionFollowWhileSpeaking) {
|
||||
visionTurnLocked = true;
|
||||
visionFollowQueue = [];
|
||||
}
|
||||
pttHeld = false;
|
||||
pttButton.classList.toggle('is-active', false);
|
||||
pttButton.textContent = 'Hold to talk';
|
||||
setModel(profile.waiting);
|
||||
appendLog('PTT up · commit');
|
||||
}
|
||||
|
||||
function beginAssistant(responseId) {
|
||||
currentResponseId = responseId || currentResponseId;
|
||||
responseHasAudio = false;
|
||||
@@ -351,6 +465,7 @@
|
||||
}
|
||||
|
||||
function feedPlayback(decoded, responseId) {
|
||||
if (playbackSuppressed(responseId || currentResponseId)) return;
|
||||
if (!decoded || !decoded.pcm || decoded.pcm.length === 0 || !playbackNode) return;
|
||||
const pcm = resampleInt16(decoded.pcm, decoded.sourceRate, playbackRate);
|
||||
responseHasAudio = true;
|
||||
@@ -392,13 +507,18 @@
|
||||
}
|
||||
|
||||
async function handleAudioEvent(action) {
|
||||
const responseId = action.responseId || currentResponseId || `turn-${turnCounter}`;
|
||||
if (playbackSuppressed(responseId)) return;
|
||||
markBusy();
|
||||
currentResponseId = action.responseId || currentResponseId || `turn-${turnCounter}`;
|
||||
currentResponseId = responseId;
|
||||
setModel('Speaking');
|
||||
const generation = sessionGeneration;
|
||||
const responseId = currentResponseId;
|
||||
const decoded = await decodeAudioDelta(action.event);
|
||||
if (generation === sessionGeneration && !interruptedResponses.has(responseId)) feedPlayback(decoded, responseId);
|
||||
if (
|
||||
generation === sessionGeneration
|
||||
&& !interruptedResponses.has(responseId)
|
||||
&& !playbackSuppressed(responseId)
|
||||
) feedPlayback(decoded, responseId);
|
||||
}
|
||||
|
||||
function handleTranscriptEvent(action) {
|
||||
@@ -408,12 +528,43 @@
|
||||
if (profile.deduplicateTranscript && assistantTextChannel && action.channel !== assistantTextChannel) return;
|
||||
if (action.text) assistantTextChannel = action.channel || assistantTextChannel;
|
||||
}
|
||||
if (action.kind === 'text') addTranscript(action.role, action.text);
|
||||
else if (profile.deduplicateTranscript && action.role === 'assistant') {
|
||||
const responseId = action.responseId || null;
|
||||
const existing = responseId && action.role === 'assistant' ? assistantRowByResponse.get(responseId) : null;
|
||||
if (existing) {
|
||||
if (action.kind === 'text') {
|
||||
if (!action.text) return;
|
||||
existing.value += action.text;
|
||||
} else if (action.text) {
|
||||
existing.value = action.text;
|
||||
}
|
||||
existing.text.textContent = existing.value;
|
||||
liveAssistantTurn = existing;
|
||||
return;
|
||||
}
|
||||
if (
|
||||
action.role === 'assistant'
|
||||
&& !liveAssistantTurn
|
||||
&& action.text
|
||||
&& action.text === lastClosedAssistantText
|
||||
) {
|
||||
// response.done already closed this sentence. A later full transcript,
|
||||
// including one stamped with a newer vision-follow response id, must
|
||||
// not open a second bubble with the same words.
|
||||
return;
|
||||
}
|
||||
if (action.kind === 'text') {
|
||||
addTranscript(action.role, action.text);
|
||||
if (action.role === 'assistant' && responseId && liveAssistantTurn) {
|
||||
assistantRowByResponse.set(responseId, liveAssistantTurn);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (profile.deduplicateTranscript && action.role === 'assistant') {
|
||||
if (action.text) {
|
||||
const turn = ensureTurn('assistant');
|
||||
turn.value = action.text;
|
||||
turn.text.textContent = action.text;
|
||||
if (responseId) assistantRowByResponse.set(responseId, turn);
|
||||
}
|
||||
} else finishTranscript(action.role, action.text);
|
||||
}
|
||||
@@ -459,12 +610,14 @@
|
||||
}
|
||||
case 'listen':
|
||||
assistantActive = false;
|
||||
releaseVisionTurn(responseId);
|
||||
setModel(profile.waiting);
|
||||
break;
|
||||
case 'begin':
|
||||
if (profile.halfDuplex) armTurnTimeout();
|
||||
if (echoTimer !== null) { clearTimeout(echoTimer); echoTimer = null; }
|
||||
beginAssistant(responseId);
|
||||
if (profile.visionFollowWhileSpeaking) visionTurnLocked = true;
|
||||
break;
|
||||
case 'audio':
|
||||
await handleAudioEvent(action);
|
||||
@@ -474,11 +627,13 @@
|
||||
break;
|
||||
case 'text': case 'text-final':
|
||||
handleTranscriptEvent(action);
|
||||
if (action.kind === 'text-final' && action.role === 'assistant') releaseVisionTurn(responseId);
|
||||
break;
|
||||
case 'done':
|
||||
clearTimeout(turnTimeout);
|
||||
responseComplete = true;
|
||||
finishTranscript('assistant');
|
||||
releaseVisionTurn(responseId);
|
||||
requestPlaybackDrain(responseId);
|
||||
finishResponseIfReady();
|
||||
break;
|
||||
@@ -671,7 +826,11 @@
|
||||
await openSocket();
|
||||
running = true;
|
||||
muted = false;
|
||||
pttHeld = false;
|
||||
assistantActive = false;
|
||||
visionFollowQueue = [];
|
||||
visionTurnLocked = false;
|
||||
suppressedPlaybackId = null;
|
||||
sendTimer = window.setInterval(flushCapture, profile.sendIntervalMs || SEND_INTERVAL_MS);
|
||||
startClock();
|
||||
callButton.textContent = 'End session';
|
||||
@@ -679,6 +838,7 @@
|
||||
muteButton.disabled = false;
|
||||
cameraButton.disabled = !profile.camera;
|
||||
sendTurnButton.disabled = !profile.clientCommit;
|
||||
pttButton.disabled = !profile.pushToTalk;
|
||||
setConnection('Connected', 'online');
|
||||
setModel(profile.waiting);
|
||||
appendLog('session started');
|
||||
@@ -698,8 +858,9 @@
|
||||
cameraPreview.srcObject = cameraStream;
|
||||
cameraPreview.style.display = '';
|
||||
await cameraPreview.play().catch(() => {});
|
||||
// Official omni-duplex cadence: one JPEG (quality 0.7) per ~1 s chunk,
|
||||
// no client-side resize (the server normalizes at scale_resolution=448).
|
||||
// JPEG quality 0.7; no client-side resize (server scale_resolution=448).
|
||||
// Interval is per-profile: AURA 2 fps, MiniCPM/Qwen stay at 1 s.
|
||||
const cameraIntervalMs = profile.cameraIntervalMs || 1000;
|
||||
const captureCameraFrame = () => {
|
||||
if (!cameraStream || cameraPreview.videoWidth === 0) return;
|
||||
const scale = profile.cameraMaxDimension
|
||||
@@ -712,14 +873,17 @@
|
||||
if (connectionReady && socket?.readyState === WebSocket.OPEN) {
|
||||
for (const event of profile.imageMessages(frame)) socket.send(JSON.stringify(event));
|
||||
}
|
||||
} else cameraPendingFrame = frame;
|
||||
} else {
|
||||
cameraPendingFrame = frame;
|
||||
if (profile.stickyCamera) cameraLastFrame = frame;
|
||||
}
|
||||
};
|
||||
// Do not make the first spoken turn race a one-second timer.
|
||||
captureCameraFrame();
|
||||
cameraTimer = window.setInterval(captureCameraFrame, 1000);
|
||||
cameraTimer = window.setInterval(captureCameraFrame, cameraIntervalMs);
|
||||
cameraButton.textContent = 'Camera off';
|
||||
cameraButton.classList.add('is-active');
|
||||
appendLog('camera on (1 fps omni frames)');
|
||||
appendLog(`camera on (${(1000 / cameraIntervalMs).toFixed(0)} fps omni frames)`);
|
||||
}
|
||||
|
||||
function stopCamera() {
|
||||
@@ -730,6 +894,7 @@
|
||||
}
|
||||
cameraStream = null;
|
||||
cameraPendingFrame = null;
|
||||
cameraLastFrame = null;
|
||||
cameraPreview.srcObject = null;
|
||||
cameraPreview.style.display = 'none';
|
||||
cameraButton.textContent = 'Camera';
|
||||
@@ -778,9 +943,18 @@
|
||||
playbackComplete = true;
|
||||
turnSubmitted = false;
|
||||
assistantTextChannel = null;
|
||||
assistantRowByResponse.clear();
|
||||
lastClosedAssistantText = '';
|
||||
sendTurnButton.disabled = true;
|
||||
pttHeld = false;
|
||||
pttButton.disabled = true;
|
||||
pttButton.classList.remove('is-active');
|
||||
pttButton.textContent = 'Hold to talk';
|
||||
running = false;
|
||||
assistantActive = false;
|
||||
visionFollowQueue = [];
|
||||
visionTurnLocked = false;
|
||||
suppressedPlaybackId = null;
|
||||
pendingCapture = [];
|
||||
if (sendTimer !== null) clearInterval(sendTimer);
|
||||
if (clockTimer !== null) clearInterval(clockTimer);
|
||||
@@ -854,6 +1028,23 @@
|
||||
setModel('Thinking');
|
||||
appendLog('turn submitted');
|
||||
});
|
||||
const pttDown = (event) => {
|
||||
event.preventDefault();
|
||||
setPttHeld(true);
|
||||
};
|
||||
const pttUp = (event) => {
|
||||
event.preventDefault();
|
||||
setPttHeld(false);
|
||||
};
|
||||
pttButton.addEventListener('pointerdown', pttDown);
|
||||
pttButton.addEventListener('pointerup', pttUp);
|
||||
pttButton.addEventListener('pointercancel', pttUp);
|
||||
pttButton.addEventListener('pointerleave', () => {
|
||||
if (pttHeld) setPttHeld(false);
|
||||
});
|
||||
window.addEventListener('pointerup', () => {
|
||||
if (pttHeld) setPttHeld(false);
|
||||
});
|
||||
muteButton.addEventListener('click', toggleMute);
|
||||
clearLogButton.addEventListener('click', () => {
|
||||
eventLog.textContent = '';
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
(function (root) {
|
||||
'use strict';
|
||||
const profiles = root.OmniRealtimeProfiles;
|
||||
profiles['aura-ptt'] = () => ({
|
||||
title: 'AURA Realtime',
|
||||
eyebrow: 'Push-to-talk duplex',
|
||||
policy: 'Hold to talk • release to commit',
|
||||
description:
|
||||
'Hold to talk, release to send. Camera stays on whether you speak or not. '
|
||||
+ 'Holding the button stops local playback.',
|
||||
waiting: 'Ready',
|
||||
camera: true,
|
||||
// Display only. Shared CSS puts .camera-preview-large on its own row.
|
||||
// Other profiles keep the 96×72 preview in index.html.
|
||||
cameraPreviewLarge: true,
|
||||
playbackAck: true,
|
||||
clientCommit: false,
|
||||
pushToTalk: true,
|
||||
stickyCamera: true,
|
||||
// OmniInteract / Native AURA clock: 2 fps. Other profiles omit this and stay at 1 s.
|
||||
cameraIntervalMs: 500,
|
||||
visionFollowWhileSpeaking: true,
|
||||
deduplicateTranscript: true,
|
||||
halfDuplex: false,
|
||||
closeSession: true,
|
||||
reconnectEachTurn: false,
|
||||
readyEvent: 'session.updated',
|
||||
instructions: true,
|
||||
sendIntervalMs: 200,
|
||||
presets: {
|
||||
omni: 'You are receiving a live video stream where the final frame is the present moment. Respond only when a response is needed based on the user\'s message or the visual context. Otherwise, output `<|silent|>` to signify silence.',
|
||||
},
|
||||
url(config, location) {
|
||||
const url = profiles.url(config, location);
|
||||
url.searchParams.set('duplex', '1');
|
||||
url.searchParams.set('model', config.model || 'aurateam/AURA');
|
||||
return url.toString();
|
||||
},
|
||||
initialMessages(config, instructions) {
|
||||
const session = {
|
||||
modalities: ['audio', 'text'],
|
||||
extra_body: { auto_response: true },
|
||||
};
|
||||
if (instructions) session.instructions = instructions;
|
||||
return [{ type: 'session.update', session }];
|
||||
},
|
||||
append(audio, frame, opts) {
|
||||
const isSpeech = !opts || opts.isSpeech !== false;
|
||||
const event = {
|
||||
type: 'input_audio_buffer.append',
|
||||
audio,
|
||||
format: 'pcm16',
|
||||
sample_rate_hz: 16000,
|
||||
is_speech: isSpeech,
|
||||
};
|
||||
const frames = Array.isArray(frame) ? frame.filter(Boolean) : (frame ? [frame] : []);
|
||||
if (frames.length) event.video_frames = frames;
|
||||
return event;
|
||||
},
|
||||
commitMessages: () => [{ type: 'input_audio_buffer.commit', create_response: true }],
|
||||
ack(responseId, playedMs) {
|
||||
return {
|
||||
type: 'playback.ack',
|
||||
response_id: responseId,
|
||||
item_id: `item_${responseId}`,
|
||||
played_ms: playedMs,
|
||||
committed_ms: playedMs,
|
||||
};
|
||||
},
|
||||
mapEvent(event) {
|
||||
if (event.type === 'response.listen') return { kind: 'listen' };
|
||||
if (event.type === 'playback.acknowledged') {
|
||||
return { kind: 'ack', committedMs: (event.event || event).committed_ms || 0 };
|
||||
}
|
||||
return profiles.event(event);
|
||||
},
|
||||
connectionHint: 'Check the AURA duplex serve (run_duplex_smoke_serve.sh) and --ws-backend port.',
|
||||
});
|
||||
})(globalThis);
|
||||
@@ -71,6 +71,18 @@ main { width: min(1040px, calc(100% - 40px)); margin: 28px auto 48px; }
|
||||
}
|
||||
|
||||
.call-actions { display: flex; gap: 8px; }
|
||||
/* AURA only: class is added solely by the aura-ptt profile. */
|
||||
.call-bar:has(.camera-preview-large) .call-actions { grid-column: 1 / -1; }
|
||||
.call-actions:has(.camera-preview-large) { flex-wrap: wrap; align-items: center; }
|
||||
.call-actions:has(.camera-preview-large) .camera-preview-large {
|
||||
order: -1;
|
||||
flex: 0 0 100%;
|
||||
width: 100% !important;
|
||||
height: auto !important;
|
||||
max-height: 480px;
|
||||
aspect-ratio: 4 / 3;
|
||||
}
|
||||
.call-actions:has(.camera-preview-large) button { flex: 0 0 auto; }
|
||||
button { border-radius: 5px; border: 1px solid transparent; cursor: pointer; }
|
||||
button:disabled { opacity: .46; cursor: default; }
|
||||
.primary { padding: 10px 15px; color: #ffffff; background: #16834b; font-weight: 700; }
|
||||
|
||||
@@ -76,15 +76,20 @@ def build_app(
|
||||
profile: str = "minicpm-native",
|
||||
adapter: str = "stt",
|
||||
) -> FastAPI:
|
||||
if profile not in {"minicpm-native", "qwen3-turn"}:
|
||||
if profile not in {"minicpm-native", "qwen3-turn", "aura-ptt"}:
|
||||
raise ValueError(f"Unknown profile: {profile}")
|
||||
if adapter not in {"stt", "vad"}:
|
||||
raise ValueError(f"Unknown adapter: {adapter}")
|
||||
if profile == "qwen3-turn" and ref_audio:
|
||||
raise ValueError("Qwen3 profile does not accept --ref-audio")
|
||||
if profile == "aura-ptt" and ref_audio:
|
||||
raise ValueError("AURA profile does not accept --ref-audio")
|
||||
native = profile == "minicpm-native"
|
||||
ws_backend = ws_backend or ("ws://127.0.0.1:8099" if native else "ws://127.0.0.1:8091")
|
||||
model = model or ("openbmb/MiniCPM-o-4_5" if native else "Qwen/Qwen3-Omni-30B-A3B-Instruct")
|
||||
aura = profile == "aura-ptt"
|
||||
ws_backend = ws_backend or ("ws://127.0.0.1:8099" if native or aura else "ws://127.0.0.1:8091")
|
||||
model = model or (
|
||||
"openbmb/MiniCPM-o-4_5" if native else "aurateam/AURA" if aura else "Qwen/Qwen3-Omni-30B-A3B-Instruct"
|
||||
)
|
||||
app = FastAPI(title="Omni Realtime Web UI")
|
||||
index_path = APP_DIR / "index.html"
|
||||
app_version_hash = hashlib.sha256()
|
||||
@@ -182,7 +187,7 @@ def main(default_profile: str = "minicpm-native") -> None:
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument("--host", default="0.0.0.0")
|
||||
parser.add_argument("--port", type=int, default=7862)
|
||||
parser.add_argument("--profile", choices=("minicpm-native", "qwen3-turn"), default=default_profile)
|
||||
parser.add_argument("--profile", choices=("minicpm-native", "qwen3-turn", "aura-ptt"), default=default_profile)
|
||||
parser.add_argument("--ws-backend", "--backend", dest="ws_backend")
|
||||
mode = parser.add_mutually_exclusive_group()
|
||||
mode.add_argument("--stt", dest="adapter", action="store_const", const="stt")
|
||||
@@ -202,12 +207,15 @@ def main(default_profile: str = "minicpm-native") -> None:
|
||||
)
|
||||
args = parser.parse_args()
|
||||
native = args.profile == "minicpm-native"
|
||||
aura = args.profile == "aura-ptt"
|
||||
if native and not args.ref_audio:
|
||||
parser.error("--ref-audio is required for the minicpm-native profile")
|
||||
if not native and args.ref_audio:
|
||||
parser.error("--ref-audio is only supported by minicpm-native")
|
||||
args.model = args.model or ("openbmb/MiniCPM-o-4_5" if native else "Qwen/Qwen3-Omni-30B-A3B-Instruct")
|
||||
args.ws_backend = args.ws_backend or ("ws://127.0.0.1:8099" if native else "ws://127.0.0.1:8091")
|
||||
args.model = args.model or (
|
||||
"openbmb/MiniCPM-o-4_5" if native else "aurateam/AURA" if aura else "Qwen/Qwen3-Omni-30B-A3B-Instruct"
|
||||
)
|
||||
args.ws_backend = args.ws_backend or ("ws://127.0.0.1:8099" if native or aura else "ws://127.0.0.1:8091")
|
||||
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
uvicorn.run(
|
||||
|
||||
Reference in new issue
Block a user