|
@@ -1,5 +1,5 @@
|
|
|
<template>
|
|
|
- <div class="chatArea" v-loading="loading">
|
|
|
+ <div class="chatArea">
|
|
|
<div class="m-operation">
|
|
|
<div>实时转录</div>
|
|
|
<div>{{ createTime }}</div>
|
|
@@ -64,9 +64,17 @@
|
|
|
v-if="pageStatus == 2 && !showIndexPage && editorBarData.type == '0'"
|
|
|
v-loading="uploadFileLoading"
|
|
|
>
|
|
|
- <div class="wavGetTextProgress" v-if="wavGetTextLoading" style="position: absolute; bottom: 20px; right: 285px; z-index: 10002">
|
|
|
- <el-progress :text-inside="true" :stroke-width="26" :percentage="wavGetTextProgress"></el-progress>
|
|
|
- </div>
|
|
|
+ <div
|
|
|
+ class="wavGetTextProgress"
|
|
|
+ v-if="wavGetTextLoading"
|
|
|
+ style="position: absolute; bottom: 20px; right: 285px; z-index: 10002"
|
|
|
+ >
|
|
|
+ <el-progress
|
|
|
+ :text-inside="true"
|
|
|
+ :stroke-width="26"
|
|
|
+ :percentage="wavGetTextProgress"
|
|
|
+ ></el-progress>
|
|
|
+ </div>
|
|
|
<el-button
|
|
|
style="position: absolute; bottom: 20px; right: 185px; z-index: 10002"
|
|
|
size="small"
|
|
@@ -75,6 +83,32 @@
|
|
|
@click.stop="stopWavGetText()"
|
|
|
>终止转译</el-button
|
|
|
>
|
|
|
+ <el-popover placement="top" trigger="click" v-if="!wavGetTextLoading">
|
|
|
+ <div style="display: flex;">
|
|
|
+ <el-input
|
|
|
+ size="small"
|
|
|
+ style="width: 150px;margin-right: 10px;"
|
|
|
+ v-model="replace1"
|
|
|
+ placeholder="替换之前的文字"
|
|
|
+ ></el-input>
|
|
|
+ <el-input
|
|
|
+ size="small"
|
|
|
+ style="width: 150px;margin-right: 10px;"
|
|
|
+ v-model="replace2"
|
|
|
+ placeholder="替换之后的文字"
|
|
|
+ ></el-input>
|
|
|
+ <el-button type="primary" size="small" @click="replaceText()"
|
|
|
+ >替换</el-button
|
|
|
+ >
|
|
|
+ </div>
|
|
|
+ <el-button
|
|
|
+ slot="reference"
|
|
|
+ style="position: absolute; bottom: 20px; right: 185px; z-index: 10002"
|
|
|
+ size="small"
|
|
|
+ type="primary"
|
|
|
+ >文字替换</el-button
|
|
|
+ >
|
|
|
+ </el-popover>
|
|
|
<el-popover placement="top" trigger="hover">
|
|
|
<el-button size="small" @click.stop="startContinuousJobs('role')">
|
|
|
说话人编码
|
|
@@ -761,13 +795,15 @@ export default {
|
|
|
showTeacherVoiceprintBox: false,
|
|
|
teacherVoiceprintList: [],
|
|
|
chosenVoiceprint: [],
|
|
|
- recorderProvider: "shengyang",
|
|
|
+ recorderProvider: "microsoft",
|
|
|
shengyangContext: {
|
|
|
recorder: null,
|
|
|
ws: null
|
|
|
},
|
|
|
userName: "",
|
|
|
- curRequestController:null,
|
|
|
+ curRequestController: null,
|
|
|
+ replace1: "", //替换1
|
|
|
+ replace2: "" //替换2
|
|
|
};
|
|
|
},
|
|
|
computed: {
|
|
@@ -986,44 +1022,50 @@ export default {
|
|
|
};
|
|
|
|
|
|
let _addText = "";
|
|
|
- const md = new MarkdownIt();
|
|
|
- let _this = this;
|
|
|
- // const curRequestController = new AbortController();
|
|
|
- this.curRequestController = new AbortController();
|
|
|
-
|
|
|
- fetchEventSource("https://gpt4.cocorobo.cn/ai_agent_park_chat_new_post_stream",{
|
|
|
- method: "POST",
|
|
|
- headers: {
|
|
|
- "Content-Type": "application/json"
|
|
|
- },
|
|
|
- body: JSON.stringify(params),
|
|
|
- signal: _this.curRequestController.signal,
|
|
|
- onmessage(ev){
|
|
|
- console.log(ev)
|
|
|
- if(ev.data=="")return
|
|
|
- let _data = JSON.parse(ev.data);
|
|
|
- if(_data.content=='[DONE]')return;
|
|
|
- _addText+=_data.content;
|
|
|
- _this.chatList.find(i => i.uid == _uid).aiContent = md.render(_addText);
|
|
|
- _this.chatList.find(i => i.uid == _uid).loading = false;
|
|
|
- _this.scrollBottom();
|
|
|
- console.log(_data)
|
|
|
- },
|
|
|
- onclose(){
|
|
|
- _this.$forceUpdate();
|
|
|
- // _this.stopTalkToken = null;
|
|
|
- // _this.faloading = false;
|
|
|
- _this.curRequestController = null;
|
|
|
- _this.chatList.find(i => i.uid == _uid).isalltext = true;
|
|
|
- _this.chatList.find(i => i.uid == _uid).isShowSynchronization = true;
|
|
|
- _this.insertChat(_uid);
|
|
|
- console.log("连接关闭")
|
|
|
- },
|
|
|
- onerror(err){
|
|
|
-
|
|
|
- console.log("连接错误",err)
|
|
|
- }
|
|
|
- })
|
|
|
+ const md = new MarkdownIt();
|
|
|
+ let _this = this;
|
|
|
+ // const curRequestController = new AbortController();
|
|
|
+ this.curRequestController = new AbortController();
|
|
|
+
|
|
|
+ fetchEventSource(
|
|
|
+ "https://gpt4.cocorobo.cn/ai_agent_park_chat_new_post_stream",
|
|
|
+ {
|
|
|
+ method: "POST",
|
|
|
+ headers: {
|
|
|
+ "Content-Type": "application/json"
|
|
|
+ },
|
|
|
+ body: JSON.stringify(params),
|
|
|
+ signal: _this.curRequestController.signal,
|
|
|
+ onmessage(ev) {
|
|
|
+ console.log(ev);
|
|
|
+ if (ev.data == "") return;
|
|
|
+ let _data = JSON.parse(ev.data);
|
|
|
+ if (_data.content == "[DONE]") return;
|
|
|
+ _addText += _data.content;
|
|
|
+ _this.chatList.find(i => i.uid == _uid).aiContent = md.render(
|
|
|
+ _addText
|
|
|
+ );
|
|
|
+ _this.chatList.find(i => i.uid == _uid).loading = false;
|
|
|
+ _this.scrollBottom();
|
|
|
+ console.log(_data);
|
|
|
+ },
|
|
|
+ onclose() {
|
|
|
+ _this.$forceUpdate();
|
|
|
+ // _this.stopTalkToken = null;
|
|
|
+ // _this.faloading = false;
|
|
|
+ _this.curRequestController = null;
|
|
|
+ _this.chatList.find(i => i.uid == _uid).isalltext = true;
|
|
|
+ _this.chatList.find(
|
|
|
+ i => i.uid == _uid
|
|
|
+ ).isShowSynchronization = true;
|
|
|
+ _this.insertChat(_uid);
|
|
|
+ console.log("连接关闭");
|
|
|
+ },
|
|
|
+ onerror(err) {
|
|
|
+ console.log("连接错误", err);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ );
|
|
|
// this.ajax
|
|
|
// .post("https://gpt4.cocorobo.cn/ai_agent_park_chat_new", params)
|
|
|
// .then(res => {
|
|
@@ -1080,7 +1122,7 @@ export default {
|
|
|
messages: _historyMessage,
|
|
|
uid: _uuid,
|
|
|
mind_map_question: "",
|
|
|
- stream:true
|
|
|
+ stream: true
|
|
|
};
|
|
|
// let params = JSON.stringify({
|
|
|
// message: {
|
|
@@ -1094,44 +1136,46 @@ export default {
|
|
|
// model: "Claude 3 Sonnet", // Claude 3 Sonnet或者Claude 3 Haiku
|
|
|
// });
|
|
|
|
|
|
-
|
|
|
let _addText = "";
|
|
|
const md = new MarkdownIt();
|
|
|
let _this = this;
|
|
|
- this.curRequestController = new AbortController();
|
|
|
+ this.curRequestController = new AbortController();
|
|
|
|
|
|
- fetchEventSource("https://gpt4.cocorobo.cn/chat_post_stream",{
|
|
|
+ fetchEventSource("https://gpt4.cocorobo.cn/chat_post_stream", {
|
|
|
method: "POST",
|
|
|
headers: {
|
|
|
"Content-Type": "application/json"
|
|
|
},
|
|
|
body: JSON.stringify(params),
|
|
|
signal: _this.curRequestController.signal,
|
|
|
- onmessage(ev){
|
|
|
- console.log(ev)
|
|
|
+ onmessage(ev) {
|
|
|
+ console.log(ev);
|
|
|
let _data = ev.data;
|
|
|
- if(_data=='[DONE]')return;
|
|
|
- _addText+=_data;
|
|
|
- _this.chatList.find(i => i.uid == _uuid).aiContent = md.render(_addText);
|
|
|
+ if (_data == "[DONE]") return;
|
|
|
+ _addText += _data;
|
|
|
+ _this.chatList.find(i => i.uid == _uuid).aiContent = md.render(
|
|
|
+ _addText
|
|
|
+ );
|
|
|
_this.chatList.find(i => i.uid == _uuid).loading = false;
|
|
|
_this.scrollBottom();
|
|
|
- console.log(_data)
|
|
|
+ console.log(_data);
|
|
|
},
|
|
|
- onclose(){
|
|
|
+ onclose() {
|
|
|
_this.$forceUpdate();
|
|
|
// _this.stopTalkToken = null;
|
|
|
// _this.faloading = false;
|
|
|
_this.curRequestController = null;
|
|
|
_this.chatList.find(i => i.uid == _uuid).isalltext = true;
|
|
|
- _this.chatList.find(i => i.uid == _uuid).isShowSynchronization = true;
|
|
|
+ _this.chatList.find(
|
|
|
+ i => i.uid == _uuid
|
|
|
+ ).isShowSynchronization = true;
|
|
|
_this.insertChat(_uuid);
|
|
|
- console.log("连接关闭")
|
|
|
+ console.log("连接关闭");
|
|
|
},
|
|
|
- onerror(err){
|
|
|
-
|
|
|
- console.log("连接错误",err)
|
|
|
+ onerror(err) {
|
|
|
+ console.log("连接错误", err);
|
|
|
}
|
|
|
- })
|
|
|
+ });
|
|
|
|
|
|
// this.ajax
|
|
|
// .post("https://gpt4.cocorobo.cn/chat", params)
|
|
@@ -1558,10 +1602,10 @@ ${JSON.stringify(_list)}
|
|
|
// return new Blob(buffer, { type: "audio/mp3" });
|
|
|
// },
|
|
|
async wavFileGetText(audioFile) {
|
|
|
- this.wavGetTextProgress = 0;
|
|
|
- let _TimeProgress = 6000;//六秒
|
|
|
- let _totalTime = 0;
|
|
|
- let _duration = 0;
|
|
|
+ this.wavGetTextProgress = 0;
|
|
|
+ let _TimeProgress = 6000; //六秒
|
|
|
+ let _totalTime = 0;
|
|
|
+ let _duration = 0;
|
|
|
let flag = true;
|
|
|
let textList = [];
|
|
|
let _file = null;
|
|
@@ -1577,16 +1621,22 @@ ${JSON.stringify(_list)}
|
|
|
console.log("将转录的文件👇");
|
|
|
console.log(_file);
|
|
|
|
|
|
- const audio = new Audio(URL.createObjectURL(_file));
|
|
|
- audio.addEventListener("canplaythrough",()=>{
|
|
|
- _duration = (audio.duration * 1000).toFixed(0);
|
|
|
- console.log("音频时长",_duration)
|
|
|
- })
|
|
|
-
|
|
|
+ const audio = new Audio(URL.createObjectURL(_file));
|
|
|
+ audio.addEventListener("canplaythrough", () => {
|
|
|
+ _duration = (audio.duration * 1000).toFixed(0);
|
|
|
+ console.log("音频时长", _duration);
|
|
|
+ });
|
|
|
|
|
|
+ let _startTime = 0;
|
|
|
+ let _endTime = 0;
|
|
|
+ let _getRoleList = [];
|
|
|
+ let _roleList = {};
|
|
|
+ let _getRoleLoading = false;
|
|
|
+ let _getBehavioralCodingLoading = false;
|
|
|
+ let _behavioralCodingList = [];
|
|
|
try {
|
|
|
- let iiframe = this.$refs["iiframe"];
|
|
|
- let _this = this;
|
|
|
+ let iiframe = this.$refs["iiframe"];
|
|
|
+ let _this = this;
|
|
|
this.wavGetTextLoading = true;
|
|
|
iiframe.contentWindow.window.document.getElementById(
|
|
|
"languageOptions"
|
|
@@ -1606,38 +1656,204 @@ ${JSON.stringify(_list)}
|
|
|
_this.editorBarData.content = "";
|
|
|
textList = [];
|
|
|
}
|
|
|
- if(_this.wavGetTextProgress<=70){
|
|
|
- _TimeProgress = 6000;//六秒
|
|
|
- }else if(_this.wavGetTextProgress<=80){
|
|
|
- _TimeProgress = 4000;//改为三秒
|
|
|
- }else if(_this.wavGetTextProgress<=90){
|
|
|
- _TimeProgress = 2000;//改为一秒
|
|
|
- }else if(_this.wavGetTextProgress<95){
|
|
|
- _TimeProgress = 1000;//改为0.5秒
|
|
|
- }else if(_this.wavGetTextProgress<99){
|
|
|
- _TimeProgress = 500;//改为0.1秒
|
|
|
- }else{
|
|
|
- _TimeProgress = 0;//改为0秒不动
|
|
|
- }
|
|
|
-
|
|
|
- _totalTime+=_TimeProgress;
|
|
|
- _this.wavGetTextProgress = (_totalTime/_duration*100).toFixed(0);
|
|
|
+ if (_this.wavGetTextProgress <= 70) {
|
|
|
+ _TimeProgress = 6000; //六秒
|
|
|
+ } else if (_this.wavGetTextProgress <= 80) {
|
|
|
+ _TimeProgress = 4000; //改为三秒
|
|
|
+ } else if (_this.wavGetTextProgress <= 90) {
|
|
|
+ _TimeProgress = 2000; //改为一秒
|
|
|
+ } else if (_this.wavGetTextProgress < 95) {
|
|
|
+ _TimeProgress = 1000; //改为0.5秒
|
|
|
+ } else if (_this.wavGetTextProgress < 99) {
|
|
|
+ _TimeProgress = 500; //改为0.1秒
|
|
|
+ } else {
|
|
|
+ _TimeProgress = 0; //改为0秒不动
|
|
|
+ }
|
|
|
+
|
|
|
+ _totalTime += _TimeProgress;
|
|
|
+ _this.wavGetTextProgress = ((_totalTime / _duration) * 100).toFixed(
|
|
|
+ 0
|
|
|
+ );
|
|
|
_this.wavGetTextLoading = true;
|
|
|
_this.showGetTextLoading = true;
|
|
|
let privText = e.privText;
|
|
|
- console.log("👇转译对象👇");
|
|
|
- console.log(e);
|
|
|
- console.log("👇转译结果👇");
|
|
|
- console.log(privText);
|
|
|
- if(!privText)return;
|
|
|
+ let privSpeakerId = e.privSpeakerId;
|
|
|
+ let privDuration = e.privDuration;
|
|
|
+ let privOffset = e.privOffset;
|
|
|
+ console.log("👉转译对象👉", e);
|
|
|
+ console.log("👉转译结果👉", privText);
|
|
|
+ if (!privText || !privSpeakerId || privSpeakerId == "Unknown") {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (_roleList[privSpeakerId]) {
|
|
|
+ privSpeakerId = _roleList[privSpeakerId];
|
|
|
+ } else {
|
|
|
+ _getRoleList.push({
|
|
|
+ role: privSpeakerId,
|
|
|
+ content: privText
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ _behavioralCodingList.push({
|
|
|
+ index: textList.length,
|
|
|
+ role: privSpeakerId,
|
|
|
+ content: privText,
|
|
|
+ code: ""
|
|
|
+ });
|
|
|
+
|
|
|
+ console.log("roleList", _roleList);
|
|
|
+ console.log("getRoleList", _getRoleList);
|
|
|
+ console.log("behavioralCodingList", _behavioralCodingList);
|
|
|
+ if (_getRoleList.length >= 10 && !_getRoleLoading) {
|
|
|
+ try {
|
|
|
+ let params = {
|
|
|
+ inputs: {
|
|
|
+ options: "老师,学生",
|
|
|
+ rows: JSON.stringify(
|
|
|
+ _getRoleList.map(i => {
|
|
|
+ return { content: i.content, role: i.role };
|
|
|
+ })
|
|
|
+ )
|
|
|
+ },
|
|
|
+ response_mode: "blocking",
|
|
|
+ user: _this.userId
|
|
|
+ };
|
|
|
+ _getRoleLoading = true;
|
|
|
+ _this
|
|
|
+ .getWavRoleList(params)
|
|
|
+ .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];
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ //同时更新
|
|
|
+ _behavioralCodingList.forEach(i=>{
|
|
|
+ if(roleKeys.includes(i.role)){
|
|
|
+ i.role = _roleList[i.role]
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ _getRoleList = _getRoleList.filter(
|
|
|
+ i => !roleKeys.includes(i.role)
|
|
|
+ );
|
|
|
+ _getRoleLoading = false;
|
|
|
+ })
|
|
|
+ .catch(err => {
|
|
|
+ console.log("获取说话人编码失败", err);
|
|
|
+ _getRoleLoading = false;
|
|
|
+ });
|
|
|
+ } catch (error) {
|
|
|
+ console.log("说话人编码失败", error);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ console.log("behavioralCodingListIf", (_behavioralCodingList.filter(
|
|
|
+ i => (i.role.indexOf("Guest") == -1 && i.code == "")
|
|
|
+ )));
|
|
|
+ if (
|
|
|
+ _behavioralCodingList.filter(
|
|
|
+ i => i.role.indexOf("Guest") === -1 && i.code === ""
|
|
|
+ ).length >= 10 &&
|
|
|
+ !_getBehavioralCodingLoading
|
|
|
+ ) {
|
|
|
+ try {
|
|
|
+ const _behavioralCodingListTemp = _behavioralCodingList
|
|
|
+ .filter(i => i.role.indexOf("Guest") == -1 && i.code == "")
|
|
|
+ .slice(0, 10);
|
|
|
+
|
|
|
+ console.log("behavioralCodingListTemp", _behavioralCodingListTemp);
|
|
|
+ const params = {
|
|
|
+ inputs: {
|
|
|
+ rows: JSON.stringify(
|
|
|
+ _behavioralCodingListTemp.map(i => ({
|
|
|
+ content: i.content,
|
|
|
+ role: i.role
|
|
|
+ }))
|
|
|
+ ),
|
|
|
+ options: "老师讲课,老师提问或点名,老师板书或操作,老师评价或反馈,老师其他,学生发言,学生小组活动,学生自主学习,学生汇报分享,学生其他",
|
|
|
+ attention: "- 先根据说话人角色判断,再在对应角色的选项中选择选项\n- 如果没有合适的选项,默认使用`老师其他`或者`学生其他`"
|
|
|
+ },
|
|
|
+ response_mode: "blocking",
|
|
|
+ user: _this.userId
|
|
|
+ };
|
|
|
+
|
|
|
+ _getBehavioralCodingLoading = true;
|
|
|
+ _this
|
|
|
+ .getBehavioralCoding(params)
|
|
|
+ .then(res => {
|
|
|
+ const _runResult = res.data.data.outputs.result;
|
|
|
+ _behavioralCodingListTemp.forEach((item, index) => {
|
|
|
+ const foundItem = _behavioralCodingList.find(i => i.index === item.index);
|
|
|
+ if (foundItem) {
|
|
|
+ foundItem.code = _runResult[index];
|
|
|
+ textList[item.index].code = foundItem.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: "",
|
|
|
- endTime: "",
|
|
|
- time: ""
|
|
|
+ startTime: _this.updateRecordedTime({ duration: _startTime }),
|
|
|
+ endTime: _this.updateRecordedTime({ duration: _endTime }),
|
|
|
+ time: _this.updateRecordedTime({ duration: _endTime - _startTime }),
|
|
|
+ role: privSpeakerId,
|
|
|
+ code: ""
|
|
|
});
|
|
|
+
|
|
|
+ _startTime = _endTime;
|
|
|
+
|
|
|
_this.transcriptionData.content += privText;
|
|
|
|
|
|
+ // console.log(textList);
|
|
|
+
|
|
|
let _result = `
|
|
|
<table
|
|
|
border="0"
|
|
@@ -1660,12 +1876,12 @@ ${JSON.stringify(_list)}
|
|
|
textList.forEach((item, index) => {
|
|
|
_result += `<tr>
|
|
|
<td>${index + 1}</td>
|
|
|
- <td></td>
|
|
|
- <td></td>
|
|
|
+ <td>${item.startTime}</td>
|
|
|
+ <td>${item.endTime}</td>
|
|
|
<td>${item.value}</td>
|
|
|
- <td></td>
|
|
|
- <td></td>
|
|
|
- <td></td>
|
|
|
+ <td>${item.time}</td>
|
|
|
+ <td>${item.role}</td>
|
|
|
+ <td>${item.code}</td>
|
|
|
</tr>`;
|
|
|
});
|
|
|
_result += `
|
|
@@ -1681,26 +1897,203 @@ ${JSON.stringify(_list)}
|
|
|
</tbody>
|
|
|
</table>`;
|
|
|
_this.editorBarData.content = _result;
|
|
|
+ this.$forceUpdate();
|
|
|
// _this.editorBarData.content += privText;
|
|
|
};
|
|
|
|
|
|
- iiframe.contentWindow.onSessionStopped = function(e) {
|
|
|
- _this.wavGetTextProgress = 100;
|
|
|
- if(_this.wavFileGetTextLoading)_this.$message.success("转译完成");
|
|
|
+ iiframe.contentWindow.onSessionStopped = async function(e) {
|
|
|
+ let _flag = false;
|
|
|
+ if (_getRoleList.length > 0) {
|
|
|
+ _flag = true;
|
|
|
+ await _this
|
|
|
+ .getWavRoleList({
|
|
|
+ inputs: {
|
|
|
+ options: "老师,学生",
|
|
|
+ rows: JSON.stringify(
|
|
|
+ _getRoleList.map(i => {
|
|
|
+ return { content: i.content, role: i.role };
|
|
|
+ })
|
|
|
+ )
|
|
|
+ },
|
|
|
+ response_mode: "blocking",
|
|
|
+ user: _this.userId
|
|
|
+ })
|
|
|
+ .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;
|
|
|
+ })
|
|
|
+ .catch(err => {
|
|
|
+ console.log("最后的获取说话人身份失败", err);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (
|
|
|
+ _behavioralCodingList.some(
|
|
|
+ i => i.role.indexOf("Guest") === -1 && i.code === ""
|
|
|
+ )
|
|
|
+ ) {
|
|
|
+ _flag = true;
|
|
|
+ const _behavioralCodingListTemp = _behavioralCodingList
|
|
|
+ .filter(i => i.role.indexOf("Guest") == -1 && i.code == "")
|
|
|
+ const params = {
|
|
|
+ inputs: {
|
|
|
+ rows: JSON.stringify(
|
|
|
+ _behavioralCodingListTemp.map(i => ({
|
|
|
+ content: i.content,
|
|
|
+ role: i.role
|
|
|
+ }))
|
|
|
+ ),
|
|
|
+ options: "老师讲课,老师提问或点名,老师板书或操作,老师评价或反馈,老师其他,学生发言,学生小组活动,学生自主学习,学生汇报分享,学生其他",
|
|
|
+ attention: "- 先根据说话人角色判断,再在对应角色的选项中选择选项\n- 如果没有合适的选项,默认使用`老师其他`或者`学生其他`"
|
|
|
+ },
|
|
|
+ response_mode: "blocking",
|
|
|
+ user: _this.userId
|
|
|
+ };
|
|
|
+ await _this
|
|
|
+ .getBehavioralCoding(params)
|
|
|
+ .then(res => {
|
|
|
+ const _runResult = res.data.data.outputs.result;
|
|
|
+ _behavioralCodingListTemp.forEach((item, index) => {
|
|
|
+ const foundItem = _behavioralCodingList.find(i => i.index === item.index);
|
|
|
+ if (foundItem) {
|
|
|
+ foundItem.code = _runResult[index];
|
|
|
+ textList[item.index].code = foundItem.code;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ })
|
|
|
+ .catch(err => {
|
|
|
+ console.log("获取行为编码错误", err);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ if (_flag) {
|
|
|
+ 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>${item.code}</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;
|
|
|
+ }
|
|
|
+ _this.wavGetTextProgress = 100;
|
|
|
+ if (_this.wavFileGetTextLoading) _this.$message.success("转译完成");
|
|
|
_this.showGetTextLoading = false;
|
|
|
_this.wavGetTextLoading = false;
|
|
|
_this.saveEditorBar();
|
|
|
};
|
|
|
|
|
|
- iiframe.contentWindow.doContinuousPronunciationAssessment("", {
|
|
|
+ iiframe.contentWindow.ConversationTranscriber({
|
|
|
files: [_file]
|
|
|
});
|
|
|
} catch (error) {
|
|
|
- console.log(error)
|
|
|
+ console.log(error);
|
|
|
this.wavGetTextLoading = false;
|
|
|
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 {
|
|
@@ -1708,7 +2101,7 @@ ${JSON.stringify(_list)}
|
|
|
iiframe.contentWindow.scenarioStopButton.click();
|
|
|
this.wavGetTextLoading = false;
|
|
|
this.showGetTextLoading = false;
|
|
|
- this.wavGetTextProgress = 0;
|
|
|
+ this.wavGetTextProgress = 0;
|
|
|
this.$message.success("终止转译成功");
|
|
|
} catch (error) {
|
|
|
this.$message.error("终止转译失败");
|
|
@@ -2995,8 +3388,26 @@ ${JSON.stringify(_list)}
|
|
|
this.shengyangContext.recorder = null;
|
|
|
this.shengyangContext.ws = null;
|
|
|
// TODO
|
|
|
- }
|
|
|
+ },
|
|
|
// ============ end 声扬录音转译
|
|
|
+ //替换文字
|
|
|
+ replaceText() {
|
|
|
+ if (!this.tid) return;
|
|
|
+ if (!this.replace1.trim() || !this.replace2.trim()) {
|
|
|
+ return this.$message.error("请输入内容");
|
|
|
+ }
|
|
|
+
|
|
|
+ let _replace1 = this.replace1.trim();
|
|
|
+ let _replace2 = this.replace2.trim();
|
|
|
+ console.log(_replace1, _replace2);
|
|
|
+ // console.log(this.editorBarData)
|
|
|
+ this.editorBarData.content = this.editorBarData.content.replace(
|
|
|
+ new RegExp(_replace1, "g"),
|
|
|
+ _replace2
|
|
|
+ );
|
|
|
+ this.$forceUpdate();
|
|
|
+ // this.saveEditorBar();
|
|
|
+ }
|
|
|
},
|
|
|
mounted() {
|
|
|
this.loadVoiceprints();
|
|
@@ -3645,10 +4056,10 @@ ${JSON.stringify(_list)}
|
|
|
color: #fff !important;
|
|
|
}
|
|
|
|
|
|
-.wavGetTextProgress{
|
|
|
- width: 250px;
|
|
|
- height: 32px;
|
|
|
- box-sizing: border-box;
|
|
|
- padding: 3px 0;
|
|
|
+.wavGetTextProgress {
|
|
|
+ width: 250px;
|
|
|
+ height: 32px;
|
|
|
+ box-sizing: border-box;
|
|
|
+ padding: 3px 0;
|
|
|
}
|
|
|
</style>
|