Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
saas_plus
/
dj-car-boutique-work-wechat
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
1
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 762d8e77
authored
Jul 22, 2024
by
前端
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
报告
1 parent
baf70767
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
157 additions
and
124 deletions
packageEquity/pages/aiCheck/chat/chat.js
packageEquity/pages/aiCheck/chat/chat.wxml
packageEquity/pages/aiCheck/components/AudioTts/AudioTts.js
packageEquity/pages/aiCheck/components/AudioTts/AudioTts.wxml
packageEquity/pages/aiCheck/result/result.js
packageEquity/pages/aiCheck/start/components/introduction/introduction.js
packageEquity/pages/aiCheck/upload/uploadFile.js
packageEquity/pages/aiCheck/chat/chat.js
View file @
762d8e7
// packageEquity/pages/aiCheck/chat/chat.js
import
carLifeApi
from
'../../../carEquityApi'
const
VOICE
=
[
'zhifeng_emo'
,
'stanley'
,
'zhibing_emo'
,
'rosa'
,
'zhimiao_emo'
,
'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
,
},
];
const
VOICE
=
{
1
:
'zhifeng_emo'
,
2
:
'stanley'
,
3
:
'rosa'
,
4
:
'zhibing_emo'
,
5
:
'zhimiao_emo'
,
9
:
'zhiyan_emo'
}
let
timer
=
null
;
let
duration
=
0
;
import
aiApi
from
"../../../aiApi"
;
...
...
@@ -37,7 +15,7 @@ Page({
scrollTop
:
0
,
defense_step
:
0
,
//攻防步骤的编号,表示当前攻防的阶段。
round
:
0
,
//对练的轮次,用于记录当前对话是第几轮对练。
step
:
"reception"
,
//
当前对练的环节,可选值为"reception"(接待)、"defense"(攻防)、"referral"(转介)、"over"(结束),用于指示当前处理的环节。
step
:
"reception"
,
//
reception delivery defense referral 四个环节的字典值
navStyle
:
"background-color: transparent"
,
showChat
:
false
,
// false 展示介绍页,true展示聊天页
showScenePopup
:
false
,
// 场弹窗
...
...
@@ -238,8 +216,9 @@ Page({
},
closeSpeechPopup
()
{
this
.
setData
({
showSpeechPopup
:
false
,
showSpeechPopup
:
false
});
// this.send({detail:{result:'你好欢迎光临'}})
},
//获取改进建议和润色表达
getEnhancement
(
last_message
,
idx
)
{
...
...
@@ -393,11 +372,6 @@ Page({
defense_step
,
step
:
next_step
,
});
if
(
next_step
==
"over"
)
{
setTimeout
(()
=>
{
this
.
toResult
();
},
3000
);
}
});
},
handleShow
(
e
)
{
...
...
@@ -509,7 +483,7 @@ Page({
stage
,
avatar
,
person_type
,
voice
:
VOICE
[
roleType
-
1
],
voice
:
VOICE
[
roleType
],
roleName
,
roleType
,
batch_id
:
(
Math
.
random
()
+
""
).
slice
(
2
),
...
...
packageEquity/pages/aiCheck/chat/chat.wxml
View file @
762d8e7
...
...
@@ -27,7 +27,7 @@
</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 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>
...
...
packageEquity/pages/aiCheck/components/AudioTts/AudioTts.js
View file @
762d8e7
...
...
@@ -30,6 +30,7 @@ Component({
avatar
:
String
,
voice
:
String
,
roleName
:
String
,
isDemo
:
Boolean
,
showSpeechPopup
:
{
type
:
Boolean
,
observer
:
function
(
n
)
{
...
...
@@ -79,17 +80,11 @@ Component({
getVoiceConfig
()
{
aiApi
.
getVoiceConfig
({
person_type
:
this
.
data
.
roleName
person_type
:
this
.
data
.
roleName
.
replace
(
/客户/
,
''
)
}).
then
(
res
=>
{
const
{
access_token
,
app_id
,
application_name
,
company_name
,
person_type
,
secret_key
,
voice_id
}
=
res
this
.
setData
({
voiceInfo
:
res
})
})
},
HS_play
(
text
)
{
...
...
@@ -100,8 +95,8 @@ Component({
access_token
,
app_id
:
appid
,
voice_id
:
voice_type
}
=
this
.
data
_this
=
this
;
}
=
this
.
data
.
voiceInfo
;
const
_this
=
this
;
const
cluster
=
"volcano_mega"
;
wx
.
request
({
url
:
'https://openspeech.bytedance.com/api/v1/tts'
,
...
...
@@ -144,9 +139,10 @@ Component({
data
:
arrayBuffer
,
encoding
:
'base64'
,
success
(
res
)
{
const
audioContext
=
wx
.
createInnerAudioContext
();
audioContext
.
src
=
audioPath
;
audioContext
.
play
();
_this
.
setAudio
(
_this
.
data
.
selectIndex
,
audioPath
,
'ai'
)
// const audioContext = wx.createInnerAudioContext();
// audioContext.src = audioPath;
// audioContext.play();
},
})
}
...
...
@@ -358,11 +354,19 @@ Component({
file_link
:
url
}).
then
(
res
=>
{
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
({
[
'list['
+
i
+
'].voiceUrl'
]:
url
,
[
'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
)
})
...
...
@@ -374,17 +378,20 @@ Component({
Sentences
.
forEach
(
i
=>
{
totalSpeed
+=
i
.
SpeechRate
;
totalEmotionValue
+=
i
.
EmotionValue
;
SpeechRateAll
.
push
(
i
.
SpeechRat
e
)
SpeechRateAll
.
push
(
i
.
EmotionValu
e
)
})
const
averageSpeed
=
totalSpeed
/
Sentences
.
length
;
const
averageEmotionValue
=
totalEmotionValue
/
Sentences
.
length
const
val_1
=
SpeechRateValue
[
calculateStars
(
averageSpeed
)]
const
val_2
=
calculateIntonation
(
SpeechRateAll
)
console
.
log
(
calculateEmotion
,
averageEmotionValue
)
const
val_3
=
calculateEmotion
(
averageEmotionValue
)
const
val_4
=
this
.
getNum
(
redundantWords
)
console
.
log
(
val_1
,
val_2
,
val_3
,
val_4
)
return
[
val_1
,
val_2
,
val_3
,
val_4
]
const
speed
=
SpeechRateValue
[
calculateStars
(
averageSpeed
)]
const
intonation
=
calculateIntonation
(
SpeechRateAll
)
const
definition
=
calculateEmotion
(
averageEmotionValue
)
const
redundant
=
this
.
getNum
(
redundantWords
)
return
{
speed
,
intonation
,
definition
,
redundant
}
},
getNum
(
words
)
{
// 构建一个正则表达式,匹配数组h中每个元素的叠词
...
...
@@ -436,9 +443,12 @@ Component({
this
.
toBottom
()
this
.
stopAudio
()
},
setSuggest
(
val
,
i
)
{
setSuggest
(
val
,
i
)
{
this
.
setData
({
[
'list['
+
i
+
']'
]:
{...
this
.
data
.
list
[
i
],...
val
}
[
'list['
+
i
+
']'
]:
{
...
this
.
data
.
list
[
i
],
...
val
}
})
},
/**
...
...
@@ -490,13 +500,23 @@ Component({
},
//AI声音播放
playAudio
:
wx
.
$util
.
throttle
(
function
(
e
)
{
console
.
log
(
33
)
let
index
=
e
.
currentTarget
?
e
.
currentTarget
.
dataset
.
index
:
e
this
.
onTtsStart
(
index
)
const
{
isDemo
}
=
this
.
data
isDemo
?
this
.
playTTS
(
index
)
:
this
.
onTtsStart
(
index
)
},
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
)
{
const
{
...
...
packageEquity/pages/aiCheck/components/AudioTts/AudioTts.wxml
View file @
762d8e7
...
...
@@ -73,19 +73,19 @@
<view class="chat-aspect">
<view class="aspect-item">
<view class="aspect-name">语速</view>
<view class="aspect-result">{{item.
Sentences_desc[0]
}}</view>
<view class="aspect-result">{{item.
speed
}}</view>
</view>
<view class="aspect-item">
<view class="aspect-name">语调</view>
<view class="aspect-result">{{item.
Sentences_desc[1]
}}</view>
<view class="aspect-result">{{item.
intonation
}}</view>
</view>
<view class="aspect-item">
<view class="aspect-name">清晰度</view>
<view class="aspect-result">{{item.
Sentences_desc[2]
}}</view>
<view class="aspect-result">{{item.
definition
}}</view>
</view>
<view class="aspect-item">
<view class="aspect-name">冗余词</view>
<view class="aspect-result">{{item.
Sentences_desc[3]
}}</view>
<view class="aspect-result">{{item.
redundant
}}</view>
</view>
</view>
<view class="suggest">
...
...
packageEquity/pages/aiCheck/result/result.js
View file @
762d8e7
...
...
@@ -184,25 +184,37 @@ Page({
uuid
}
=
wx
.
$util
.
getUserInfo
();
console
.
log
(
history_message
);
if
(
id
)
{
this
.
setData
({
duration
:
false
})
this
.
getDetail
(
id
);
this
.
getChatDetail
({
staffRecordId
:
uuid
})
this
.
getChatDetail
({
staffRecordId
:
uuid
})
}
else
{
const
chatList
=
JSON
.
parse
(
wx
.
getStorageSync
(
"chatList"
));
this
.
setData
({
chatList
})
this
.
handleSave
(
chatList
,
duration
)
this
.
setData
({
chatList
})
this
.
handleSave
(
chatList
,
duration
)
}
console
.
log
(
windowW
);
},
getChatDetail
(
staffRecordId
)
{
carLifeApi
.
getSparringDetail
({
staffRecordId
,
pageNum
:
1
,
pageSize
:
100
}).
then
(
res
=>
{
const
{
list
=
[]
}
=
res
.
data
this
.
setData
({
chatList
:
list
})
carLifeApi
.
getSparringDetail
({
staffRecordId
,
pageNum
:
1
,
pageSize
:
100
}).
then
(
res
=>
{
const
{
list
=
[]
}
=
res
.
data
this
.
setData
({
chatList
:
list
})
})
},
//提交数据
...
...
@@ -306,7 +318,7 @@ Page({
return
{
...
desc
,
...
selectedXYItem
,
className
:
'move-circle'
className
:
'move-circle'
};
})
this
.
setData
({
...
...
@@ -315,70 +327,88 @@ Page({
},
500
)
});
},
convertSecondsToMinutesAndSeconds
(
seconds
,
isSymbol
)
{
convertSecondsToMinutesAndSeconds
(
seconds
,
isSymbol
)
{
var
minutes
=
Math
.
floor
(
seconds
/
60
);
// 计算分钟数
var
remainingSeconds
=
seconds
%
60
;
// 计算剩余的秒数
// 如果剩余的秒数小于10,则前面添加0以保持格式一致
if
(
remainingSeconds
<
10
)
{
remainingSeconds
=
'0'
+
remainingSeconds
;
}
let
res
=
minutes
+
'分'
+
remainingSeconds
+
'秒'
;
if
(
isSymbol
)
{
let
res
=
minutes
+
'分'
+
remainingSeconds
+
'秒'
;
if
(
isSymbol
)
{
res
=
minutes
+
':'
+
remainingSeconds
;
}
return
res
},
getSentencesDetail
(
Sentences
,
totalTime
,
redundantWord
)
{
getSentencesDetail
(
Sentences
,
totalTime
,
redundantWord
)
{
let
totalSpeed
=
0
;
let
totalEmotionValue
=
0
;
const
axisX
=
[];
const
axisY_SpeechRate
=
[];
const
axisY_EmotionValue
=
[];
Sentences
.
forEach
((
i
,
k
)
=>
{
totalSpeed
+=
i
.
SpeechRate
;
totalEmotionValue
+=
i
.
EmotionValue
;
if
(
k
==
0
)
{
axisX
.
push
(
'0:00'
)
}
else
if
(
k
==
Sentences
.
length
-
1
)
{
axisX
.
push
(
this
.
convertSecondsToMinutesAndSeconds
(
totalTime
,
true
))
}
else
{
axisX
.
push
(
k
)
if
(
Sentences
.
length
>
2
)
{
Sentences
.
forEach
((
i
,
k
)
=>
{
totalSpeed
+=
i
.
SpeechRate
;
totalEmotionValue
+=
i
.
EmotionValue
;
if
(
k
==
0
)
{
axisX
.
push
(
'0:00'
)
}
else
if
(
k
==
Sentences
.
length
-
1
)
{
axisX
.
push
(
this
.
convertSecondsToMinutesAndSeconds
(
totalTime
,
true
))
}
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
)
axisY_EmotionValue
.
push
(
i
.
EmotionValue
)
})
}
else
{
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
averageEmotionValue
=
totalEmotionValue
/
Sentences
.
length
const
speechSpeed
=
{
star
:
calculateStars
(
averageSpeed
),
x
:
axisX
,
star
:
calculateStars
(
averageSpeed
),
x
:
axisX
,
y
:
axisY_SpeechRate
,
min
:
speechSpeed_MIN
,
max
:
speechSpeed_MAX
min
:
speechSpeed_MIN
,
max
:
speechSpeed_MAX
}
const
definition
=
{
x
:
axisX
,
y
:
axisY_EmotionValue
,
star
:
calculateEmotion
(
averageEmotionValue
,
true
),
min
:
Emotion_MIN
,
max
:
Emotion_MAX
x
:
axisX
,
y
:
axisY_EmotionValue
,
star
:
calculateEmotion
(
averageEmotionValue
,
true
),
min
:
Emotion_MIN
,
max
:
Emotion_MAX
}
const
axisY_Intonation
=
axisY_SpeechRate
.
map
((
currentValue
,
index
)
=>
{
if
(
index
<
axisY_SpeechRate
.
length
-
1
)
{
return
axisY_SpeechRate
[
index
+
1
]
-
currentValue
+
1
;
}
else
{
}
else
{
return
1
}
});
const
intonation
=
{
x
:
axisX
,
y
:
axisY_Intonation
,
star
:
calculateIntonation
(
axisY_SpeechRate
,
true
),
min
:
Emotion_MIN
,
max
:
Emotion_MAX
x
:
axisX
,
y
:
axisY_Intonation
,
star
:
calculateIntonation
(
axisY_EmotionValue
,
true
),
min
:
Emotion_MIN
,
max
:
Emotion_MAX
}
const
redundantWords
=
this
.
getWord
(
redundantWord
)
return
{
speechSpeed
,
redundantWords
,
definition
,
intonation
}
return
{
speechSpeed
,
redundantWords
,
definition
,
intonation
}
},
getWord
(
words
)
{
const
sentences
=
words
.
split
(
/
[
,。,
]
/
);
...
...
@@ -395,22 +425,30 @@ Page({
if
(
star
<
1
)
{
star
=
1
}
const
content
=
filteredSentences
.
join
(
","
);
return
{
star
,
content
}
const
content
=
filteredSentences
.
join
(
","
);
return
{
star
,
content
}
},
handleSave
(
list
,
sparringDuration
)
{
console
.
log
(
list
)
let
totalTime
=
0
;
let
Sentences
=
[];
let
content
;
list
.
forEach
(
i
=>
{
if
(
i
.
role
==
2
)
{
list
.
forEach
(
i
=>
{
if
(
i
.
role
==
2
)
{
totalTime
+=
i
.
times
content
+=
i
.
content
Sentences
=
[...
Sentences
,...
i
.
Sentences
]
content
+=
i
.
content
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
{
sparringTaskId
,
roleType
,
...
...
@@ -437,6 +475,10 @@ Page({
voiceUrl
,
times
:
voiceDuration
,
spkTime
,
speed
,
intonation
,
definition
,
redundant
}
=
i
;
return
{
sparringLink
,
...
...
@@ -447,6 +489,10 @@ Page({
improve
,
polish
,
spkTime
,
speed
,
intonation
,
definition
,
redundant
};
});
carLifeApi
.
sparringCommit
({
...
...
@@ -458,7 +504,7 @@ Page({
fluency
,
deliver
,
details
:
JSON
.
stringify
(
details
),
}).
then
(
res
=>
{
}).
then
(
res
=>
{
this
.
getDetail
(
res
.
data
.
sparringRecordId
)
});
},
...
...
@@ -477,7 +523,7 @@ Page({
name
:
"评分"
,
data
,
alpha
:
0.2
,
lineColor
:
'#4864FF'
,
lineColor
:
'#4864FF'
,
eachSeries
:
{
color
:
"#3989FE"
,
},
...
...
@@ -493,7 +539,7 @@ Page({
},
},
{
dataPointShape
:
[
"circle"
],
drawLine
:
true
drawLine
:
true
});
},
jump
(
e
)
{
...
...
packageEquity/pages/aiCheck/start/components/introduction/introduction.js
View file @
762d8e7
...
...
@@ -81,11 +81,9 @@ Component({
yqMerchantId
:
merchantId
})
this
.
setData
({
isVisible
:
!
res
.
data
.
sparringAllow
})
if
(
res
.
data
.
sparringAllow
)
{
wx
.
navigateTo
({
url
:
`/packageEquity/pages/aiCheck/scene/scene?id=
${
id
}
`
})
}
},
}
})
\ No newline at end of file
packageEquity/pages/aiCheck/upload/uploadFile.js
View file @
762d8e7
...
...
@@ -2,11 +2,6 @@ import config from './config'
export
default
function
(
filePath
,
options
)
{
return
new
Promise
(
async
(
resolve
,
reject
)
=>
{
if
(
!
filePath
||
filePath
.
length
<
9
)
{
uni
.
showModal
({
title
:
"文件错误"
,
content
:
"请重试"
,
showCancel
:
false
,
});
reject
(
"文件错误"
);
}
// 获取上传的文件类型
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment