import { BifrostSpeech, SpeechInput } from "@/lib/types/logs"; import { AlertCircle, Play, Volume2 } from "lucide-react"; import React, { Component } from "react"; import AudioPlayer from "./audioPlayer"; interface SpeechViewProps { speechInput?: SpeechInput; speechOutput?: BifrostSpeech; isStreaming?: boolean; } // Error boundary specifically for audio player errors class AudioErrorBoundary extends Component<{ children: React.ReactNode }, { hasError: boolean; error: Error | null }> { constructor(props: { children: React.ReactNode }) { super(props); this.state = { hasError: false, error: null }; } static getDerivedStateFromError(error: Error) { return { hasError: true, error }; } componentDidCatch(error: Error, errorInfo: React.ErrorInfo) { console.error("Audio player error:", error, errorInfo); } render() { if (this.state.hasError) { return (
Failed to load audio player: {this.state.error?.message || "Unknown error"}
); } return this.props.children; } } export default function SpeechView({ speechInput, speechOutput, isStreaming }: SpeechViewProps) { return (
{/* Speech Input */} {speechInput && (
Speech Input
{speechInput.input}
)} {/* Speech Output */} {(speechOutput || isStreaming) && (
Speech Output
)}
); }