/* TIO proactive unread v1 */ #sessionBtn{position:relative} #sessionUnreadDot{ position:absolute; top:3px; right:3px; } .proactive-unread-dot{ display:inline-block; width:8px; height:8px; min-width:8px; border-radius:999px; background:#ef4444; box-shadow:0 0 0 2px var(--panel,#fff); } .session-unread-dot{ margin-left:auto; margin-right:8px; }

Claude

输入连接密钥,进入你和Claude的频道。

苏ICP备2026046914号-1
⚡ 加载中 ▼

画图模型设置

画一张图

添加新模型

新日记设置

尚未读取
(function (global) { "use strict"; const EVENT_TYPE = "call_tts_audio"; const AUDIO_FORMAT = "pcm_s16le"; const SAMPLE_RATE = 32000; const CHANNELS = 1; function decodeBase64ToBytes(value) { if (typeof value !== "string" || !value) { throw new Error("audio_b64_missing"); } const binary = global.atob(value); const bytes = new Uint8Array(binary.length); for (let i = 0; i < binary.length; i += 1) { bytes[i] = binary.charCodeAt(i); } return bytes; } function pcm16ToFloat32(bytes) { if (bytes.byteLength % 2 !== 0) { throw new Error("pcm_s16le_requires_even_bytes"); } const view = new DataView( bytes.buffer, bytes.byteOffset, bytes.byteLength ); const samples = new Float32Array(bytes.byteLength / 2); for (let i = 0; i < samples.length; i += 1) { samples[i] = view.getInt16(i * 2, true) / 32768; } return samples; } class CallTtsPcmPlayer { constructor(audioContextFactory) { if (typeof audioContextFactory !== "function") { throw new Error("audio_context_factory_required"); } this.audioContextFactory = audioContextFactory; this.ctx = null; this.destination = null; this.callId = ""; this.streamId = ""; this.nextStart = 0; this.sources = []; this.closed = false; } ensureContext() { if (this.closed) { throw new Error("player_closed"); } if (!this.ctx) { this.ctx = this.audioContextFactory(); if (!this.ctx || typeof this.ctx.createBuffer !== "function") { throw new Error("invalid_audio_context"); } this.destination = this.ctx.destination; } if ( this.ctx.state === "suspended" && typeof this.ctx.resume === "function" ) { this.ctx.resume().catch(function () {}); } return this.ctx; } reset(callId, streamId) { if ( this.callId === String(callId || "") && this.streamId === String(streamId || "") ) { return; } this.stop(); this.callId = String(callId || ""); this.streamId = String(streamId || ""); } stop() { for (const source of this.sources) { try { source.stop(); } catch (_) {} } this.sources = []; this.nextStart = 0; } push(event) { if (!event || event.type !== EVENT_TYPE) { throw new Error("unexpected_event_type"); } if (!event.call_id || !event.stream_id) { throw new Error("call_or_stream_id_missing"); } if (event.audio_format !== AUDIO_FORMAT) { throw new Error("unexpected_audio_format"); } if (Number(event.sample_rate) !== SAMPLE_RATE) { throw new Error("unexpected_sample_rate"); } if (Number(event.channels) !== CHANNELS) { throw new Error("unexpected_channels"); } this.reset(event.call_id, event.stream_id); const ctx = this.ensureContext(); const bytes = decodeBase64ToBytes(event.audio_b64); const samples = pcm16ToFloat32(bytes); const buffer = ctx.createBuffer( CHANNELS, samples.length, SAMPLE_RATE ); buffer.copyToChannel(samples, 0); const source = ctx.createBufferSource(); source.buffer = buffer; source.connect(this.destination); const now = Number(ctx.currentTime || 0); if (this.nextStart < now + 0.02) { this.nextStart = now + 0.02; } const startAt = this.nextStart; source.start(startAt); this.nextStart = startAt + buffer.duration; this.sources.push(source); source.onended = () => { const index = this.sources.indexOf(source); if (index >= 0) { this.sources.splice(index, 1); } }; return { callId: this.callId, streamId: this.streamId, samples: samples.length, startAt: startAt, duration: buffer.duration, final: Boolean(event.final), }; } close() { this.stop(); if ( this.ctx && typeof this.ctx.close === "function" ) { this.ctx.close().catch(function () {}); } this.closed = true; this.ctx = null; this.destination = null; } } global.TIOCallTtsPcmPlayer = CallTtsPcmPlayer; })(typeof globalThis !== "undefined" ? globalThis : window); /* ===== TIO BIDI FRONTEND WIRING V3 FIXED BEGIN ===== */ (function installTioBidiFrontend(){ if (window.__tioBidiFrontendV3) return; window.__tioBidiFrontendV3 = true; let pcmPlayer = null; function ensurePcmPlayer(){ if (!pcmPlayer){ pcmPlayer = new CallTtsPcmPlayer(); } return pcmPlayer; } window.TioCallTtsPcmPlayer = { push: function(payload){ const player = ensurePcmPlayer(); if (player && typeof player.push === "function"){ player.push(payload); } }, stop: function(){ if (pcmPlayer && typeof pcmPlayer.stop === "function"){ pcmPlayer.stop(); } pcmPlayer = null; } }; window.__tioBidiPcmPush = function(payload){ if (!payload || payload.type !== "call_tts_audio"){ return; } window.TioCallTtsPcmPlayer.push(payload); }; window.__tioBidiPcmStop = function(){ window.TioCallTtsPcmPlayer.stop(); }; })(); /* ===== TIO BIDI FRONTEND WIRING V3 FIXED END ===== */