mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-27 17:43:55 +08:00
补充
This commit is contained in:
+6
@@ -165,6 +165,9 @@ public class VoiceCloneServiceImpl extends BaseServiceImpl<VoiceCloneDao, VoiceC
|
|||||||
dto.setUserName(sysUserService.getByUserId(entity.getUserId()).getUsername());
|
dto.setUserName(sysUserService.getByUserId(entity.getUserId()).getUsername());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 确保trainStatus字段被正确设置,前端需要这个字段来判断是否为克隆音频
|
||||||
|
dto.setTrainStatus(entity.getTrainStatus());
|
||||||
|
|
||||||
return dto;
|
return dto;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -198,6 +201,9 @@ public class VoiceCloneServiceImpl extends BaseServiceImpl<VoiceCloneDao, VoiceC
|
|||||||
dto.setUserName(sysUserService.getByUserId(entity.getUserId()).getUsername());
|
dto.setUserName(sysUserService.getByUserId(entity.getUserId()).getUsername());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 确保trainStatus字段被正确设置,前端需要这个字段来判断是否为克隆音频
|
||||||
|
dto.setTrainStatus(entity.getTrainStatus());
|
||||||
|
|
||||||
// 设置是否有音频数据
|
// 设置是否有音频数据
|
||||||
dto.setHasVoice(entity.getVoice() != null);
|
dto.setHasVoice(entity.getVoice() != null);
|
||||||
|
|
||||||
|
|||||||
@@ -580,7 +580,9 @@ export default {
|
|||||||
referenceAudio: voice.referenceAudio,
|
referenceAudio: voice.referenceAudio,
|
||||||
// 新增:添加克隆音频相关字段
|
// 新增:添加克隆音频相关字段
|
||||||
cloneAudioUrl: voice.cloneAudioUrl,
|
cloneAudioUrl: voice.cloneAudioUrl,
|
||||||
hasCloneAudio: voice.hasCloneAudio || false
|
hasCloneAudio: voice.hasCloneAudio || false,
|
||||||
|
// 保存训练状态字段,用于判断是否为克隆音频
|
||||||
|
train_status: voice.trainStatus,
|
||||||
}));
|
}));
|
||||||
// 保存完整的音色信息,添加调试信息
|
// 保存完整的音色信息,添加调试信息
|
||||||
console.log("获取到的音色数据:", data.data);
|
console.log("获取到的音色数据:", data.data);
|
||||||
@@ -702,31 +704,33 @@ export default {
|
|||||||
},
|
},
|
||||||
// 检查是否有音频预览
|
// 检查是否有音频预览
|
||||||
hasAudioPreview(item) {
|
hasAudioPreview(item) {
|
||||||
// 检查item中是否包含有效的音频URL字段或克隆音频字段
|
// 检查item中是否包含有效的音频URL字段或克隆音频字段
|
||||||
// 克隆音频通过hasCloneAudio标志或特定格式的ID来判断
|
// 克隆音频通过hasCloneAudio标志或特定格式的ID来判断
|
||||||
const isCloneAudio = item.hasCloneAudio ||
|
const isCloneAudio =
|
||||||
(item.id && item.id.startsWith('e') && item.id.length === 14);
|
item.hasCloneAudio ||
|
||||||
|
(item.id && item.id.startsWith("e") && item.id.length === 14);
|
||||||
|
|
||||||
const audioFields = [
|
const audioFields = [
|
||||||
item.voiceDemo,
|
item.voiceDemo,
|
||||||
item.demoUrl,
|
item.demoUrl,
|
||||||
item.audioUrl,
|
item.audioUrl,
|
||||||
item.voice_demo,
|
item.voice_demo,
|
||||||
item.sample_voice,
|
item.sample_voice,
|
||||||
item.referenceAudio,
|
item.referenceAudio,
|
||||||
item.cloneAudioUrl // 克隆音频的URL
|
item.cloneAudioUrl, // 克隆音频的URL
|
||||||
];
|
];
|
||||||
|
|
||||||
// 检查是否有任何音频字段是有效的URL
|
// 检查是否有任何音频字段是有效的URL
|
||||||
const hasUrlAudio = audioFields.some(field =>
|
const hasUrlAudio = audioFields.some(
|
||||||
|
(field) =>
|
||||||
field !== undefined &&
|
field !== undefined &&
|
||||||
field !== null &&
|
field !== null &&
|
||||||
typeof field === "string" &&
|
typeof field === "string" &&
|
||||||
field.trim() !== "" &&
|
field.trim() !== "" &&
|
||||||
field.toLowerCase().startsWith("http")
|
field.toLowerCase().startsWith("http")
|
||||||
);
|
);
|
||||||
|
|
||||||
return hasUrlAudio || isCloneAudio;
|
return hasUrlAudio || isCloneAudio;
|
||||||
},
|
},
|
||||||
|
|
||||||
// 播放/暂停音频切换
|
// 播放/暂停音频切换
|
||||||
@@ -785,9 +789,14 @@ export default {
|
|||||||
let isCloneAudio = false;
|
let isCloneAudio = false;
|
||||||
|
|
||||||
if (voiceDetail) {
|
if (voiceDetail) {
|
||||||
// 首先检查是否是克隆音频(通过ID格式或hasCloneAudio标志判断)
|
// 首先检查是否是克隆音频(通过train_status字段、hasCloneAudio标志或ID格式判断)
|
||||||
isCloneAudio = voiceDetail.hasCloneAudio ||
|
isCloneAudio =
|
||||||
(voiceDetail.id && voiceDetail.id.startsWith('e') && voiceDetail.id.length === 14);
|
(voiceDetail.train_status !== undefined && voiceDetail.train_status >= 0) ||
|
||||||
|
voiceDetail.hasCloneAudio ||
|
||||||
|
(voiceDetail.id &&
|
||||||
|
voiceDetail.id.startsWith("e") &&
|
||||||
|
voiceDetail.id.length === 14);
|
||||||
|
console.log("克隆音频判断结果:", isCloneAudio, "训练状态:", voiceDetail.train_status);
|
||||||
|
|
||||||
// 获取音频URL
|
// 获取音频URL
|
||||||
if (isCloneAudio && voiceDetail.id) {
|
if (isCloneAudio && voiceDetail.id) {
|
||||||
@@ -804,7 +813,7 @@ export default {
|
|||||||
// 首先调用getAudioId接口获取临时UUID
|
// 首先调用getAudioId接口获取临时UUID
|
||||||
RequestService.sendRequest()
|
RequestService.sendRequest()
|
||||||
.url(`${getServiceUrl()}/voiceClone/audio/${voiceDetail.id}`)
|
.url(`${getServiceUrl()}/voiceClone/audio/${voiceDetail.id}`)
|
||||||
.method('POST')
|
.method("POST")
|
||||||
.success((res) => {
|
.success((res) => {
|
||||||
if (res.code === 0 && res.data) {
|
if (res.code === 0 && res.data) {
|
||||||
// 使用返回的UUID构建播放URL
|
// 使用返回的UUID构建播放URL
|
||||||
|
|||||||
Reference in New Issue
Block a user