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