克隆完成版

main
guofei 2024-12-03 17:01:00 +08:00
parent 1376f9375e
commit ee7a83547e
4 changed files with 37 additions and 13 deletions

View File

@ -1,5 +1,6 @@
generator client {
provider = "prisma-client-js"
provider = "prisma-client-js"
// previewFeatures = ["strictUndefinedChecks"]
}
datasource db {
@ -33,7 +34,7 @@ model SystemCharter {
voiceName String?
// 剩余可克隆次数
remainingCloneCount Int @default(10)
remainingCloneCount Int? @default(10)
// 原始音频
originAudioUrl String?

View File

@ -26,10 +26,7 @@ export class RedisTaskProcessor {
const volcenAudioSpeakService = new VolcenAudioSpeakService();
// voiceId = await volcenAudioSpeakService.getVoiceId();
// const voiceId = 'S_FC60x0Gb1';
// 剩余1次
// const voiceId = 'S_VK2Yw0Gb1';
voiceId = 'S_5QKWw0Gb1';
// voiceId = 'S_VK2Yw0Gb1';
// 请求ossurl获取base64
const base64 = await volcenAudioSpeakService.getAudioBase64(ossUrl);
// 克隆音频

View File

@ -7,6 +7,8 @@ import { RedisTaskService } from 'src/common/RedisTask/RedisTask.service';
import { VolcenAudioSpeakService } from 'src/services/VolcenAudioSpeakService';
import axios from 'axios';
import { CloneSpeakDto } from './dto/CloneSpeakDto.dto';
import { isNotEmpty } from 'class-validator';
import { Prisma } from '@prisma/client';
// 添加任务查询DTO
export class TaskQueryDto {
@ -26,12 +28,30 @@ export class SystemCharterController {
) {}
@Get('/getList')
async getList(@Query() query: SystemCharterlDto) {
async getList(@Query() query: SystemCharterlDto & { originAudioUrl?: string }) {
const { current, pageSize, ...other } = query;
const where = {};
if (query.roleName) {
where['roleName'] = other.roleName;
if (other.roleName) {
where['roleName'] = {
contains: other.roleName,
mode: 'insensitive',
};
}
if (query.originAudioUrl) {
// 根据原始音频状态筛选
if (query.originAudioUrl == 'true') {
// 已克隆的
where['originAudioUrl'] = {
not: null,
};
} else {
// 为空的数据
// where['OR'] = [{ originAudioUrl: null }, { originAudioUrl: '' }, { originAudioUrl: undefined }];
where['originAudioUrl'] = undefined;
}
}
console.log(where, query.originAudioUrl, typeof query.originAudioUrl);
const [record, total] = await this.dbService.systemCharter.findManyAndCount({
where,
@ -152,9 +172,12 @@ export class SystemCharterController {
}
const volcenAudioSpeakService = new VolcenAudioSpeakService();
const result = await volcenAudioSpeakService.speakActivate(speakerId);
return ApiResponse.successToMessage('音频激活成功', result);
const isActivate = await volcenAudioSpeakService.speakActivate(speakerId);
if (isActivate) {
return ApiResponse.success('音频激活成功');
} else {
return ApiResponse.failToMessage('音频激活失败');
}
} catch (error) {
console.error('激活音频失败:', error);
return ApiResponse.failToMessage('激活音频失败:' + error.message);
@ -300,6 +323,9 @@ export class SystemCharterController {
where: { id: roleId },
});
// 判断是否有克隆次数
if (!charter) {
throw new HttpException('角色不存在', HttpStatus.BAD_REQUEST);
}

View File

@ -1,4 +1,4 @@
import { IsOptional, IsString } from 'class-validator';
import { IsBoolean, IsOptional, IsString } from 'class-validator';
import { PaginationDto } from 'src/common/pagination/PaginationDto.dto';
export class SystemCharterlDto extends PaginationDto {