Commit 762d8e77 by 前端

报告

1 parent baf70767
// packageEquity/pages/aiCheck/chat/chat.js // packageEquity/pages/aiCheck/chat/chat.js
import carLifeApi from '../../../carEquityApi' import carLifeApi from '../../../carEquityApi'
const VOICE = ['zhifeng_emo', 'stanley', 'zhibing_emo', 'rosa', 'zhimiao_emo', 'zhiyan_emo'] const VOICE = {1:'zhifeng_emo', 2:'stanley', 3:'rosa',4:'zhibing_emo', 5:'zhimiao_emo', 9:'zhiyan_emo'}
const productList = [{
id: 1,
name: "驻店延保",
description: "模拟驻点人员向车主推销延保产品",
imgName: "extended-warranty",
isAvailable: true,
},
{
id: 2,
name: "权益升级",
description: "快速获取车主需求,推荐权益产品",
imgName: "rights-upgrade",
isAvailable: false,
},
{
id: 3,
name: "轻改升级",
description: "通过精品礼券,引导客户到店轻改升级",
imgName: "minor-upgrade",
isAvailable: false,
},
];
let timer = null; let timer = null;
let duration = 0; let duration = 0;
import aiApi from "../../../aiApi"; import aiApi from "../../../aiApi";
...@@ -37,7 +15,7 @@ Page({ ...@@ -37,7 +15,7 @@ Page({
scrollTop: 0, scrollTop: 0,
defense_step: 0, //攻防步骤的编号,表示当前攻防的阶段。 defense_step: 0, //攻防步骤的编号,表示当前攻防的阶段。
round: 0, //对练的轮次,用于记录当前对话是第几轮对练。 round: 0, //对练的轮次,用于记录当前对话是第几轮对练。
step: "reception", // 当前对练的环节,可选值为"reception"(接待)、"defense"(攻防)、"referral"(转介)、"over"(结束),用于指示当前处理的环节。 step: "reception", // reception delivery defense referral 四个环节的字典值
navStyle: "background-color: transparent", navStyle: "background-color: transparent",
showChat: false, // false 展示介绍页,true展示聊天页 showChat: false, // false 展示介绍页,true展示聊天页
showScenePopup: false, // 场弹窗 showScenePopup: false, // 场弹窗
...@@ -238,8 +216,9 @@ Page({ ...@@ -238,8 +216,9 @@ Page({
}, },
closeSpeechPopup() { closeSpeechPopup() {
this.setData({ this.setData({
showSpeechPopup: false, showSpeechPopup: false
}); });
// this.send({detail:{result:'你好欢迎光临'}})
}, },
//获取改进建议和润色表达 //获取改进建议和润色表达
getEnhancement(last_message,idx) { getEnhancement(last_message,idx) {
...@@ -393,11 +372,6 @@ Page({ ...@@ -393,11 +372,6 @@ Page({
defense_step, defense_step,
step: next_step, step: next_step,
}); });
if (next_step == "over") {
setTimeout(() => {
this.toResult();
}, 3000);
}
}); });
}, },
handleShow(e) { handleShow(e) {
...@@ -509,7 +483,7 @@ Page({ ...@@ -509,7 +483,7 @@ Page({
stage, stage,
avatar, avatar,
person_type, person_type,
voice: VOICE[roleType - 1], voice: VOICE[roleType],
roleName, roleName,
roleType, roleType,
batch_id: (Math.random() + "").slice(2), batch_id: (Math.random() + "").slice(2),
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
</view> </view>
</view> </view>
</view> </view>
<audio-tts showSpeechPopup="{{showSpeechPopup}}" roleName="{{roleName}}" chatList="{{chatList}}" voice="{{voice}}" avatar="{{avatar}}" id="audioBox"></audio-tts></scroll-view> <audio-tts wx:if="{{roleName}}" isDemo="{{isDemo}}" showSpeechPopup="{{showSpeechPopup}}" roleName="{{roleName}}" chatList="{{chatList}}" voice="{{voice}}" avatar="{{avatar}}" id="audioBox"></audio-tts></scroll-view>
</view> </view>
<view class="control-box" style="{{controlBoxStyle}}"> <view class="control-box" style="{{controlBoxStyle}}">
<view class="inspiration-btn {{popType == 'inspiration' ? 'active' : ''}}" bindtap="openPopup" data-type="inspiration"><gl-image class="icon" src="/aiCheck/{{popType == 'inspiration' ? 'inspiration-icon-white' : 'inspiration-icon'}}.png"></gl-image></view> <view class="inspiration-btn {{popType == 'inspiration' ? 'active' : ''}}" bindtap="openPopup" data-type="inspiration"><gl-image class="icon" src="/aiCheck/{{popType == 'inspiration' ? 'inspiration-icon-white' : 'inspiration-icon'}}.png"></gl-image></view>
......
...@@ -30,6 +30,7 @@ Component({ ...@@ -30,6 +30,7 @@ Component({
avatar: String, avatar: String,
voice: String, voice: String,
roleName: String, roleName: String,
isDemo: Boolean,
showSpeechPopup: { showSpeechPopup: {
type: Boolean, type: Boolean,
observer: function (n) { observer: function (n) {
...@@ -79,17 +80,11 @@ Component({ ...@@ -79,17 +80,11 @@ Component({
getVoiceConfig() { getVoiceConfig() {
aiApi aiApi
.getVoiceConfig({ .getVoiceConfig({
person_type: this.data.roleName person_type: this.data.roleName.replace(/客户/, '')
}).then(res => { }).then(res => {
const { this.setData({
access_token, voiceInfo: res
app_id, })
application_name,
company_name,
person_type,
secret_key,
voice_id
} = res
}) })
}, },
HS_play(text) { HS_play(text) {
...@@ -100,8 +95,8 @@ Component({ ...@@ -100,8 +95,8 @@ Component({
access_token, access_token,
app_id: appid, app_id: appid,
voice_id: voice_type voice_id: voice_type
} = this.data } = this.data.voiceInfo;
_this = this; const _this = this;
const cluster = "volcano_mega"; const cluster = "volcano_mega";
wx.request({ wx.request({
url: 'https://openspeech.bytedance.com/api/v1/tts', url: 'https://openspeech.bytedance.com/api/v1/tts',
...@@ -144,9 +139,10 @@ Component({ ...@@ -144,9 +139,10 @@ Component({
data: arrayBuffer, data: arrayBuffer,
encoding: 'base64', encoding: 'base64',
success(res) { success(res) {
const audioContext = wx.createInnerAudioContext(); _this.setAudio(_this.data.selectIndex, audioPath, 'ai')
audioContext.src = audioPath; // const audioContext = wx.createInnerAudioContext();
audioContext.play(); // audioContext.src = audioPath;
// audioContext.play();
}, },
}) })
} }
...@@ -358,11 +354,19 @@ Component({ ...@@ -358,11 +354,19 @@ Component({
file_link: url file_link: url
}).then(res => { }).then(res => {
const Sentences = res.Sentences const Sentences = res.Sentences
const Sentences_desc = this.getSentencesDetail(Sentences, this.data.list[i].content) const {
speed,
intonation,
definition,
redundant
} = this.getSentencesDetail(Sentences, this.data.list[i].content)
this.setData({ this.setData({
['list[' + i + '].voiceUrl']: url, ['list[' + i + '].voiceUrl']: url,
['list[' + i + '].Sentences']: Sentences, ['list[' + i + '].Sentences']: Sentences,
['list[' + i + '].Sentences_desc']: Sentences_desc ['list[' + i + '].speed']: speed,
['list[' + i + '].intonation']: intonation,
['list[' + i + '].definition']: definition,
['list[' + i + '].redundant']: redundant
}); });
console.log(this.data.list) console.log(this.data.list)
}) })
...@@ -374,17 +378,20 @@ Component({ ...@@ -374,17 +378,20 @@ Component({
Sentences.forEach(i => { Sentences.forEach(i => {
totalSpeed += i.SpeechRate; totalSpeed += i.SpeechRate;
totalEmotionValue += i.EmotionValue; totalEmotionValue += i.EmotionValue;
SpeechRateAll.push(i.SpeechRate) SpeechRateAll.push(i.EmotionValue)
}) })
const averageSpeed = totalSpeed / Sentences.length; const averageSpeed = totalSpeed / Sentences.length;
const averageEmotionValue = totalEmotionValue / Sentences.length const averageEmotionValue = totalEmotionValue / Sentences.length
const val_1 = SpeechRateValue[calculateStars(averageSpeed)] const speed = SpeechRateValue[calculateStars(averageSpeed)]
const val_2 = calculateIntonation(SpeechRateAll) const intonation = calculateIntonation(SpeechRateAll)
console.log(calculateEmotion, averageEmotionValue) const definition = calculateEmotion(averageEmotionValue)
const val_3 = calculateEmotion(averageEmotionValue) const redundant = this.getNum(redundantWords)
const val_4 = this.getNum(redundantWords) return {
console.log(val_1, val_2, val_3, val_4) speed,
return [val_1, val_2, val_3, val_4] intonation,
definition,
redundant
}
}, },
getNum(words) { getNum(words) {
// 构建一个正则表达式,匹配数组h中每个元素的叠词 // 构建一个正则表达式,匹配数组h中每个元素的叠词
...@@ -436,9 +443,12 @@ Component({ ...@@ -436,9 +443,12 @@ Component({
this.toBottom() this.toBottom()
this.stopAudio() this.stopAudio()
}, },
setSuggest(val,i) { setSuggest(val, i) {
this.setData({ this.setData({
['list[' + i + ']']: {...this.data.list[i],...val} ['list[' + i + ']']: {
...this.data.list[i],
...val
}
}) })
}, },
/** /**
...@@ -490,13 +500,23 @@ Component({ ...@@ -490,13 +500,23 @@ Component({
}, },
//AI声音播放 //AI声音播放
playAudio: wx.$util.throttle(function (e) { playAudio: wx.$util.throttle(function (e) {
console.log(33)
let index = e.currentTarget ? e.currentTarget.dataset.index : e let index = e.currentTarget ? e.currentTarget.dataset.index : e
this.onTtsStart(index) const {
isDemo
} = this.data
isDemo ? this.playTTS(index) : this.onTtsStart(index)
}, 1000), }, 1000),
//火山声音复刻 //火山声音复刻
playTTS() { playTTS(index) {
const {
list,
} = this.data;
this.stopAudio()
this.setData({
selectIndex: index
})
const idx = list.findIndex(i => i.id == index)
this.HS_play(list[idx].content)
}, },
async onTtsStart(index) { async onTtsStart(index) {
const { const {
......
...@@ -73,19 +73,19 @@ ...@@ -73,19 +73,19 @@
<view class="chat-aspect"> <view class="chat-aspect">
<view class="aspect-item"> <view class="aspect-item">
<view class="aspect-name">语速</view> <view class="aspect-name">语速</view>
<view class="aspect-result">{{item.Sentences_desc[0]}}</view> <view class="aspect-result">{{item.speed}}</view>
</view> </view>
<view class="aspect-item"> <view class="aspect-item">
<view class="aspect-name">语调</view> <view class="aspect-name">语调</view>
<view class="aspect-result">{{item.Sentences_desc[1]}}</view> <view class="aspect-result">{{item.intonation}}</view>
</view> </view>
<view class="aspect-item"> <view class="aspect-item">
<view class="aspect-name">清晰度</view> <view class="aspect-name">清晰度</view>
<view class="aspect-result">{{item.Sentences_desc[2]}}</view> <view class="aspect-result">{{item.definition}}</view>
</view> </view>
<view class="aspect-item"> <view class="aspect-item">
<view class="aspect-name">冗余词</view> <view class="aspect-name">冗余词</view>
<view class="aspect-result">{{item.Sentences_desc[3]}}</view> <view class="aspect-result">{{item.redundant}}</view>
</view> </view>
</view> </view>
<view class="suggest"> <view class="suggest">
......
...@@ -184,25 +184,37 @@ Page({ ...@@ -184,25 +184,37 @@ Page({
uuid uuid
} = wx.$util.getUserInfo(); } = wx.$util.getUserInfo();
console.log(history_message); console.log(history_message);
if (id) { if (id) {
this.setData({ this.setData({
duration: false duration: false
}) })
this.getDetail(id); this.getDetail(id);
this.getChatDetail({staffRecordId: uuid}) this.getChatDetail({
staffRecordId: uuid
})
} else { } else {
const chatList = JSON.parse(wx.getStorageSync("chatList")); const chatList = JSON.parse(wx.getStorageSync("chatList"));
this.setData({chatList}) this.setData({
this.handleSave(chatList,duration) chatList
})
this.handleSave(chatList, duration)
} }
console.log(windowW); console.log(windowW);
}, },
getChatDetail(staffRecordId) { getChatDetail(staffRecordId) {
carLifeApi.getSparringDetail({staffRecordId,pageNum:1,pageSize:100}).then(res=>{ carLifeApi.getSparringDetail({
const {list=[] } = res.data staffRecordId,
this.setData({chatList: list}) pageNum: 1,
pageSize: 100
}).then(res => {
const {
list = []
} = res.data
this.setData({
chatList: list
})
}) })
}, },
//提交数据 //提交数据
...@@ -306,7 +318,7 @@ Page({ ...@@ -306,7 +318,7 @@ Page({
return { return {
...desc, ...desc,
...selectedXYItem, ...selectedXYItem,
className:'move-circle' className: 'move-circle'
}; };
}) })
this.setData({ this.setData({
...@@ -315,70 +327,88 @@ Page({ ...@@ -315,70 +327,88 @@ Page({
}, 500) }, 500)
}); });
}, },
convertSecondsToMinutesAndSeconds(seconds,isSymbol) { convertSecondsToMinutesAndSeconds(seconds, isSymbol) {
var minutes = Math.floor(seconds / 60); // 计算分钟数 var minutes = Math.floor(seconds / 60); // 计算分钟数
var remainingSeconds = seconds % 60; // 计算剩余的秒数 var remainingSeconds = seconds % 60; // 计算剩余的秒数
// 如果剩余的秒数小于10,则前面添加0以保持格式一致 // 如果剩余的秒数小于10,则前面添加0以保持格式一致
if (remainingSeconds < 10) { if (remainingSeconds < 10) {
remainingSeconds = '0' + remainingSeconds; remainingSeconds = '0' + remainingSeconds;
} }
let res = minutes + '分' + remainingSeconds+'秒'; let res = minutes + '分' + remainingSeconds + '秒';
if(isSymbol) { if (isSymbol) {
res = minutes + ':' + remainingSeconds; res = minutes + ':' + remainingSeconds;
} }
return res return res
}, },
getSentencesDetail(Sentences,totalTime,redundantWord) { getSentencesDetail(Sentences, totalTime, redundantWord) {
let totalSpeed = 0; let totalSpeed = 0;
let totalEmotionValue = 0; let totalEmotionValue = 0;
const axisX = []; const axisX = [];
const axisY_SpeechRate = []; const axisY_SpeechRate = [];
const axisY_EmotionValue = []; const axisY_EmotionValue = [];
Sentences.forEach((i,k) => { if (Sentences.length > 2) {
totalSpeed += i.SpeechRate; Sentences.forEach((i, k) => {
totalEmotionValue+= i.EmotionValue; totalSpeed += i.SpeechRate;
if(k == 0) { totalEmotionValue += i.EmotionValue;
axisX.push('0:00') if (k == 0) {
}else if(k == Sentences.length -1 ) { axisX.push('0:00')
axisX.push(this.convertSecondsToMinutesAndSeconds(totalTime,true)) } else if (k == Sentences.length - 1) {
} else { axisX.push(this.convertSecondsToMinutesAndSeconds(totalTime, true))
axisX.push(k) } else {
axisX.push(k)
}
axisY_SpeechRate.push(i.SpeechRate)
axisY_EmotionValue.push(i.EmotionValue)
})
if(Sentences.length == 2) {
axisX.push(this.convertSecondsToMinutesAndSeconds(totalTime, true))
axisY_SpeechRate.push(Sentences[1].SpeechRate)
axisY_EmotionValue.push(Sentences[1].EmotionValue)
} }
axisY_SpeechRate.push(i.SpeechRate) } else {
axisY_EmotionValue.push(i.EmotionValue) axisX = ['0:00', 1, this.convertSecondsToMinutesAndSeconds(totalTime, true)]
}) axisY_SpeechRate = [Sentences[0].SpeechRate, Sentences[0].SpeechRate, Sentences[0].SpeechRate];
axisY_EmotionValue = [Sentences[0].EmotionValue, Sentences[0].EmotionValue, Sentences[0].EmotionValue]
totalSpeed = Sentences[0].SpeechRate
totalEmotionValue = Sentences[0].EmotionValue
}
const averageSpeed = totalSpeed / Sentences.length; const averageSpeed = totalSpeed / Sentences.length;
const averageEmotionValue = totalEmotionValue / Sentences.length const averageEmotionValue = totalEmotionValue / Sentences.length
const speechSpeed = { const speechSpeed = {
star:calculateStars(averageSpeed), star: calculateStars(averageSpeed),
x:axisX, x: axisX,
y: axisY_SpeechRate, y: axisY_SpeechRate,
min:speechSpeed_MIN, min: speechSpeed_MIN,
max:speechSpeed_MAX max: speechSpeed_MAX
} }
const definition = { const definition = {
x:axisX, x: axisX,
y:axisY_EmotionValue, y: axisY_EmotionValue,
star:calculateEmotion(averageEmotionValue,true), star: calculateEmotion(averageEmotionValue, true),
min:Emotion_MIN, min: Emotion_MIN,
max:Emotion_MAX max: Emotion_MAX
} }
const axisY_Intonation = axisY_SpeechRate.map((currentValue, index) => { const axisY_Intonation = axisY_SpeechRate.map((currentValue, index) => {
if (index < axisY_SpeechRate.length - 1) { if (index < axisY_SpeechRate.length - 1) {
return axisY_SpeechRate[index + 1] - currentValue + 1; return axisY_SpeechRate[index + 1] - currentValue + 1;
}else { } else {
return 1 return 1
} }
}); });
const intonation = { const intonation = {
x:axisX, x: axisX,
y:axisY_Intonation, y: axisY_Intonation,
star:calculateIntonation(axisY_SpeechRate,true), star: calculateIntonation(axisY_EmotionValue, true),
min:Emotion_MIN, min: Emotion_MIN,
max:Emotion_MAX max: Emotion_MAX
} }
const redundantWords = this.getWord(redundantWord) const redundantWords = this.getWord(redundantWord)
return {speechSpeed,redundantWords,definition,intonation} return {
speechSpeed,
redundantWords,
definition,
intonation
}
}, },
getWord(words) { getWord(words) {
const sentences = words.split(/[,。,]/); const sentences = words.split(/[,。,]/);
...@@ -395,22 +425,30 @@ Page({ ...@@ -395,22 +425,30 @@ Page({
if (star < 1) { if (star < 1) {
star = 1 star = 1
} }
const content = filteredSentences.join(","); const content = filteredSentences.join(",");
return {star,content} return {
star,
content
}
}, },
handleSave(list, sparringDuration) { handleSave(list, sparringDuration) {
console.log(list) console.log(list)
let totalTime = 0; let totalTime = 0;
let Sentences = []; let Sentences = [];
let content; let content;
list.forEach(i=>{ list.forEach(i => {
if(i.role == 2) { if (i.role == 2) {
totalTime += i.times totalTime += i.times
content+=i.content content += i.content
Sentences = [...Sentences,...i.Sentences] Sentences = [...Sentences, ...i.Sentences]
} }
}) })
const {speechSpeed,redundantWords,definition,intonation} = this.getSentencesDetail(Sentences,totalTime,content) const {
speechSpeed,
redundantWords,
definition,
intonation
} = this.getSentencesDetail(Sentences, totalTime, content)
const { const {
sparringTaskId, sparringTaskId,
roleType, roleType,
...@@ -437,6 +475,10 @@ Page({ ...@@ -437,6 +475,10 @@ Page({
voiceUrl, voiceUrl,
times: voiceDuration, times: voiceDuration,
spkTime, spkTime,
speed,
intonation,
definition,
redundant
} = i; } = i;
return { return {
sparringLink, sparringLink,
...@@ -447,6 +489,10 @@ Page({ ...@@ -447,6 +489,10 @@ Page({
improve, improve,
polish, polish,
spkTime, spkTime,
speed,
intonation,
definition,
redundant
}; };
}); });
carLifeApi.sparringCommit({ carLifeApi.sparringCommit({
...@@ -458,7 +504,7 @@ Page({ ...@@ -458,7 +504,7 @@ Page({
fluency, fluency,
deliver, deliver,
details: JSON.stringify(details), details: JSON.stringify(details),
}).then(res=>{ }).then(res => {
this.getDetail(res.data.sparringRecordId) this.getDetail(res.data.sparringRecordId)
}); });
}, },
...@@ -477,7 +523,7 @@ Page({ ...@@ -477,7 +523,7 @@ Page({
name: "评分", name: "评分",
data, data,
alpha: 0.2, alpha: 0.2,
lineColor:'#4864FF', lineColor: '#4864FF',
eachSeries: { eachSeries: {
color: "#3989FE", color: "#3989FE",
}, },
...@@ -493,7 +539,7 @@ Page({ ...@@ -493,7 +539,7 @@ Page({
}, },
}, { }, {
dataPointShape: ["circle"], dataPointShape: ["circle"],
drawLine:true drawLine: true
}); });
}, },
jump(e) { jump(e) {
......
...@@ -81,11 +81,9 @@ Component({ ...@@ -81,11 +81,9 @@ Component({
yqMerchantId: merchantId yqMerchantId: merchantId
}) })
this.setData({isVisible: !res.data.sparringAllow}) this.setData({isVisible: !res.data.sparringAllow})
if (res.data.sparringAllow) {
wx.navigateTo({ wx.navigateTo({
url: `/packageEquity/pages/aiCheck/scene/scene?id=${id}` url: `/packageEquity/pages/aiCheck/scene/scene?id=${id}`
}) })
}
}, },
} }
}) })
\ No newline at end of file \ No newline at end of file
...@@ -2,11 +2,6 @@ import config from './config' ...@@ -2,11 +2,6 @@ import config from './config'
export default function (filePath,options) { export default function (filePath,options) {
return new Promise(async (resolve, reject) => { return new Promise(async (resolve, reject) => {
if (!filePath || filePath.length < 9) { if (!filePath || filePath.length < 9) {
uni.showModal({
title: "文件错误",
content: "请重试",
showCancel: false,
});
reject("文件错误"); reject("文件错误");
} }
// 获取上传的文件类型 // 获取上传的文件类型
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!