激活克隆声音
parent
ee7a83547e
commit
e4dc47a83f
|
@ -164,16 +164,28 @@ export class SystemCharterController {
|
|||
}
|
||||
}
|
||||
|
||||
@Get('activateVoice')
|
||||
async activateVoice(@Query('speakerId') speakerId: string) {
|
||||
@Post('activateVoice/:roleId')
|
||||
async activateVoice(@Param('roleId') roleId: string) {
|
||||
try {
|
||||
if (!speakerId) {
|
||||
return ApiResponse.failToMessage('参数错误:缺少speakerId');
|
||||
if (!roleId) {
|
||||
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 isActivate = await volcenAudioSpeakService.speakActivate(speakerId);
|
||||
const isActivate = await volcenAudioSpeakService.speakActivate(charter.voiceId);
|
||||
if (isActivate) {
|
||||
// 修改当前用户的激活状态
|
||||
await this.dbService.systemCharter.update({
|
||||
where: { id: roleId },
|
||||
data: { activate: true },
|
||||
});
|
||||
return ApiResponse.success('音频激活成功');
|
||||
} else {
|
||||
return ApiResponse.failToMessage('音频激活失败');
|
||||
|
@ -323,13 +335,14 @@ export class SystemCharterController {
|
|||
where: { id: roleId },
|
||||
});
|
||||
|
||||
// 判断是否有克隆次数
|
||||
|
||||
|
||||
if (!charter) {
|
||||
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({
|
||||
where: {
|
||||
|
|
|
@ -161,16 +161,25 @@ export class VolcenAudioSpeakService {
|
|||
secretKey: VolcenAudioSpeakService.TiktokSecretKeyId,
|
||||
});
|
||||
// 激活
|
||||
const activateVoiceResult = await axios.post(
|
||||
VolcenAudioSpeakService.ENGIN_BASE_URL_API + '?Action=ActivateMegaTTSTrainStatus&Version=2023-11-07',
|
||||
activatePost.body,
|
||||
{
|
||||
headers: activatePost.headers,
|
||||
},
|
||||
);
|
||||
|
||||
const hasCurrentSpeakId = activateVoiceResult.data?.Result.Statuses.find((item: any) => item.SpeakerID === voiceId);
|
||||
return hasCurrentSpeakId;
|
||||
try {
|
||||
const activateVoiceResult = await axios.post(
|
||||
VolcenAudioSpeakService.ENGIN_BASE_URL_API + '?Action=ActivateMegaTTSTrainStatus&Version=2023-11-07',
|
||||
activatePost.body,
|
||||
{
|
||||
headers: activatePost.headers,
|
||||
},
|
||||
);
|
||||
const result = activateVoiceResult.data;
|
||||
console.log('激活结果', result);
|
||||
if (result?.Result.Statuses) {
|
||||
const hasCurrentSpeakId = result?.Result.Statuses.find((item: any) => item.SpeakerID === voiceId);
|
||||
return hasCurrentSpeakId;
|
||||
}
|
||||
} catch (error) {
|
||||
const responseResult = error.response.data;
|
||||
console.log('激活失败', responseResult);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue