import React, { useRef } from "react"; import { Play, Pause, Download } from "lucide-react"; interface AudioResultProps { stats: { firstLatency: number | null; processingTime: number; charsPerSec: number; rtf: number; totalDuration: number; currentDuration: number; }; progressPercentage: number; isGenerating: boolean; isPlaying: boolean; onTogglePlay: () => void; onDownload: () => void; onSeek: (percentage: number) => void; } export const AudioResult = ({ stats, progressPercentage, isGenerating, isPlaying, onTogglePlay, onDownload, onSeek, }: AudioResultProps) => { const progressBarRef = useRef(null); const formatTime = (secs: number) => { const minutes = Math.floor(secs / 60); const seconds = (secs % 60).toFixed(2); return `${minutes}:${seconds.padStart(5, "0")}`; }; const playbackProgress = stats.totalDuration > 0 ? Math.min(100, (stats.currentDuration / stats.totalDuration) * 100) : 0; const handleSeekClick = (e: React.MouseEvent) => { if (progressBarRef.current) { const rect = progressBarRef.current.getBoundingClientRect(); const x = e.clientX - rect.left; const percentage = Math.max(0, Math.min(1, x / rect.width)); onSeek(percentage); } }; return (
Supertonic On-Device
{stats.firstLatency !== null ? ( <> First {stats.firstLatency.toFixed(2)} s / ) : null} {stats.processingTime.toFixed(2)} s
Processing Time ↓
{stats.charsPerSec > 0 ? stats.charsPerSec.toFixed(1) : "-"}
Chars/sec ↑
{stats.rtf > 0 ? stats.rtf.toFixed(3) : "-"} x
RTF ↓
{formatTime(stats.currentDuration)}
{formatTime(stats.totalDuration)}
); };