React hook that generates TTS fallback text and manages voice playback logic.
// Source: https://github.com/daggerhashimoto/openclaw-nerve | License: MIT | Copyright 2025-2026 Nerve contributors
// Provided via justclaw.it.com; keep this notice with the code.
/**
* useChatTTS — TTS playback logic extracted from ChatContext
*
* Manages voice fallback text generation, TTS marker extraction,
* auto-speak logic, and played-sound deduplication.
*/
import { useRef, useCallback, useMemo } from 'react';
import { playPing } from '@/features/voice/audio-feedback';
import type { FinalMessageData } from '@/features/chat/operations';
// ─── Constants ──────────────────────────────────────────────────────────────────
export const FALLBACK_MAX_CHARS = 300;
// ─── Pure helpers ───────────────────────────────────────────────────────────────
/** Strip code blocks, markdown n
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key