|
@@ -1632,6 +1632,8 @@ ${JSON.stringify(_list)}
|
|
|
let _getRoleList = [];
|
|
|
let _roleList = {};
|
|
|
let _getRoleLoading = false;
|
|
|
+ let _getBehavioralCodingLoading = false;
|
|
|
+ let _behavioralCodingList = [];
|
|
|
try {
|
|
|
let iiframe = this.$refs["iiframe"];
|
|
|
let _this = this;
|
|
@@ -1678,14 +1680,9 @@ ${JSON.stringify(_list)}
|
|
|
let privSpeakerId = e.privSpeakerId;
|
|
|
let privDuration = e.privDuration;
|
|
|
let privOffset = e.privOffset;
|
|
|
- console.log("👇转译对象👇");
|
|
|
- console.log(e);
|
|
|
- console.log("👇转译结果👇");
|
|
|
- console.log(privText);
|
|
|
- console.log(privSpeakerId);
|
|
|
- if (!privText || !privSpeakerId || privSpeakerId=='Unknown') {
|
|
|
- console.log(privText, privSpeakerId);
|
|
|
- console.log(!privText || !privSpeakerId);
|
|
|
+ console.log("👉转译对象👉", e);
|
|
|
+ console.log("👉转译结果👉", privText);
|
|
|
+ if (!privText || !privSpeakerId || privSpeakerId == "Unknown") {
|
|
|
return;
|
|
|
}
|
|
|
|
|
@@ -1698,8 +1695,17 @@ ${JSON.stringify(_list)}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- console.log("roleList",_roleList);
|
|
|
- console.log("getRoleList",_getRoleList)
|
|
|
+ _behavioralCodingList.push({
|
|
|
+ index:textList.length,
|
|
|
+ role:privSpeakerId,
|
|
|
+ content:privText,
|
|
|
+ code:"",
|
|
|
+ })
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ console.log("roleList", _roleList);
|
|
|
+ console.log("getRoleList", _getRoleList);
|
|
|
if (_getRoleList.length >= 10 && !_getRoleLoading) {
|
|
|
try {
|
|
|
let params = {
|
|
@@ -1715,8 +1721,8 @@ ${JSON.stringify(_list)}
|
|
|
user: _this.userId
|
|
|
};
|
|
|
_getRoleLoading = true;
|
|
|
- _this.ajax
|
|
|
- .post("https://dify.cocorobo.cn/v1/workflows/run?key=role", params)
|
|
|
+ _this
|
|
|
+ .getWavRoleList(params)
|
|
|
.then(res => {
|
|
|
let _runData = res.data.data;
|
|
|
let _runResult = _runData.outputs.result;
|
|
@@ -1724,40 +1730,50 @@ ${JSON.stringify(_list)}
|
|
|
|
|
|
_runResult.forEach((txt, index) => {
|
|
|
let _oldRole = _getRoleList[index].role;
|
|
|
- if(_numRole.map(i=>i.role).includes(_oldRole)){
|
|
|
- let _findIndex = _numRole.findIndex(i=>i.role==_oldRole);
|
|
|
- if(txt=="学生"){
|
|
|
- _numRole[_findIndex].s+=1;
|
|
|
- }else if(txt=="老师"){
|
|
|
- _numRole[_findIndex].t+=1;
|
|
|
+ if (_numRole.map(i => i.role).includes(_oldRole)) {
|
|
|
+ let _findIndex = _numRole.findIndex(
|
|
|
+ i => i.role == _oldRole
|
|
|
+ );
|
|
|
+ if (txt == "学生") {
|
|
|
+ _numRole[_findIndex].s += 1;
|
|
|
+ } else if (txt == "老师") {
|
|
|
+ _numRole[_findIndex].t += 1;
|
|
|
}
|
|
|
- }else{
|
|
|
- if(txt=="学生"){
|
|
|
- _numRole.push({role:_oldRole,t:0,s:1});
|
|
|
- }else if(txt=="老师"){
|
|
|
- _numRole.push({role:_oldRole,t:1,s:0});
|
|
|
+ } else {
|
|
|
+ if (txt == "学生") {
|
|
|
+ _numRole.push({ role: _oldRole, t: 0, s: 1 });
|
|
|
+ } else if (txt == "老师") {
|
|
|
+ _numRole.push({ role: _oldRole, t: 1, s: 0 });
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
|
|
|
//根据数量判断是老师还是学生
|
|
|
- _numRole.forEach(i=>{
|
|
|
- if(i.t > i.s){
|
|
|
+ _numRole.forEach(i => {
|
|
|
+ if (i.t > i.s) {
|
|
|
_roleList[i.role] = "老师";
|
|
|
- }else if(i.t < i.s){
|
|
|
+ } else if (i.t < i.s) {
|
|
|
_roleList[i.role] = "学生";
|
|
|
}
|
|
|
- })
|
|
|
+ });
|
|
|
//已经有的role
|
|
|
let roleKeys = Object.keys(_roleList);
|
|
|
|
|
|
- textList.forEach(i=>{
|
|
|
+ textList.forEach(i => {
|
|
|
+ if (roleKeys.includes(i.role)) {
|
|
|
+ i.role = _roleList[i.role];
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ _behavioralCodingList.forEach(i=>{
|
|
|
if(roleKeys.includes(i.role)){
|
|
|
- i.role = _roleList[i.role]
|
|
|
+ i.code = _roleList[i.role];
|
|
|
}
|
|
|
})
|
|
|
|
|
|
- _getRoleList = _getRoleList.filter(i=>!roleKeys.includes(i.role))
|
|
|
+ _getRoleList = _getRoleList.filter(
|
|
|
+ i => !roleKeys.includes(i.role)
|
|
|
+ );
|
|
|
_getRoleLoading = false;
|
|
|
})
|
|
|
.catch(err => {
|
|
@@ -1769,13 +1785,55 @@ ${JSON.stringify(_list)}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ if(_behavioralCodingList.filter(i=> !i.role.includes("Guest") && i.code=="").length>10 && !_getBehavioralCodingLoading){
|
|
|
+ try {
|
|
|
+ let _behavioralCodingListTemp = _behavioralCodingList.filter(i=> !i.role.includes("Guest") && i.code=="").slice(0, 10);
|
|
|
+ let params = {
|
|
|
+ inputs:{
|
|
|
+ rows:JSON.stringify(_behavioralCodingListTemp.map(i=>{
|
|
|
+ return {content:i.content,role:i.role}
|
|
|
+ })),
|
|
|
+ options:"老师讲课,老师提问或点名,老师板书或操作,老师评价或反馈,老师其他,学生发言,学生小组活动,学生自主学习,学生汇报分享,学生其他",
|
|
|
+ attention:"- 先根据说话人角色判断,再在对应角色的选项中选择选项\n- 如果没有合适的选项,默认使用`老师其他`或者`学生其他`"
|
|
|
+ },
|
|
|
+ response_mode:"blocking",
|
|
|
+ user:_this.userId
|
|
|
+ }
|
|
|
+
|
|
|
+ _getBehavioralCodingLoading = true;
|
|
|
+ _this.getBehavioralCoding(params)
|
|
|
+ .then(res=>{
|
|
|
+ let _runData = res.data.data;
|
|
|
+ let _runResult = _runData.outputs.result;
|
|
|
+ _behavioralCodingListTemp.forEach((i,index)=>{
|
|
|
+ _behavioralCodingList.find(i2=>i2.index == i.index).code = _runResult[index];
|
|
|
+ })
|
|
|
+
|
|
|
+ _behavioralCodingList.forEach(i=>{
|
|
|
+ if(textList[i.index].code == ""){
|
|
|
+ textList[i.index].code = i.code;
|
|
|
+ }
|
|
|
+ })
|
|
|
+ _getBehavioralCodingLoading = false;
|
|
|
+ })
|
|
|
+ .catch(err=>{
|
|
|
+ console.log("获取行为编码错误",err)
|
|
|
+ _getBehavioralCodingLoading = false;
|
|
|
+ })
|
|
|
+ } catch (error) {
|
|
|
+ console.log("获取行为编码错误",error)
|
|
|
+ _getBehavioralCodingLoading = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
_endTime = (privOffset + privDuration) / 10000000;
|
|
|
textList.push({
|
|
|
value: privText,
|
|
|
startTime: _this.updateRecordedTime({ duration: _startTime }),
|
|
|
endTime: _this.updateRecordedTime({ duration: _endTime }),
|
|
|
time: _this.updateRecordedTime({ duration: _endTime - _startTime }),
|
|
|
- role: privSpeakerId
|
|
|
+ role: privSpeakerId,
|
|
|
+ code:"",
|
|
|
});
|
|
|
|
|
|
_startTime = _endTime;
|
|
@@ -1811,7 +1869,7 @@ ${JSON.stringify(_list)}
|
|
|
<td>${item.value}</td>
|
|
|
<td>${item.time}</td>
|
|
|
<td>${item.role}</td>
|
|
|
- <td></td>
|
|
|
+ <td>${item.code}</td>
|
|
|
</tr>`;
|
|
|
});
|
|
|
_result += `
|
|
@@ -1831,7 +1889,114 @@ ${JSON.stringify(_list)}
|
|
|
// _this.editorBarData.content += privText;
|
|
|
};
|
|
|
|
|
|
- iiframe.contentWindow.onSessionStopped = function(e) {
|
|
|
+ iiframe.contentWindow.onSessionStopped = async function(e) {
|
|
|
+ if (_getRoleList.length > 0) {
|
|
|
+ await _this
|
|
|
+ .getWavRoleList({
|
|
|
+ inputs: {
|
|
|
+ options: "老师,学生",
|
|
|
+ rows: JSON.stringify(
|
|
|
+ _getRoleList.map(i => {
|
|
|
+ return { content: i.content, role: i.role };
|
|
|
+ })
|
|
|
+ )
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .then(res => {
|
|
|
+ let _runData = res.data.data;
|
|
|
+ let _runResult = _runData.outputs.result;
|
|
|
+ let _numRole = [];
|
|
|
+
|
|
|
+ _runResult.forEach((txt, index) => {
|
|
|
+ let _oldRole = _getRoleList[index].role;
|
|
|
+ if (_numRole.map(i => i.role).includes(_oldRole)) {
|
|
|
+ let _findIndex = _numRole.findIndex(
|
|
|
+ i => i.role == _oldRole
|
|
|
+ );
|
|
|
+ if (txt == "学生") {
|
|
|
+ _numRole[_findIndex].s += 1;
|
|
|
+ } else if (txt == "老师") {
|
|
|
+ _numRole[_findIndex].t += 1;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (txt == "学生") {
|
|
|
+ _numRole.push({ role: _oldRole, t: 0, s: 1 });
|
|
|
+ } else if (txt == "老师") {
|
|
|
+ _numRole.push({ role: _oldRole, t: 1, s: 0 });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ //根据数量判断是老师还是学生
|
|
|
+ _numRole.forEach(i => {
|
|
|
+ if (i.t > i.s) {
|
|
|
+ _roleList[i.role] = "老师";
|
|
|
+ } else if (i.t < i.s) {
|
|
|
+ _roleList[i.role] = "学生";
|
|
|
+ }
|
|
|
+ });
|
|
|
+ //已经有的role
|
|
|
+ let roleKeys = Object.keys(_roleList);
|
|
|
+
|
|
|
+ textList.forEach(i => {
|
|
|
+ if (roleKeys.includes(i.role)) {
|
|
|
+ i.role = _roleList[i.role];
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ _getRoleList = _getRoleList.filter(
|
|
|
+ i => !roleKeys.includes(i.role)
|
|
|
+ );
|
|
|
+ _getRoleLoading = false;
|
|
|
+
|
|
|
+ let _result = `
|
|
|
+ <table
|
|
|
+ border="0"
|
|
|
+ width="100%"
|
|
|
+ cellpadding="0"
|
|
|
+ cellspacing="0"
|
|
|
+ style="text-align: center"
|
|
|
+ >
|
|
|
+ <tbody>
|
|
|
+ <tr>
|
|
|
+ <th>序号</th>
|
|
|
+ <th>开始时间</th>
|
|
|
+ <th>结束时间</th>
|
|
|
+ <th>发言内容</th>
|
|
|
+ <th>时长</th>
|
|
|
+ <th>说话人身份</th>
|
|
|
+ <th>行为编码</th>
|
|
|
+ </tr>
|
|
|
+ `;
|
|
|
+ textList.forEach((item, index) => {
|
|
|
+ _result += `<tr>
|
|
|
+ <td>${index + 1}</td>
|
|
|
+ <td>${item.startTime}</td>
|
|
|
+ <td>${item.endTime}</td>
|
|
|
+ <td>${item.value}</td>
|
|
|
+ <td>${item.time}</td>
|
|
|
+ <td>${item.role}</td>
|
|
|
+ <td></td>
|
|
|
+ </tr>`;
|
|
|
+ });
|
|
|
+ _result += `
|
|
|
+ <tr>
|
|
|
+ <td></td>
|
|
|
+ <td></td>
|
|
|
+ <td></td>
|
|
|
+ <td></td>
|
|
|
+ <td></td>
|
|
|
+ <td></td>
|
|
|
+ <td></td>
|
|
|
+ </tr>
|
|
|
+ </tbody>
|
|
|
+ </table>`;
|
|
|
+ _this.editorBarData.content = _result;
|
|
|
+ })
|
|
|
+ .catch(err => {
|
|
|
+ console.log("最后的获取说话人身份失败", err);
|
|
|
+ });
|
|
|
+ }
|
|
|
_this.wavGetTextProgress = 100;
|
|
|
if (_this.wavFileGetTextLoading) _this.$message.success("转译完成");
|
|
|
_this.showGetTextLoading = false;
|
|
@@ -1848,6 +2013,30 @@ ${JSON.stringify(_list)}
|
|
|
this.showGetTextLoading = false;
|
|
|
}
|
|
|
},
|
|
|
+
|
|
|
+ getWavRoleList(params) {
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
+ this.ajax
|
|
|
+ .post("https://dify.cocorobo.cn/v1/workflows/run?key=role", params)
|
|
|
+ .then(res => {
|
|
|
+ resolve(res);
|
|
|
+ })
|
|
|
+ .catch(err => {
|
|
|
+ reject(err);
|
|
|
+ });
|
|
|
+ });
|
|
|
+ },
|
|
|
+ getBehavioralCoding(params){
|
|
|
+ return new Promise((resolve,reject)=>{
|
|
|
+ this.ajax.post("https://dify.cocorobo.cn/v1/workflows/run?key=code",params)
|
|
|
+ .then(res=>{
|
|
|
+ resolve(res)
|
|
|
+ })
|
|
|
+ .catch(err=>{
|
|
|
+ reject(err)
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
stopWavGetText() {
|
|
|
if (this.wavGetTextLoading) {
|
|
|
try {
|