feat: 优化
This commit is contained in:
@@ -499,9 +499,9 @@ public class TikUserVoiceServiceImpl implements TikUserVoiceService {
|
||||
log.info("[previewVoice][试听,voiceConfigId={}, voiceId={}, userId={}]",
|
||||
voiceConfigId, reqVO.getVoiceId(), userId);
|
||||
|
||||
String voiceId = null;
|
||||
String fileUrl = null;
|
||||
String referenceText = null;
|
||||
String voiceId;
|
||||
String fileUrl;
|
||||
String referenceText;
|
||||
|
||||
// 1. 通过语音URL合成
|
||||
if (StrUtil.isNotBlank(reqVO.getFileUrl()) && StrUtil.isNotBlank(reqVO.getTranscriptionText())) {
|
||||
@@ -510,6 +510,7 @@ public class TikUserVoiceServiceImpl implements TikUserVoiceService {
|
||||
? reqVO.getFileUrl()
|
||||
: fileApi.presignGetUrl(rawFileUrl, PRESIGN_URL_EXPIRATION_SECONDS);
|
||||
referenceText = reqVO.getTranscriptionText();
|
||||
voiceId = null;
|
||||
}
|
||||
// 2. 用户配音
|
||||
else if (voiceConfigId != null) {
|
||||
@@ -518,8 +519,10 @@ public class TikUserVoiceServiceImpl implements TikUserVoiceService {
|
||||
throw exception(VOICE_NOT_EXISTS, "配音不存在");
|
||||
}
|
||||
|
||||
if (StrUtil.isNotBlank(voice.getVoiceId())) {
|
||||
voiceId = voice.getVoiceId();
|
||||
voiceId = voice.getVoiceId();
|
||||
if (StrUtil.isNotBlank(voiceId)) {
|
||||
fileUrl = null;
|
||||
referenceText = null;
|
||||
} else {
|
||||
FileDO fileDO = fileMapper.selectById(voice.getFileId());
|
||||
if (fileDO == null) {
|
||||
@@ -538,14 +541,14 @@ public class TikUserVoiceServiceImpl implements TikUserVoiceService {
|
||||
if (StrUtil.isBlank(voiceId)) {
|
||||
throw exception(VOICE_NOT_EXISTS, "系统配音音色ID不能为空");
|
||||
}
|
||||
fileUrl = null;
|
||||
referenceText = null;
|
||||
}
|
||||
|
||||
// 统一处理:使用前端传入的 inputText,否则使用默认试听文本
|
||||
String finalText = StrUtil.blankToDefault(reqVO.getInputText(), getPreviewText());
|
||||
|
||||
String instruction = reqVO.getInstruction();
|
||||
Float speechRate = reqVO.getSpeechRate() != null ? reqVO.getSpeechRate() : 1.0f;
|
||||
Float volume = reqVO.getVolume() != null ? reqVO.getVolume() : 0f;
|
||||
Float speechRate = ObjectUtil.defaultIfNull(reqVO.getSpeechRate(), 1.0f);
|
||||
Float volume = ObjectUtil.defaultIfNull(reqVO.getVolume(), 0f);
|
||||
String audioFormat = StrUtil.blankToDefault(reqVO.getAudioFormat(), "mp3");
|
||||
|
||||
// 缓存
|
||||
|
||||
Reference in New Issue
Block a user