|
@@ -584,6 +584,16 @@ export default {
|
|
|
// 从角色详情中获取场景列表
|
|
|
let sceneList = this.info.sceneList
|
|
|
// 获取当前聊天对应的场景
|
|
|
+ if (!sceneList || sceneList.length.length == 0) {
|
|
|
+ this.$message({
|
|
|
+ message: '该场景已被设为私有或被创作者删除,无法查看',
|
|
|
+ type: 'error'
|
|
|
+ })
|
|
|
+ this.sceneInfo = {
|
|
|
+ isDelete: 1
|
|
|
+ }
|
|
|
+ return
|
|
|
+ }
|
|
|
for (let i = 0; i < sceneList.length; i++) {
|
|
|
const element = sceneList[i];
|
|
|
if (element.sceneId == value2.sceneId) {
|
|
@@ -957,8 +967,10 @@ export default {
|
|
|
// localStorage.setItem(`[userId:${123},aiId:${this.info.id}]`, JSON.stringify(this.returnMessage));
|
|
|
// }
|
|
|
if (this.sceneId) {
|
|
|
- console.log(this.sceneId);
|
|
|
let sceneList = this.info.sceneList
|
|
|
+ if (!sceneList || sceneList.length == 0) {
|
|
|
+ return
|
|
|
+ }
|
|
|
for (let i = 0; i < sceneList.length; i++) {
|
|
|
const element = sceneList[i];
|
|
|
if (element.sceneId == this.sceneId) {
|
|
@@ -974,7 +986,8 @@ export default {
|
|
|
console.log('fffffffffffffffffffffff');
|
|
|
this.returnMessage.push({
|
|
|
role: 'assistant',
|
|
|
- content: this.info.firstContent
|
|
|
+ content: this.info.firstContent,
|
|
|
+ uuid: this.info.uuid,
|
|
|
})
|
|
|
}
|
|
|
},
|
|
@@ -1324,7 +1337,24 @@ export default {
|
|
|
|
|
|
this.loopGetVoice(history.id, index)
|
|
|
},
|
|
|
- playAudio(index) {
|
|
|
+ audioPlay(audioUrl) {
|
|
|
+ try {
|
|
|
+ this.audioUrl = require(audioUrl);
|
|
|
+ } catch (error) {
|
|
|
+ this.$message({
|
|
|
+ message: '语音生成失败',
|
|
|
+ type: 'error'
|
|
|
+ });
|
|
|
+ }
|
|
|
+ setTimeout(() => {
|
|
|
+ if (this.audioUrl && this.audioUrl != 'false') {
|
|
|
+ this.$refs.audio.play()
|
|
|
+ } else {
|
|
|
+ this.audioClose()
|
|
|
+ }
|
|
|
+ }, 1000)
|
|
|
+ },
|
|
|
+ playAudioIndex(index) {
|
|
|
if (index) {
|
|
|
this.audioPlayIndex = index
|
|
|
}
|
|
@@ -1335,14 +1365,14 @@ export default {
|
|
|
// 如果当前播放的语音地址为空,则等待2秒后重新获取
|
|
|
if (!this.audioUrlArr[this.audioUrlArrIndx].voiceAddress && this.videoLoopTime <= 50) {
|
|
|
setTimeout(() => {
|
|
|
- this.playAudio(index)
|
|
|
+ this.playAudioIndex(index)
|
|
|
}, 2000)
|
|
|
return
|
|
|
}
|
|
|
// 如果当前播放的语音地址为false,则跳过当前语音
|
|
|
if (this.audioUrlArr[this.audioUrlArrIndx].voiceAddress == 'false' && this.audioUrlArrIndx < this.audioUrlArr.length - 1) {
|
|
|
this.audioUrlArrIndx += 1
|
|
|
- this.playAudio(index)
|
|
|
+ this.playAudioIndex(index)
|
|
|
return
|
|
|
} else if (this.audioUrlArrIndx > this.audioUrlArr.length - 1) {
|
|
|
this.audioUrl = ''
|
|
@@ -1351,15 +1381,7 @@ export default {
|
|
|
this.audioUrlArr = []
|
|
|
return
|
|
|
}
|
|
|
- this.audioUrl = this.audioUrlArr[this.audioUrlArrIndx].voiceAddress
|
|
|
-
|
|
|
- setTimeout(() => {
|
|
|
- if (this.audioUrl && this.audioUrl != 'false') {
|
|
|
- this.$refs.audio.play()
|
|
|
- } else {
|
|
|
- this.audioClose()
|
|
|
- }
|
|
|
- }, 1000)
|
|
|
+ this.audioPlay(this.audioUrlArr[this.audioUrlArrIndx].voiceAddress)
|
|
|
},
|
|
|
async historyGetVoice(value, index) {
|
|
|
console.log(value, 'value');
|
|
@@ -1375,7 +1397,7 @@ export default {
|
|
|
this.audioUrlArrIndx = 0
|
|
|
this.videoLoopTime = 0
|
|
|
this.loopPlay = false
|
|
|
- this.playAudio(index)
|
|
|
+ this.playAudioIndex(index)
|
|
|
},
|
|
|
async loopGetVoice(id, index) {
|
|
|
this.videoLoopTime += 1
|
|
@@ -1408,7 +1430,7 @@ export default {
|
|
|
console.log(this.audioUrlArr, '进入播放流程1');
|
|
|
if (this.$refs.audio.paused || this.audioUrlArrIndx > this.audioUrlArr.length - 1) {
|
|
|
if (this.loopPlay == false) {
|
|
|
- this.playAudio(index)
|
|
|
+ this.playAudioIndex(index)
|
|
|
this.loopPlay = true
|
|
|
}
|
|
|
}
|
|
@@ -1419,7 +1441,7 @@ export default {
|
|
|
console.log(this.audioUrlArr, '进入播放流程2');
|
|
|
if (this.$refs.audio.paused || this.audioUrlArrIndx > this.audioUrlArr.length - 1) {
|
|
|
if (this.loopPlay == false) {
|
|
|
- this.playAudio(index)
|
|
|
+ this.playAudioIndex(index)
|
|
|
this.loopPlay = true
|
|
|
}
|
|
|
}
|
|
@@ -1441,24 +1463,17 @@ export default {
|
|
|
// 如果当前播放的语音地址为空,则等待2秒后重新获取
|
|
|
if (!this.audioUrlArr[this.audioUrlArrIndx].voiceAddress) {
|
|
|
setTimeout(() => {
|
|
|
- this.playAudio()
|
|
|
+ this.playAudioIndex()
|
|
|
}, 2000)
|
|
|
return
|
|
|
}
|
|
|
// 如果当前播放的语音地址为false,则跳过当前语音
|
|
|
if (this.audioUrlArr[this.audioUrlArrIndx].voiceAddress == 'false' && this.audioUrlArrIndx < this.audioUrlArr.length - 1) {
|
|
|
this.audioUrlArrIndx += 1
|
|
|
- this.playAudio()
|
|
|
+ this.playAudioIndex()
|
|
|
return
|
|
|
}
|
|
|
- this.audioUrl = this.audioUrlArr[this.audioUrlArrIndx].voiceAddress
|
|
|
- setTimeout(() => {
|
|
|
- if (this.audioUrl && this.audioUrl != 'false') {
|
|
|
- this.$refs.audio.play()
|
|
|
- } else {
|
|
|
- this.audioClose()
|
|
|
- }
|
|
|
- }, 100)
|
|
|
+ this.audioPlay(this.audioUrlArr[this.audioUrlArrIndx].voiceAddress)
|
|
|
} else {
|
|
|
this.audioClose()
|
|
|
}
|