|
@@ -49,6 +49,8 @@ import com.fs.his.service.*;
|
|
|
import com.fs.his.utils.ConfigUtil;
|
|
import com.fs.his.utils.ConfigUtil;
|
|
|
import com.fs.his.vo.*;
|
|
import com.fs.his.vo.*;
|
|
|
import com.fs.hisStore.enums.SysConfigEnum;
|
|
import com.fs.hisStore.enums.SysConfigEnum;
|
|
|
|
|
+import com.fs.qw.domain.QwUser;
|
|
|
|
|
+import com.fs.qw.mapper.QwUserMapper;
|
|
|
import com.fs.sop.domain.QwSopTempVoice;
|
|
import com.fs.sop.domain.QwSopTempVoice;
|
|
|
import com.fs.sop.service.IQwSopTempVoiceService;
|
|
import com.fs.sop.service.IQwSopTempVoiceService;
|
|
|
import com.fs.system.oss.CloudStorageService;
|
|
import com.fs.system.oss.CloudStorageService;
|
|
@@ -68,6 +70,7 @@ import org.apache.http.impl.client.HttpClients;
|
|
|
import org.apache.http.util.EntityUtils;
|
|
import org.apache.http.util.EntityUtils;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
+import org.springframework.beans.factory.annotation.Qualifier;
|
|
|
import org.springframework.mock.web.MockMultipartFile;
|
|
import org.springframework.mock.web.MockMultipartFile;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
import org.springframework.validation.annotation.Validated;
|
|
@@ -82,9 +85,7 @@ import javax.sound.sampled.AudioSystem;
|
|
|
import java.io.*;
|
|
import java.io.*;
|
|
|
import java.net.HttpURLConnection;
|
|
import java.net.HttpURLConnection;
|
|
|
import java.net.URL;
|
|
import java.net.URL;
|
|
|
-import java.util.List;
|
|
|
|
|
-import java.util.Optional;
|
|
|
|
|
-import java.util.UUID;
|
|
|
|
|
|
|
+import java.util.*;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
import java.util.concurrent.TimeUnit;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
@@ -123,6 +124,9 @@ public class CompanyUserController extends AppBaseController {
|
|
|
private VoiceCloneController voiceCloneController;
|
|
private VoiceCloneController voiceCloneController;
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private TtsServiceImpl ttsServiceImpl;
|
|
private TtsServiceImpl ttsServiceImpl;
|
|
|
|
|
+ @Qualifier("qwUserMapper")
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private QwUserMapper qwUserMapper;
|
|
|
|
|
|
|
|
@PostMapping("/login")
|
|
@PostMapping("/login")
|
|
|
public R Login(@RequestBody CompanyUserLoginParam param, HttpServletRequest request) {
|
|
public R Login(@RequestBody CompanyUserLoginParam param, HttpServletRequest request) {
|
|
@@ -318,11 +322,20 @@ public class CompanyUserController extends AppBaseController {
|
|
|
if (qwSopTempVoice != null && qwSopTempVoice.getCompanyUserId() != null) {
|
|
if (qwSopTempVoice != null && qwSopTempVoice.getCompanyUserId() != null) {
|
|
|
JSONObject vcConfig = configUtil.generateConfigByKey(SysConfigEnum.VS_CONFIG.getKey());
|
|
JSONObject vcConfig = configUtil.generateConfigByKey(SysConfigEnum.VS_CONFIG.getKey());
|
|
|
if (vcConfig != null && !vcConfig.isEmpty() &&
|
|
if (vcConfig != null && !vcConfig.isEmpty() &&
|
|
|
-// !vcConfig.equals(new JSONObject()) &&
|
|
|
|
|
"2".equals(vcConfig.getString("type"))) {
|
|
"2".equals(vcConfig.getString("type"))) {
|
|
|
VcCompanyUser vcCompanyUser = companyUserMapper.selectVcCompanyUserByCompanyUserId(companyUserId);
|
|
VcCompanyUser vcCompanyUser = companyUserMapper.selectVcCompanyUserByCompanyUserId(companyUserId);
|
|
|
if (vcCompanyUser == null) throw new RuntimeException("用户不存在");
|
|
if (vcCompanyUser == null) throw new RuntimeException("用户不存在");
|
|
|
audioVO = ttsServiceImpl.textToSpeech(new TtsRequest(null, null, vcCompanyUser.getSpeakerId(), qwSopTempVoice.getVoiceTxt().replace(" ", "")));
|
|
audioVO = ttsServiceImpl.textToSpeech(new TtsRequest(null, null, vcCompanyUser.getSpeakerId(), qwSopTempVoice.getVoiceTxt().replace(" ", "")));
|
|
|
|
|
+ QwUser qwUser = new QwUser();
|
|
|
|
|
+ qwUser.setCompanyUserId(companyUserId);
|
|
|
|
|
+ List<QwUser> qwUsers = qwUserMapper.selectQwUserList(qwUser);
|
|
|
|
|
+ if (qwUsers != null && !qwUsers.isEmpty()){
|
|
|
|
|
+ List<QwUser> collect = qwUsers.stream().filter(o -> o.getFastGptRoleId() != null).collect(Collectors.toList());
|
|
|
|
|
+ if (!collect.isEmpty()){
|
|
|
|
|
+ qwUsers = collect;
|
|
|
|
|
+ }
|
|
|
|
|
+ }else qwUsers= Collections.singletonList(new QwUser());
|
|
|
|
|
+ ttsServiceImpl.ttsChargeByCount(vcCompanyUser, audioVO, qwUsers.get(0));
|
|
|
} else {
|
|
} else {
|
|
|
List<FastgptChatVoiceHomo> homos = fastgptChatVoiceHomoMapper.selectFastgptChatVoiceHomoList(new FastgptChatVoiceHomo());
|
|
List<FastgptChatVoiceHomo> homos = fastgptChatVoiceHomoMapper.selectFastgptChatVoiceHomoList(new FastgptChatVoiceHomo());
|
|
|
audioVO = AudioUtils.createUserUrlAndUrl(homos, qwSopTempVoice.getCompanyUserId(), qwSopTempVoice.getVoiceTxt().replace(" ", ""));
|
|
audioVO = AudioUtils.createUserUrlAndUrl(homos, qwSopTempVoice.getCompanyUserId(), qwSopTempVoice.getVoiceTxt().replace(" ", ""));
|
|
@@ -363,11 +376,20 @@ public class CompanyUserController extends AppBaseController {
|
|
|
if (qwSopTempVoice != null && qwSopTempVoice.getId() != null) {
|
|
if (qwSopTempVoice != null && qwSopTempVoice.getId() != null) {
|
|
|
JSONObject vcConfig = configUtil.generateConfigByKey(SysConfigEnum.VS_CONFIG.getKey());
|
|
JSONObject vcConfig = configUtil.generateConfigByKey(SysConfigEnum.VS_CONFIG.getKey());
|
|
|
if (vcConfig != null && !vcConfig.isEmpty() &&
|
|
if (vcConfig != null && !vcConfig.isEmpty() &&
|
|
|
-// !vcConfig.equals(new JSONObject()) &&
|
|
|
|
|
"2".equals(vcConfig.getString("type"))) {
|
|
"2".equals(vcConfig.getString("type"))) {
|
|
|
VcCompanyUser vcCompanyUser = companyUserMapper.selectVcCompanyUserByCompanyUserId(companyUserId);
|
|
VcCompanyUser vcCompanyUser = companyUserMapper.selectVcCompanyUserByCompanyUserId(companyUserId);
|
|
|
if (vcCompanyUser == null) throw new RuntimeException("用户不存在");
|
|
if (vcCompanyUser == null) throw new RuntimeException("用户不存在");
|
|
|
audioVO = ttsServiceImpl.textToSpeech(new TtsRequest(null, null, vcCompanyUser.getSpeakerId(), qwSopTempVoice.getVoiceTxt().replace(" ", "")));
|
|
audioVO = ttsServiceImpl.textToSpeech(new TtsRequest(null, null, vcCompanyUser.getSpeakerId(), qwSopTempVoice.getVoiceTxt().replace(" ", "")));
|
|
|
|
|
+ QwUser qwUser = new QwUser();
|
|
|
|
|
+ qwUser.setCompanyUserId(companyUserId);
|
|
|
|
|
+ List<QwUser> qwUsers = qwUserMapper.selectQwUserList(qwUser);
|
|
|
|
|
+ if (qwUsers != null && !qwUsers.isEmpty()){
|
|
|
|
|
+ List<QwUser> collect = qwUsers.stream().filter(o -> o.getFastGptRoleId() != null).collect(Collectors.toList());
|
|
|
|
|
+ if (!collect.isEmpty()){
|
|
|
|
|
+ qwUsers = collect;
|
|
|
|
|
+ }
|
|
|
|
|
+ }else qwUsers= Collections.singletonList(new QwUser());
|
|
|
|
|
+ ttsServiceImpl.ttsChargeByCount(vcCompanyUser, audioVO, qwUsers.get(0));
|
|
|
} else {
|
|
} else {
|
|
|
audioVO = AudioUtils.createVoiceUrl(qwSopTempVoice.getCompanyUserId(), userVoiceUrl);
|
|
audioVO = AudioUtils.createVoiceUrl(qwSopTempVoice.getCompanyUserId(), userVoiceUrl);
|
|
|
}
|
|
}
|
|
@@ -565,7 +587,7 @@ public class CompanyUserController extends AppBaseController {
|
|
|
Double duration = (double) frames / format.getFrameRate();
|
|
Double duration = (double) frames / format.getFrameRate();
|
|
|
audioInputStream.close();
|
|
audioInputStream.close();
|
|
|
MultipartFile convert = FileToMultipartConverterUtil.convert(file);
|
|
MultipartFile convert = FileToMultipartConverterUtil.convert(file);
|
|
|
- R r = voiceCloneController.uploadVoice(vcCompanyUser.getSpeakerId(), convert, 1, 0);
|
|
|
|
|
|
|
+ R r = voiceCloneController.uploadVoice(vcCompanyUser.getSpeakerId(), convert, vcCompanyUser.getVersionId(), 0);
|
|
|
if (r.get("code") != "200")
|
|
if (r.get("code") != "200")
|
|
|
return AjaxResult.error("上传声纹失败", r.get("msg"));
|
|
return AjaxResult.error("上传声纹失败", r.get("msg"));
|
|
|
vcCompanyUser.incrementTimes();
|
|
vcCompanyUser.incrementTimes();
|