fix: 刷新页面处理
This commit is contained in:
parent
5be54dd239
commit
b9dd70b658
|
|
@ -146,10 +146,6 @@
|
|||
<!-- 讯飞语音识别 -->
|
||||
<script>
|
||||
window.onload = function () {
|
||||
reset();
|
||||
};
|
||||
|
||||
function reset() {
|
||||
var videoElement = document.getElementById('myVideo');
|
||||
var startTime = 5; // 开始时间(以秒为单位)
|
||||
var endTime = 10; // 结束时间(以秒为单位)
|
||||
|
|
@ -211,7 +207,6 @@
|
|||
endRec.style.display = "none";
|
||||
stopRec.style.display = "none";
|
||||
|
||||
|
||||
var token = null;
|
||||
let times = null;
|
||||
|
||||
|
|
@ -260,24 +255,24 @@
|
|||
/*
|
||||
* 实例化迅飞语音听写(流式版)WebAPI
|
||||
*/
|
||||
var seconds = 10;
|
||||
var seconds = 5;
|
||||
var gaptime = null;
|
||||
const voice = new Voice({
|
||||
var voice = new Voice({
|
||||
// 服务接口认证信息
|
||||
appId: '5f4ffdeb',
|
||||
apiSecret: 'OGIwM2RlMjBkOTI5Mzk5YTJlMzUwODI5',
|
||||
apiKey: '0b17a761b6b7174b789f639119d7e29a',
|
||||
onWillStatusChange: function (oldStatus, newStatus) {
|
||||
console.log(oldStatus, newStatus, '交互逻辑')
|
||||
},
|
||||
onWillStatusChange: function (oldStatus, newStatus) {},
|
||||
onTextChange: function (text) {
|
||||
// 监听识别结果的变化
|
||||
voiceTxt.innerText = text;
|
||||
marquee("marquee", "voice-txt");
|
||||
// 3秒钟内没有说话,就自动关闭
|
||||
|
||||
// 如果已有定时器在运行,则清除它
|
||||
if (gaptime) {
|
||||
clearInterval(gaptime);
|
||||
gaptime = null;
|
||||
};
|
||||
// 重置倒计时
|
||||
seconds = 10;
|
||||
|
|
@ -291,6 +286,7 @@
|
|||
console.log('有 text 参数'); // 如果有 text 参数,打印 1
|
||||
clearInterval(gaptime);
|
||||
gaptime = null;
|
||||
seconds = 10;
|
||||
|
||||
// 3秒钟内没有说话,就自动关闭
|
||||
if (text) {
|
||||
|
|
@ -299,6 +295,7 @@
|
|||
clearTimeout(times);
|
||||
times = setTimeout(() => {
|
||||
this.stop();
|
||||
statusTxt.value = '正在说话';
|
||||
|
||||
const params = { msg: text };
|
||||
|
||||
|
|
@ -475,7 +472,12 @@
|
|||
}
|
||||
}
|
||||
} else if (seconds == 0){
|
||||
reset();
|
||||
clearInterval(gaptime);
|
||||
closeShibie();
|
||||
|
||||
// 重置
|
||||
location.reload();
|
||||
return;
|
||||
}
|
||||
}, 1000);
|
||||
}
|
||||
|
|
@ -527,13 +529,8 @@
|
|||
// 先静音即可处理解决(提前做交互)
|
||||
audioElement.muted = false;
|
||||
|
||||
// 检查是否可以播放,避免中断
|
||||
if (!audioElement.paused) {
|
||||
audioElement.currentTime = 0;
|
||||
audioElement.pause();
|
||||
};
|
||||
|
||||
seconds = 10;
|
||||
|
||||
voice.start();
|
||||
|
||||
|
|
@ -544,28 +541,18 @@
|
|||
}
|
||||
|
||||
function closeShibie() {
|
||||
reset();
|
||||
|
||||
/**关闭识别**/
|
||||
voiceTxt.innerText = '';
|
||||
statusTxt.value = '';
|
||||
stopRec.textContent = '暂停';
|
||||
|
||||
voice.stop();
|
||||
// 音频
|
||||
// 检查是否可以播放,避免中断
|
||||
if (!audioElement.paused) {
|
||||
audioElement.currentTime = 0;
|
||||
audioElement.pause();
|
||||
};
|
||||
|
||||
audioElement.currentTime = 0;
|
||||
// 视频
|
||||
replayVideoSegment(0, 60);
|
||||
|
||||
isCallbackExecuted = false;
|
||||
seconds = 10;
|
||||
|
||||
voice.stop();
|
||||
console.log('关闭识别');
|
||||
|
||||
startRec.style.display = 'block';
|
||||
endRec.style.display = 'none';
|
||||
|
|
@ -779,7 +766,7 @@
|
|||
// 如果没有找到匹配的数据项,则返回null或错误信息(这里选择返回null)
|
||||
return null;
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -146,10 +146,6 @@
|
|||
<!-- 讯飞语音识别 -->
|
||||
<script>
|
||||
window.onload = function () {
|
||||
reset();
|
||||
};
|
||||
|
||||
function reset() {
|
||||
var videoElement = document.getElementById('myVideo');
|
||||
var startTime = 5; // 开始时间(以秒为单位)
|
||||
var endTime = 10; // 结束时间(以秒为单位)
|
||||
|
|
@ -211,7 +207,6 @@
|
|||
endRec.style.display = "none";
|
||||
stopRec.style.display = "none";
|
||||
|
||||
|
||||
var token = null;
|
||||
let times = null;
|
||||
|
||||
|
|
@ -260,24 +255,24 @@
|
|||
/*
|
||||
* 实例化迅飞语音听写(流式版)WebAPI
|
||||
*/
|
||||
var seconds = 10;
|
||||
var seconds = 5;
|
||||
var gaptime = null;
|
||||
const voice = new Voice({
|
||||
var voice = new Voice({
|
||||
// 服务接口认证信息
|
||||
appId: '5f4ffdeb',
|
||||
apiSecret: 'OGIwM2RlMjBkOTI5Mzk5YTJlMzUwODI5',
|
||||
apiKey: '0b17a761b6b7174b789f639119d7e29a',
|
||||
onWillStatusChange: function (oldStatus, newStatus) {
|
||||
console.log(oldStatus, newStatus, '交互逻辑')
|
||||
},
|
||||
onWillStatusChange: function (oldStatus, newStatus) {},
|
||||
onTextChange: function (text) {
|
||||
// 监听识别结果的变化
|
||||
voiceTxt.innerText = text;
|
||||
marquee("marquee", "voice-txt");
|
||||
// 3秒钟内没有说话,就自动关闭
|
||||
|
||||
// 如果已有定时器在运行,则清除它
|
||||
if (gaptime) {
|
||||
clearInterval(gaptime);
|
||||
gaptime = null;
|
||||
};
|
||||
// 重置倒计时
|
||||
seconds = 10;
|
||||
|
|
@ -291,6 +286,7 @@
|
|||
console.log('有 text 参数'); // 如果有 text 参数,打印 1
|
||||
clearInterval(gaptime);
|
||||
gaptime = null;
|
||||
seconds = 10;
|
||||
|
||||
// 3秒钟内没有说话,就自动关闭
|
||||
if (text) {
|
||||
|
|
@ -478,9 +474,16 @@
|
|||
} else if (seconds == 0){
|
||||
clearInterval(gaptime);
|
||||
closeShibie();
|
||||
reset();
|
||||
gaptime = null;
|
||||
seconds = 10;
|
||||
|
||||
// 重置
|
||||
voiceTxt.innerText = '';
|
||||
statusTxt.value = '';
|
||||
replayVideoSegment(0, 60);
|
||||
hideModal();
|
||||
stopVideo();
|
||||
window.onload();
|
||||
|
||||
return;
|
||||
}
|
||||
}, 1000);
|
||||
}
|
||||
|
|
@ -532,13 +535,8 @@
|
|||
// 先静音即可处理解决(提前做交互)
|
||||
audioElement.muted = false;
|
||||
|
||||
// 检查是否可以播放,避免中断
|
||||
if (!audioElement.paused) {
|
||||
audioElement.currentTime = 0;
|
||||
audioElement.pause();
|
||||
};
|
||||
|
||||
seconds = 10;
|
||||
|
||||
voice.start();
|
||||
|
||||
|
|
@ -553,22 +551,14 @@
|
|||
voiceTxt.innerText = '';
|
||||
statusTxt.value = '';
|
||||
stopRec.textContent = '暂停';
|
||||
|
||||
voice.stop();
|
||||
// 音频
|
||||
// 检查是否可以播放,避免中断
|
||||
if (!audioElement.paused) {
|
||||
audioElement.currentTime = 0;
|
||||
audioElement.pause();
|
||||
};
|
||||
|
||||
audioElement.currentTime = 0;
|
||||
// 视频
|
||||
replayVideoSegment(0, 60);
|
||||
|
||||
isCallbackExecuted = false;
|
||||
seconds = 10;
|
||||
|
||||
voice.stop();
|
||||
console.log('关闭识别');
|
||||
|
||||
startRec.style.display = 'block';
|
||||
endRec.style.display = 'none';
|
||||
|
|
@ -782,7 +772,7 @@
|
|||
// 如果没有找到匹配的数据项,则返回null或错误信息(这里选择返回null)
|
||||
return null;
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -146,10 +146,6 @@
|
|||
<!-- 讯飞语音识别 -->
|
||||
<script>
|
||||
window.onload = function () {
|
||||
reset();
|
||||
};
|
||||
|
||||
function reset() {
|
||||
var videoElement = document.getElementById('myVideo');
|
||||
var startTime = 5; // 开始时间(以秒为单位)
|
||||
var endTime = 10; // 结束时间(以秒为单位)
|
||||
|
|
@ -211,7 +207,6 @@
|
|||
endRec.style.display = "none";
|
||||
stopRec.style.display = "none";
|
||||
|
||||
|
||||
var token = null;
|
||||
let times = null;
|
||||
|
||||
|
|
@ -260,24 +255,24 @@
|
|||
/*
|
||||
* 实例化迅飞语音听写(流式版)WebAPI
|
||||
*/
|
||||
var seconds = 10;
|
||||
var seconds = 5;
|
||||
var gaptime = null;
|
||||
const voice = new Voice({
|
||||
var voice = new Voice({
|
||||
// 服务接口认证信息
|
||||
appId: '5f4ffdeb',
|
||||
apiSecret: 'OGIwM2RlMjBkOTI5Mzk5YTJlMzUwODI5',
|
||||
apiKey: '0b17a761b6b7174b789f639119d7e29a',
|
||||
onWillStatusChange: function (oldStatus, newStatus) {
|
||||
console.log(oldStatus, newStatus, '交互逻辑')
|
||||
},
|
||||
onWillStatusChange: function (oldStatus, newStatus) {},
|
||||
onTextChange: function (text) {
|
||||
// 监听识别结果的变化
|
||||
voiceTxt.innerText = text;
|
||||
marquee("marquee", "voice-txt");
|
||||
// 3秒钟内没有说话,就自动关闭
|
||||
|
||||
// 如果已有定时器在运行,则清除它
|
||||
if (gaptime) {
|
||||
clearInterval(gaptime);
|
||||
gaptime = null;
|
||||
};
|
||||
// 重置倒计时
|
||||
seconds = 10;
|
||||
|
|
@ -291,6 +286,7 @@
|
|||
console.log('有 text 参数'); // 如果有 text 参数,打印 1
|
||||
clearInterval(gaptime);
|
||||
gaptime = null;
|
||||
seconds = 10;
|
||||
|
||||
// 3秒钟内没有说话,就自动关闭
|
||||
if (text) {
|
||||
|
|
@ -478,9 +474,16 @@
|
|||
} else if (seconds == 0){
|
||||
clearInterval(gaptime);
|
||||
closeShibie();
|
||||
reset();
|
||||
gaptime = null;
|
||||
seconds = 10;
|
||||
|
||||
// 重置
|
||||
voiceTxt.innerText = '';
|
||||
statusTxt.value = '';
|
||||
replayVideoSegment(0, 60);
|
||||
hideModal();
|
||||
stopVideo();
|
||||
window.onload();
|
||||
|
||||
return;
|
||||
}
|
||||
}, 1000);
|
||||
}
|
||||
|
|
@ -532,13 +535,8 @@
|
|||
// 先静音即可处理解决(提前做交互)
|
||||
audioElement.muted = false;
|
||||
|
||||
// 检查是否可以播放,避免中断
|
||||
if (!audioElement.paused) {
|
||||
audioElement.currentTime = 0;
|
||||
audioElement.pause();
|
||||
};
|
||||
|
||||
seconds = 10;
|
||||
|
||||
voice.start();
|
||||
|
||||
|
|
@ -553,22 +551,14 @@
|
|||
voiceTxt.innerText = '';
|
||||
statusTxt.value = '';
|
||||
stopRec.textContent = '暂停';
|
||||
|
||||
voice.stop();
|
||||
// 音频
|
||||
// 检查是否可以播放,避免中断
|
||||
if (!audioElement.paused) {
|
||||
audioElement.currentTime = 0;
|
||||
audioElement.pause();
|
||||
};
|
||||
|
||||
audioElement.currentTime = 0;
|
||||
// 视频
|
||||
replayVideoSegment(0, 60);
|
||||
|
||||
isCallbackExecuted = false;
|
||||
seconds = 10;
|
||||
|
||||
voice.stop();
|
||||
console.log('关闭识别');
|
||||
|
||||
startRec.style.display = 'block';
|
||||
endRec.style.display = 'none';
|
||||
|
|
@ -782,7 +772,7 @@
|
|||
// 如果没有找到匹配的数据项,则返回null或错误信息(这里选择返回null)
|
||||
return null;
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -146,10 +146,6 @@
|
|||
<!-- 讯飞语音识别 -->
|
||||
<script>
|
||||
window.onload = function () {
|
||||
reset();
|
||||
};
|
||||
|
||||
function reset() {
|
||||
var videoElement = document.getElementById('myVideo');
|
||||
var startTime = 5; // 开始时间(以秒为单位)
|
||||
var endTime = 10; // 结束时间(以秒为单位)
|
||||
|
|
@ -211,7 +207,6 @@
|
|||
endRec.style.display = "none";
|
||||
stopRec.style.display = "none";
|
||||
|
||||
|
||||
var token = null;
|
||||
let times = null;
|
||||
|
||||
|
|
@ -260,24 +255,24 @@
|
|||
/*
|
||||
* 实例化迅飞语音听写(流式版)WebAPI
|
||||
*/
|
||||
var seconds = 10;
|
||||
var seconds = 5;
|
||||
var gaptime = null;
|
||||
const voice = new Voice({
|
||||
var voice = new Voice({
|
||||
// 服务接口认证信息
|
||||
appId: '5f4ffdeb',
|
||||
apiSecret: 'OGIwM2RlMjBkOTI5Mzk5YTJlMzUwODI5',
|
||||
apiKey: '0b17a761b6b7174b789f639119d7e29a',
|
||||
onWillStatusChange: function (oldStatus, newStatus) {
|
||||
console.log(oldStatus, newStatus, '交互逻辑')
|
||||
},
|
||||
onWillStatusChange: function (oldStatus, newStatus) {},
|
||||
onTextChange: function (text) {
|
||||
// 监听识别结果的变化
|
||||
voiceTxt.innerText = text;
|
||||
marquee("marquee", "voice-txt");
|
||||
// 3秒钟内没有说话,就自动关闭
|
||||
|
||||
// 如果已有定时器在运行,则清除它
|
||||
if (gaptime) {
|
||||
clearInterval(gaptime);
|
||||
gaptime = null;
|
||||
};
|
||||
// 重置倒计时
|
||||
seconds = 10;
|
||||
|
|
@ -291,6 +286,7 @@
|
|||
console.log('有 text 参数'); // 如果有 text 参数,打印 1
|
||||
clearInterval(gaptime);
|
||||
gaptime = null;
|
||||
seconds = 10;
|
||||
|
||||
// 3秒钟内没有说话,就自动关闭
|
||||
if (text) {
|
||||
|
|
@ -299,6 +295,7 @@
|
|||
clearTimeout(times);
|
||||
times = setTimeout(() => {
|
||||
this.stop();
|
||||
statusTxt.value = '正在说话';
|
||||
|
||||
const params = { msg: text };
|
||||
|
||||
|
|
@ -475,7 +472,12 @@
|
|||
}
|
||||
}
|
||||
} else if (seconds == 0){
|
||||
reset();
|
||||
clearInterval(gaptime);
|
||||
closeShibie();
|
||||
|
||||
// 重置
|
||||
location.reload();
|
||||
return;
|
||||
}
|
||||
}, 1000);
|
||||
}
|
||||
|
|
@ -527,13 +529,8 @@
|
|||
// 先静音即可处理解决(提前做交互)
|
||||
audioElement.muted = false;
|
||||
|
||||
// 检查是否可以播放,避免中断
|
||||
if (!audioElement.paused) {
|
||||
audioElement.currentTime = 0;
|
||||
audioElement.pause();
|
||||
};
|
||||
|
||||
seconds = 10;
|
||||
|
||||
voice.start();
|
||||
|
||||
|
|
@ -544,28 +541,18 @@
|
|||
}
|
||||
|
||||
function closeShibie() {
|
||||
reset();
|
||||
|
||||
/**关闭识别**/
|
||||
voiceTxt.innerText = '';
|
||||
statusTxt.value = '';
|
||||
stopRec.textContent = '暂停';
|
||||
|
||||
voice.stop();
|
||||
// 音频
|
||||
// 检查是否可以播放,避免中断
|
||||
if (!audioElement.paused) {
|
||||
audioElement.currentTime = 0;
|
||||
audioElement.pause();
|
||||
};
|
||||
|
||||
audioElement.currentTime = 0;
|
||||
// 视频
|
||||
replayVideoSegment(0, 60);
|
||||
|
||||
isCallbackExecuted = false;
|
||||
seconds = 10;
|
||||
|
||||
voice.stop();
|
||||
console.log('关闭识别');
|
||||
|
||||
startRec.style.display = 'block';
|
||||
endRec.style.display = 'none';
|
||||
|
|
@ -779,7 +766,7 @@
|
|||
// 如果没有找到匹配的数据项,则返回null或错误信息(这里选择返回null)
|
||||
return null;
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
|
||||
|
|
|
|||
Binary file not shown.
Loading…
Reference in New Issue