import { Volume2, Loader2, Square } from 'lucide-react'; import { useTranslation } from 'react-i18next'; import { useTts } from '../../hooks/useTts'; import { useVoiceAvailable } from '../../hooks/useVoiceAvailable'; // Tap-to-speak button beside the copy control on assistant messages. // Renders nothing unless the optional voice feature is enabled. const MessageSpeakControl = ({ content }: { content: string }) => { const { t } = useTranslation('chat'); const available = useVoiceAvailable(); const { state, toggle, error } = useTts(() => content); if (!available) return null; const title = state === 'playing' ? t('voice.stopSpeaking') : state === 'loading' ? t('voice.loading') : t('voice.speak'); return ( {error && ( {error} )} ); }; export default MessageSpeakControl;