Files
sionrui/frontend/app/web-gold/src/api/voice.js
2026-02-02 02:39:40 +08:00

114 lines
2.9 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* 配音 API 服务
* 对应后端 tik 模块的配音管理接口
*/
import http from './http'
import { API_BASE } from '@gold/config/api'
// 统一使用 /api/tik 前缀
const BASE_URL = `${API_BASE.APP}/api/tik/voice`
/**
* 配音 API 服务
*/
export const VoiceService = {
/**
* 创建配音
* @param {Object} data - 请求数据
* @param {string} data.name - 配音名称(必填)
* @param {number} data.fileId - 音频文件编号(必填)
* @param {boolean} data.autoTranscribe - 是否自动识别(可选)
* @param {string} data.language - 语言(可选)
* @param {string} data.gender - 音色类型(可选)
* @param {string} data.note - 备注(可选)
* @param {string} data.text - 音频文本(用于语音复刻,前端通过音频识别获取)
* @param {string} data.providerType - 供应商类型可选cosyvoice-阿里云siliconflow-硅基流动
* @returns {Promise}
*/
create(data) {
return http.post(`${BASE_URL}/create`, data)
},
/**
* 更新配音
* @param {Object} data - 请求数据
* @param {number} data.id - 配音编号(必填)
* @param {string} data.name - 配音名称(可选)
* @param {string} data.language - 语言(可选)
* @param {string} data.gender - 音色类型(可选)
* @param {string} data.note - 备注(可选)
* @returns {Promise}
*/
update(data) {
return http.put(`${BASE_URL}/update`, data)
},
/**
* 删除配音
* @param {number} id - 配音编号
* @returns {Promise}
*/
delete(id) {
return http.delete(`${BASE_URL}/delete`, {
params: { id }
})
},
/**
* 分页查询配音列表
* @param {Object} params - 查询参数
* @param {number} params.pageNo - 页码
* @param {number} params.pageSize - 每页数量
* @param {string} params.name - 配音名称(模糊查询)
* @returns {Promise}
*/
getPage(params) {
return http.get(`${BASE_URL}/page`, { params })
},
/**
* 获取单个配音
* @param {number} id - 配音编号
* @returns {Promise}
*/
get(id) {
return http.get(`${BASE_URL}/get`, {
params: { id }
})
},
/**
* 手动触发语音识别
* @param {number} id - 配音编号
* @returns {Promise}
*/
transcribe(id) {
return http.post(`${BASE_URL}/transcribe`, null, {
params: { id }
})
},
/**
* 文本转语音
* @param {Object} data
* @param {string} data.providerType - 供应商类型可选cosyvoice-阿里云siliconflow-硅基流动
* @returns {Promise}
*/
synthesize(data) {
return http.post(`${BASE_URL}/tts`, data)
},
/**
* 我的音色试听
* @param {Object} data
* @param {string} data.providerType - 供应商类型可选cosyvoice-阿里云siliconflow-硅基流动
* @returns {Promise}
*/
preview(data) {
return http.post(`${BASE_URL}/preview`, data)
}
}
export default VoiceService