From 0ac9a6ff44794d06fffeeeb50d64cc25f950004c Mon Sep 17 00:00:00 2001 From: guofei Date: Wed, 4 Dec 2024 15:23:35 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E4=BF=AE=E5=A4=8D2.0=E5=85=8B=E9=9A=86?= =?UTF-8?q?=E9=97=AE=E9=A2=98=202.=20=E4=BF=AE=E5=A4=8D=E6=9D=A1=E4=BB=B6?= =?UTF-8?q?=E7=AD=9B=E9=80=89=203.=20=E4=BD=BF=E7=94=A8=E8=A7=92=E8=89=B2?= =?UTF-8?q?=E8=87=AA=E5=AE=9A=E7=9A=84voiceID?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../RedisTask/RedisTaskProcessor.service.ts | 16 +++++++++++++++- .../SystemCharter/SystemCharter.controller.ts | 18 +++++++++++++++--- src/services/VolcenAudioSpeakService.ts | 9 ++++++++- 3 files changed, 38 insertions(+), 5 deletions(-) diff --git a/src/common/RedisTask/RedisTaskProcessor.service.ts b/src/common/RedisTask/RedisTaskProcessor.service.ts index 5e04021..8f55a05 100644 --- a/src/common/RedisTask/RedisTaskProcessor.service.ts +++ b/src/common/RedisTask/RedisTaskProcessor.service.ts @@ -24,8 +24,22 @@ export class RedisTaskProcessor { console.log(job.data); console.log(`开始处理任务 [第${job.attemptsMade + 1}次尝试]: ${job.data.roleName}`); + // 先查询人物是否有 voiceId, 如果有就用当前用户的 voiceId const volcenAudioSpeakService = new VolcenAudioSpeakService(); - voiceId = await volcenAudioSpeakService.getVoiceId(); + const user = await this.dbService.systemCharter.findUnique({ + where: { + id: charterInfo.roleId, + }, + }); + console.log('用户是否有voiceID', user.voiceId); + if (user.voiceId) { + voiceId = user.voiceId; + } else { + voiceId = await volcenAudioSpeakService.getVoiceId(); + } + if (!voiceId) { + throw new Error('获取voiceId失败' + JSON.stringify(voiceId)); + } // voiceId = 'S_VK2Yw0Gb1'; // 请求ossurl获取base64 const base64 = await volcenAudioSpeakService.getAudioBase64(ossUrl); diff --git a/src/modules/SystemCharter/SystemCharter.controller.ts b/src/modules/SystemCharter/SystemCharter.controller.ts index f27f641..54824bf 100644 --- a/src/modules/SystemCharter/SystemCharter.controller.ts +++ b/src/modules/SystemCharter/SystemCharter.controller.ts @@ -30,7 +30,7 @@ export class SystemCharterController { @Get('/getList') async getList(@Query() query: SystemCharterlDto & { originAudioUrl?: string }) { const { current, pageSize, ...other } = query; - const where = {}; + let where = {}; if (other.roleName) { where['roleName'] = { contains: other.roleName, @@ -41,13 +41,25 @@ export class SystemCharterController { // 根据原始音频状态筛选 if (query.originAudioUrl == 'true') { // 已克隆的 - where['originAudioUrl'] = { + where['voiceId'] = { not: null, }; } else { // 为空的数据 // where['OR'] = [{ originAudioUrl: null }, { originAudioUrl: '' }, { originAudioUrl: undefined }]; - where['originAudioUrl'] = undefined; + where = { + ...where, + OR: [ + { + voiceId: null, + }, + { + voiceId: { + isSet: false, + }, + }, + ], + }; } } diff --git a/src/services/VolcenAudioSpeakService.ts b/src/services/VolcenAudioSpeakService.ts index 39407d7..187e838 100644 --- a/src/services/VolcenAudioSpeakService.ts +++ b/src/services/VolcenAudioSpeakService.ts @@ -102,7 +102,14 @@ export class VolcenAudioSpeakService { bits: 16, }, ], - // model_type:1, + model_type: 1, + // cn = 0 中文(默认) + // en = 1 英文 + // ja = 2 日语 + // es = 3 西班牙语 + // id = 4 印尼语 + // pt = 5 葡萄牙语 + language: 0, source: 2, };