/** * 音色克隆工具函数 */ import type { VoiceCloneProfile, VoiceClone } from "./types" /** * 将后端 VoiceCloneProfile 转换为前端 VoiceClone * 后端 status "pending" 映射为前端 "processing" */ export const toVoiceClone = (profile: VoiceCloneProfile): VoiceClone => ({ id: profile.id, name: profile.name, description: profile.description || "", duration_seconds: 0, status: profile.status === "pending" ? "processing" : profile.status, progress: 0, sample_url: profile.source_audio_url || undefined, language: profile.language || "", gender: profile.gender || "", error_message: profile.error_message || null, created_at: profile.created_at, updated_at: profile.updated_at, }) /** 格式化时长 */ export const formatDuration = (seconds: number): string => { const m = Math.floor(seconds / 60) const s = seconds % 60 return `${m}:${String(s).padStart(2, "0")}` }