激活克隆声音
parent
ee7a83547e
commit
e4dc47a83f
|
@ -164,16 +164,28 @@ export class SystemCharterController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get('activateVoice')
|
@Post('activateVoice/:roleId')
|
||||||
async activateVoice(@Query('speakerId') speakerId: string) {
|
async activateVoice(@Param('roleId') roleId: string) {
|
||||||
try {
|
try {
|
||||||
if (!speakerId) {
|
if (!roleId) {
|
||||||
return ApiResponse.failToMessage('参数错误:缺少speakerId');
|
return ApiResponse.failToMessage('参数错误:缺少roleId');
|
||||||
|
}
|
||||||
|
const charter = await this.dbService.systemCharter.findUnique({
|
||||||
|
where: { id: roleId },
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!charter) {
|
||||||
|
throw new HttpException('角色不存在', HttpStatus.BAD_REQUEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
const volcenAudioSpeakService = new VolcenAudioSpeakService();
|
const volcenAudioSpeakService = new VolcenAudioSpeakService();
|
||||||
const isActivate = await volcenAudioSpeakService.speakActivate(speakerId);
|
const isActivate = await volcenAudioSpeakService.speakActivate(charter.voiceId);
|
||||||
if (isActivate) {
|
if (isActivate) {
|
||||||
|
// 修改当前用户的激活状态
|
||||||
|
await this.dbService.systemCharter.update({
|
||||||
|
where: { id: roleId },
|
||||||
|
data: { activate: true },
|
||||||
|
});
|
||||||
return ApiResponse.success('音频激活成功');
|
return ApiResponse.success('音频激活成功');
|
||||||
} else {
|
} else {
|
||||||
return ApiResponse.failToMessage('音频激活失败');
|
return ApiResponse.failToMessage('音频激活失败');
|
||||||
|
@ -323,13 +335,14 @@ export class SystemCharterController {
|
||||||
where: { id: roleId },
|
where: { id: roleId },
|
||||||
});
|
});
|
||||||
|
|
||||||
// 判断是否有克隆次数
|
|
||||||
|
|
||||||
|
|
||||||
if (!charter) {
|
if (!charter) {
|
||||||
throw new HttpException('角色不存在', HttpStatus.BAD_REQUEST);
|
throw new HttpException('角色不存在', HttpStatus.BAD_REQUEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!charter.remainingCloneCount || charter.remainingCloneCount <= 0) {
|
||||||
|
throw new HttpException('剩余克隆次数不足', HttpStatus.BAD_REQUEST);
|
||||||
|
}
|
||||||
|
|
||||||
// 检查是否存在未完成的相同角色任务
|
// 检查是否存在未完成的相同角色任务
|
||||||
const existingTask = await this.dbService.taskQueue.findFirst({
|
const existingTask = await this.dbService.taskQueue.findFirst({
|
||||||
where: {
|
where: {
|
||||||
|
|
|
@ -161,6 +161,7 @@ export class VolcenAudioSpeakService {
|
||||||
secretKey: VolcenAudioSpeakService.TiktokSecretKeyId,
|
secretKey: VolcenAudioSpeakService.TiktokSecretKeyId,
|
||||||
});
|
});
|
||||||
// 激活
|
// 激活
|
||||||
|
try {
|
||||||
const activateVoiceResult = await axios.post(
|
const activateVoiceResult = await axios.post(
|
||||||
VolcenAudioSpeakService.ENGIN_BASE_URL_API + '?Action=ActivateMegaTTSTrainStatus&Version=2023-11-07',
|
VolcenAudioSpeakService.ENGIN_BASE_URL_API + '?Action=ActivateMegaTTSTrainStatus&Version=2023-11-07',
|
||||||
activatePost.body,
|
activatePost.body,
|
||||||
|
@ -168,10 +169,18 @@ export class VolcenAudioSpeakService {
|
||||||
headers: activatePost.headers,
|
headers: activatePost.headers,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
const result = activateVoiceResult.data;
|
||||||
const hasCurrentSpeakId = activateVoiceResult.data?.Result.Statuses.find((item: any) => item.SpeakerID === voiceId);
|
console.log('激活结果', result);
|
||||||
|
if (result?.Result.Statuses) {
|
||||||
|
const hasCurrentSpeakId = result?.Result.Statuses.find((item: any) => item.SpeakerID === voiceId);
|
||||||
return hasCurrentSpeakId;
|
return hasCurrentSpeakId;
|
||||||
}
|
}
|
||||||
|
} catch (error) {
|
||||||
|
const responseResult = error.response.data;
|
||||||
|
console.log('激活失败', responseResult);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取speakId
|
* 获取speakId
|
||||||
|
|
Loading…
Reference in New Issue