|
@@ -2,6 +2,7 @@ package com.fs.qw.qwTask;
|
|
|
|
|
|
|
|
import com.fs.aiSoundReplication.param.TtsRequest;
|
|
import com.fs.aiSoundReplication.param.TtsRequest;
|
|
|
import com.fs.aiSoundReplication.service.impl.TtsServiceImpl;
|
|
import com.fs.aiSoundReplication.service.impl.TtsServiceImpl;
|
|
|
|
|
+import com.fs.common.core.redis.RedisCache;
|
|
|
import com.fs.company.mapper.CompanyUserMapper;
|
|
import com.fs.company.mapper.CompanyUserMapper;
|
|
|
import com.fs.company.param.VcCompanyUser;
|
|
import com.fs.company.param.VcCompanyUser;
|
|
|
import com.fs.company.service.ICompanyUserService;
|
|
import com.fs.company.service.ICompanyUserService;
|
|
@@ -33,6 +34,7 @@ import java.time.LocalDateTime;
|
|
|
import java.time.ZoneId;
|
|
import java.time.ZoneId;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
@Component("qwTask")
|
|
@Component("qwTask")
|
|
@@ -108,6 +110,9 @@ public class qwTask {
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private TtsServiceImpl ttsServiceImpl;
|
|
private TtsServiceImpl ttsServiceImpl;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private RedisCache redisCache;
|
|
|
|
|
+
|
|
|
|
|
|
|
|
//正在使用
|
|
//正在使用
|
|
|
public void qwExternalContact()
|
|
public void qwExternalContact()
|
|
@@ -443,6 +448,10 @@ public class qwTask {
|
|
|
.collect(Collectors.toMap(VcCompanyUser::getCompanyUserId, v -> v, (a, b) -> a));
|
|
.collect(Collectors.toMap(VcCompanyUser::getCompanyUserId, v -> v, (a, b) -> a));
|
|
|
List<QwSopTempVoice> filteredVoices = qwSopTempVoices.stream()
|
|
List<QwSopTempVoice> filteredVoices = qwSopTempVoices.stream()
|
|
|
.filter(v -> v.getCompanyUserId() != null && vcUserMap.containsKey(v.getCompanyUserId()))
|
|
.filter(v -> v.getCompanyUserId() != null && vcUserMap.containsKey(v.getCompanyUserId()))
|
|
|
|
|
+ .filter(v -> {
|
|
|
|
|
+ String redisKey = "sop:voice:processing:" + v.getId();
|
|
|
|
|
+ return redisCache.setIfAbsent(redisKey, "1",12, TimeUnit.HOURS);
|
|
|
|
|
+ })
|
|
|
.collect(Collectors.toList());
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
|
|
filteredVoices.forEach(item -> {
|
|
filteredVoices.forEach(item -> {
|
|
@@ -450,13 +459,22 @@ public class qwTask {
|
|
|
AudioVO audioVO = ttsServiceImpl.textToSpeech(new TtsRequest(null, null, vcCompanyUser.getSpeakerId(), item.getVoiceTxt()));
|
|
AudioVO audioVO = ttsServiceImpl.textToSpeech(new TtsRequest(null, null, vcCompanyUser.getSpeakerId(), item.getVoiceTxt()));
|
|
|
item.setVoiceUrl(audioVO.getUrl());
|
|
item.setVoiceUrl(audioVO.getUrl());
|
|
|
item.setDuration(audioVO.getDuration());
|
|
item.setDuration(audioVO.getDuration());
|
|
|
-
|
|
|
|
|
|
|
+ item.setUserVoiceUrl(audioVO.getWavUrl());
|
|
|
QwUser user = qwUserMapper.selectQwUserconvertSopVoice(item.getCompanyUserId());
|
|
QwUser user = qwUserMapper.selectQwUserconvertSopVoice(item.getCompanyUserId());
|
|
|
ttsServiceImpl.ttsChargeByCount(vcCompanyUser,audioVO,user);
|
|
ttsServiceImpl.ttsChargeByCount(vcCompanyUser,audioVO,user);
|
|
|
|
|
|
|
|
});
|
|
});
|
|
|
// 批量更新
|
|
// 批量更新
|
|
|
- iQwSopTempVoiceService.saveOrUpdateBatch(filteredVoices);
|
|
|
|
|
|
|
+ int batchSize = 200;
|
|
|
|
|
+ for (int i = 0; i < filteredVoices.size(); i += batchSize) {
|
|
|
|
|
+ List<QwSopTempVoice> batch = filteredVoices.subList(i, Math.min(i + batchSize, filteredVoices.size()));
|
|
|
|
|
+ iQwSopTempVoiceService.updateBatchWithDataSource(batch);
|
|
|
|
|
+ }
|
|
|
|
|
+ // 更新完成后清除Redis标记
|
|
|
|
|
+ filteredVoices.forEach(item -> {
|
|
|
|
|
+ String redisKey = "sop:voice:processing:" + item.getId();
|
|
|
|
|
+ redisCache.deleteObject(redisKey);
|
|
|
|
|
+ });
|
|
|
}catch (Exception e){
|
|
}catch (Exception e){
|
|
|
|
|
|
|
|
}
|
|
}
|