import { Mic, MicOff, Phone, PhoneOff, Loader2, MessageSquare } from 'lucide-react'; import { useVoiceChat } from '../hooks/useVoiceChat'; import SubtitleDisplay from './SubtitleDisplay'; export default function VoicePanel({ settings, onVoiceEnd, chatHistory = [], sessionId: parentSessionId }) { const { isActive, isMuted, isConnecting, subtitles, connectionState, error, duration, start, stop, toggleMute, clearError, } = useVoiceChat(); const formatTime = (s) => { const m = Math.floor(s / 60); const sec = s % 60; return `${m.toString().padStart(2, '0')}:${sec.toString().padStart(2, '0')}`; }; const handleStart = () => { start({ botName: settings.botName, systemRole: settings.systemRole, speakingStyle: settings.speakingStyle, modelVersion: settings.modelVersion, speaker: settings.speaker, enableWebSearch: settings.enableWebSearch, chatHistory: chatHistory.length > 0 ? chatHistory.slice(-10) : undefined, parentSessionId, }); }; return (
{isActive ? isMuted ? '麦克风已静音' : '正在聆听...' : '点击下方按钮开始语音通话'}