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, };