a59e3cc155
CI/CD Pipeline / Check if frontend-only change (push) Has been cancelled
CI/CD Pipeline / Validate - Code Quality (push) Has been cancelled
CI/CD Pipeline / Validate - Type Check (mypy) (push) Has been cancelled
CI/CD Pipeline / Validate - Migration (alembic) (push) Has been cancelled
CI/CD Pipeline / Unit Tests (push) Has been cancelled
CI/CD Pipeline / Integration Tests (push) Has been cancelled
CI/CD Pipeline / Frontend Lint (push) Has been cancelled
CI/CD Pipeline / Frontend Unit Tests (push) Has been cancelled
CI/CD Pipeline / PR Build API Image (push) Has been cancelled
CI/CD Pipeline / PR Build Web Image (push) Has been cancelled
CI/CD Pipeline / PR Build Worker Image (push) Has been cancelled
CI/CD Pipeline / Build Staging API Image (push) Has been cancelled
CI/CD Pipeline / Build Staging Web Image (push) Has been cancelled
CI/CD Pipeline / Build Staging Worker Image (push) Has been cancelled
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (push) Has been cancelled
CI/CD Pipeline / Staging E2E Tests (push) Has been cancelled
CI/CD Pipeline / Staging API Integration Tests (push) Has been cancelled
CI/CD Pipeline / Build Production API Image (push) Has been cancelled
CI/CD Pipeline / Build Production Web Image (push) Has been cancelled
CI/CD Pipeline / Build Production Worker Image (push) Has been cancelled
CI/CD Pipeline / Deploy Production (push) Has been cancelled
CI/CD Pipeline / Production Browser E2E (push) Has been cancelled
CI/CD Pipeline / ACR Image Cleanup (push) Has been cancelled
CI/CD Pipeline / Canary Release to Production (push) Has been cancelled
CI/CD Pipeline / CI Gate (push) Has been cancelled
88 lines
3.1 KiB
TypeScript
88 lines
3.1 KiB
TypeScript
/**
|
|
* 音色克隆 API 函数
|
|
*/
|
|
import apiClient from "../client"
|
|
import { toVoiceClone } from "./utils"
|
|
import type {
|
|
VoiceClone,
|
|
VoiceCloneProfile,
|
|
CreateVoiceCloneRequest,
|
|
CreateVoiceCloneRequestFull,
|
|
VoiceCloneListParams,
|
|
ListVoiceCloneResponse,
|
|
VoiceCloneStatusResponse,
|
|
} from "./types"
|
|
|
|
/** 获取克隆音色列表(返回前端兼容数组) */
|
|
export const getVoiceClones = async (params?: VoiceCloneListParams): Promise<VoiceClone[]> => {
|
|
const searchParams = new URLSearchParams()
|
|
if (params?.status) searchParams.set("status", params.status)
|
|
if (params?.skip !== undefined) searchParams.set("skip", String(params.skip))
|
|
if (params?.limit !== undefined) searchParams.set("limit", String(params.limit))
|
|
const qs = searchParams.toString()
|
|
const response = await apiClient.get<ListVoiceCloneResponse>(`/voice-clones${qs ? `?${qs}` : ""}`)
|
|
return response.data.items.map(toVoiceClone)
|
|
}
|
|
|
|
/** 获取克隆音色列表(返回完整响应含 total) */
|
|
export const getVoiceClonesWithTotal = async (
|
|
params?: VoiceCloneListParams,
|
|
): Promise<ListVoiceCloneResponse> => {
|
|
const searchParams = new URLSearchParams()
|
|
if (params?.status) searchParams.set("status", params.status)
|
|
if (params?.skip !== undefined) searchParams.set("skip", String(params.skip))
|
|
if (params?.limit !== undefined) searchParams.set("limit", String(params.limit))
|
|
const qs = searchParams.toString()
|
|
const response = await apiClient.get<ListVoiceCloneResponse>(`/voice-clones${qs ? `?${qs}` : ""}`)
|
|
return response.data
|
|
}
|
|
|
|
/** 获取单个克隆音色详情 */
|
|
export const getVoiceCloneDetail = async (id: string): Promise<VoiceCloneProfile> => {
|
|
const response = await apiClient.get<VoiceCloneProfile>(`/voice-clones/${id}`)
|
|
return response.data
|
|
}
|
|
|
|
/** 创建克隆音色 */
|
|
export const createVoiceClone = async (
|
|
data: CreateVoiceCloneRequest,
|
|
): Promise<VoiceCloneProfile> => {
|
|
const payload: CreateVoiceCloneRequestFull = {
|
|
name: data.name,
|
|
description: data.description,
|
|
source_audio_url: data.audio_url,
|
|
}
|
|
const response = await apiClient.post<VoiceCloneProfile>("/voice-clones", payload)
|
|
return response.data
|
|
}
|
|
|
|
/** 删除克隆音色 */
|
|
export const deleteVoiceClone = async (id: string): Promise<void> => {
|
|
await apiClient.delete(`/voice-clones/${id}`)
|
|
}
|
|
|
|
/** 更新克隆音色名称(stub — 后端暂无 PATCH 端点) */
|
|
export const updateVoiceClone = async (
|
|
id: string,
|
|
data: Partial<Pick<VoiceClone, "name">>,
|
|
): Promise<VoiceClone> => {
|
|
const response = await apiClient.get<VoiceCloneProfile>(`/voice-clones/${id}`)
|
|
return toVoiceClone({
|
|
...response.data,
|
|
...data,
|
|
updated_at: new Date().toISOString(),
|
|
})
|
|
}
|
|
|
|
/** 获取克隆状态 */
|
|
export const getVoiceCloneStatus = async (id: string): Promise<VoiceCloneStatusResponse> => {
|
|
const response = await apiClient.get<VoiceCloneStatusResponse>(`/voice-clones/${id}/status`)
|
|
return response.data
|
|
}
|
|
|
|
/** 重试克隆 */
|
|
export const retryVoiceClone = async (id: string): Promise<VoiceCloneProfile> => {
|
|
const response = await apiClient.post<VoiceCloneProfile>(`/voice-clones/${id}/retry`)
|
|
return response.data
|
|
}
|