fix: 监听语音结束逻辑
This commit is contained in:
parent
f2d1f60941
commit
f0a8f386ee
|
|
@ -159,6 +159,7 @@
|
||||||
const speakingTime = wordCount / wordsPerMinute;
|
const speakingTime = wordCount / wordsPerMinute;
|
||||||
// 转换为秒数
|
// 转换为秒数
|
||||||
const speakingTimeInSeconds = speakingTime * 60;
|
const speakingTimeInSeconds = speakingTime * 60;
|
||||||
|
console.log(speakingTimeInSeconds, '说完需要多少秒')
|
||||||
return speakingTimeInSeconds;
|
return speakingTimeInSeconds;
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
@ -407,26 +408,18 @@
|
||||||
// 循环视频
|
// 循环视频
|
||||||
replayVideoSegment(60, 120);
|
replayVideoSegment(60, 120);
|
||||||
|
|
||||||
// 计算所需时间
|
// 监听播放技术
|
||||||
const speakingTime = calculateSpeakingTime(filterString(str.output.text, ['*', ' ']));
|
myAudio.addEventListener('ended', function() {
|
||||||
|
console.log('音频播放已结束!');
|
||||||
// 开始倒计时
|
// 停止倒计时
|
||||||
var totalTime = speakingTime;
|
startRec.style.display = 'block';
|
||||||
var countdown = setInterval(function() {
|
endRec.style.display = 'none';
|
||||||
// 更新剩余时间
|
statusTxt.value = '';
|
||||||
totalTime --;
|
voiceTxt.innerText = '';
|
||||||
if (totalTime <= 0) {
|
voice.stop();
|
||||||
// 停止倒计时
|
replayVideoSegment(0, 60);
|
||||||
startRec.style.display = 'block';
|
hideModal()
|
||||||
endRec.style.display = 'none';
|
});
|
||||||
statusTxt.value = '';
|
|
||||||
voiceTxt.innerText = '';
|
|
||||||
clearInterval(countdown);
|
|
||||||
voice.stop();
|
|
||||||
replayVideoSegment(0, 60);
|
|
||||||
}
|
|
||||||
}, 1000);
|
|
||||||
hideModal()
|
|
||||||
}).catch(e => {
|
}).catch(e => {
|
||||||
hideModal();
|
hideModal();
|
||||||
});
|
});
|
||||||
|
|
@ -496,27 +489,18 @@
|
||||||
// 循环视频
|
// 循环视频
|
||||||
replayVideoSegment(60, 120);
|
replayVideoSegment(60, 120);
|
||||||
|
|
||||||
// 计算所需时间
|
// 监听播放技术
|
||||||
const speakingTime = calculateSpeakingTime(voiceTxt.innerText);
|
myAudio.addEventListener('ended', function() {
|
||||||
|
console.log('音频播放已结束!');
|
||||||
// 开始倒计时
|
// 停止倒计时
|
||||||
var totalTime = speakingTime;
|
startRec.style.display = 'block';
|
||||||
var countdown = setInterval(function() {
|
endRec.style.display = 'none';
|
||||||
// 更新剩余时间
|
statusTxt.value = '';
|
||||||
totalTime --;
|
voiceTxt.innerText = '';
|
||||||
if (totalTime <= 0) {
|
voice.stop();
|
||||||
// 停止倒计时
|
replayVideoSegment(0, 60);
|
||||||
startRec.style.display = 'block';
|
hideModal()
|
||||||
endRec.style.display = 'none';
|
});
|
||||||
statusTxt.value = '';
|
|
||||||
voiceTxt.innerText = '';
|
|
||||||
clearInterval(countdown);
|
|
||||||
voice.stop();
|
|
||||||
replayVideoSegment(0, 60);
|
|
||||||
}
|
|
||||||
}, 1000);
|
|
||||||
|
|
||||||
hideModal()
|
|
||||||
}).catch(e => {
|
}).catch(e => {
|
||||||
hideModal();
|
hideModal();
|
||||||
});
|
});
|
||||||
|
|
@ -660,26 +644,18 @@
|
||||||
// 循环视频
|
// 循环视频
|
||||||
replayVideoSegment(60, 120);
|
replayVideoSegment(60, 120);
|
||||||
|
|
||||||
// 计算所需时间
|
// 监听播放技术
|
||||||
const speakingTime = calculateSpeakingTime(content.data.choices[0].text);
|
myAudio.addEventListener('ended', function() {
|
||||||
|
console.log('音频播放已结束!');
|
||||||
// 开始倒计时
|
// 停止倒计时
|
||||||
var totalTime = speakingTime;
|
startRec.style.display = 'block';
|
||||||
var countdown = setInterval(function() {
|
endRec.style.display = 'none';
|
||||||
// 更新剩余时间
|
statusTxt.value = '';
|
||||||
totalTime --;
|
voiceTxt.innerText = '';
|
||||||
if (totalTime <= 0) {
|
voice.stop();
|
||||||
// 停止倒计时
|
replayVideoSegment(0, 60);
|
||||||
startRec.style.display = 'block';
|
hideModal()
|
||||||
endRec.style.display = 'none';
|
});
|
||||||
statusTxt.value = '';
|
|
||||||
voiceTxt.innerText = '';
|
|
||||||
clearInterval(countdown);
|
|
||||||
replayVideoSegment(0, 60);
|
|
||||||
}
|
|
||||||
}, 1000);
|
|
||||||
|
|
||||||
hideModal()
|
|
||||||
}).catch(e => {
|
}).catch(e => {
|
||||||
hideModal();
|
hideModal();
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -159,6 +159,7 @@
|
||||||
const speakingTime = wordCount / wordsPerMinute;
|
const speakingTime = wordCount / wordsPerMinute;
|
||||||
// 转换为秒数
|
// 转换为秒数
|
||||||
const speakingTimeInSeconds = speakingTime * 60;
|
const speakingTimeInSeconds = speakingTime * 60;
|
||||||
|
console.log(speakingTimeInSeconds, '说完需要多少秒')
|
||||||
return speakingTimeInSeconds;
|
return speakingTimeInSeconds;
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
@ -407,26 +408,18 @@
|
||||||
// 循环视频
|
// 循环视频
|
||||||
replayVideoSegment(60, 120);
|
replayVideoSegment(60, 120);
|
||||||
|
|
||||||
// 计算所需时间
|
// 监听播放技术
|
||||||
const speakingTime = calculateSpeakingTime(filterString(str.output.text, ['*', ' ']));
|
myAudio.addEventListener('ended', function() {
|
||||||
|
console.log('音频播放已结束!');
|
||||||
// 开始倒计时
|
// 停止倒计时
|
||||||
var totalTime = speakingTime;
|
startRec.style.display = 'block';
|
||||||
var countdown = setInterval(function() {
|
endRec.style.display = 'none';
|
||||||
// 更新剩余时间
|
statusTxt.value = '';
|
||||||
totalTime --;
|
voiceTxt.innerText = '';
|
||||||
if (totalTime <= 0) {
|
voice.stop();
|
||||||
// 停止倒计时
|
replayVideoSegment(0, 60);
|
||||||
startRec.style.display = 'block';
|
hideModal()
|
||||||
endRec.style.display = 'none';
|
});
|
||||||
statusTxt.value = '';
|
|
||||||
voiceTxt.innerText = '';
|
|
||||||
clearInterval(countdown);
|
|
||||||
voice.stop();
|
|
||||||
replayVideoSegment(0, 60);
|
|
||||||
}
|
|
||||||
}, 1000);
|
|
||||||
hideModal()
|
|
||||||
}).catch(e => {
|
}).catch(e => {
|
||||||
hideModal();
|
hideModal();
|
||||||
});
|
});
|
||||||
|
|
@ -496,27 +489,18 @@
|
||||||
// 循环视频
|
// 循环视频
|
||||||
replayVideoSegment(60, 120);
|
replayVideoSegment(60, 120);
|
||||||
|
|
||||||
// 计算所需时间
|
// 监听播放技术
|
||||||
const speakingTime = calculateSpeakingTime(voiceTxt.innerText);
|
myAudio.addEventListener('ended', function() {
|
||||||
|
console.log('音频播放已结束!');
|
||||||
// 开始倒计时
|
// 停止倒计时
|
||||||
var totalTime = speakingTime;
|
startRec.style.display = 'block';
|
||||||
var countdown = setInterval(function() {
|
endRec.style.display = 'none';
|
||||||
// 更新剩余时间
|
statusTxt.value = '';
|
||||||
totalTime --;
|
voiceTxt.innerText = '';
|
||||||
if (totalTime <= 0) {
|
voice.stop();
|
||||||
// 停止倒计时
|
replayVideoSegment(0, 60);
|
||||||
startRec.style.display = 'block';
|
hideModal()
|
||||||
endRec.style.display = 'none';
|
});
|
||||||
statusTxt.value = '';
|
|
||||||
voiceTxt.innerText = '';
|
|
||||||
clearInterval(countdown);
|
|
||||||
voice.stop();
|
|
||||||
replayVideoSegment(0, 60);
|
|
||||||
}
|
|
||||||
}, 1000);
|
|
||||||
|
|
||||||
hideModal()
|
|
||||||
}).catch(e => {
|
}).catch(e => {
|
||||||
hideModal();
|
hideModal();
|
||||||
});
|
});
|
||||||
|
|
@ -660,26 +644,18 @@
|
||||||
// 循环视频
|
// 循环视频
|
||||||
replayVideoSegment(60, 120);
|
replayVideoSegment(60, 120);
|
||||||
|
|
||||||
// 计算所需时间
|
// 监听播放技术
|
||||||
const speakingTime = calculateSpeakingTime(content.data.choices[0].text);
|
myAudio.addEventListener('ended', function() {
|
||||||
|
console.log('音频播放已结束!');
|
||||||
// 开始倒计时
|
// 停止倒计时
|
||||||
var totalTime = speakingTime;
|
startRec.style.display = 'block';
|
||||||
var countdown = setInterval(function() {
|
endRec.style.display = 'none';
|
||||||
// 更新剩余时间
|
statusTxt.value = '';
|
||||||
totalTime --;
|
voiceTxt.innerText = '';
|
||||||
if (totalTime <= 0) {
|
voice.stop();
|
||||||
// 停止倒计时
|
replayVideoSegment(0, 60);
|
||||||
startRec.style.display = 'block';
|
hideModal()
|
||||||
endRec.style.display = 'none';
|
});
|
||||||
statusTxt.value = '';
|
|
||||||
voiceTxt.innerText = '';
|
|
||||||
clearInterval(countdown);
|
|
||||||
replayVideoSegment(0, 60);
|
|
||||||
}
|
|
||||||
}, 1000);
|
|
||||||
|
|
||||||
hideModal()
|
|
||||||
}).catch(e => {
|
}).catch(e => {
|
||||||
hideModal();
|
hideModal();
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -159,6 +159,7 @@
|
||||||
const speakingTime = wordCount / wordsPerMinute;
|
const speakingTime = wordCount / wordsPerMinute;
|
||||||
// 转换为秒数
|
// 转换为秒数
|
||||||
const speakingTimeInSeconds = speakingTime * 60;
|
const speakingTimeInSeconds = speakingTime * 60;
|
||||||
|
console.log(speakingTimeInSeconds, '说完需要多少秒')
|
||||||
return speakingTimeInSeconds;
|
return speakingTimeInSeconds;
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
@ -407,26 +408,18 @@
|
||||||
// 循环视频
|
// 循环视频
|
||||||
replayVideoSegment(60, 120);
|
replayVideoSegment(60, 120);
|
||||||
|
|
||||||
// 计算所需时间
|
// 监听播放技术
|
||||||
const speakingTime = calculateSpeakingTime(filterString(str.output.text, ['*', ' ']));
|
myAudio.addEventListener('ended', function() {
|
||||||
|
console.log('音频播放已结束!');
|
||||||
// 开始倒计时
|
// 停止倒计时
|
||||||
var totalTime = speakingTime;
|
startRec.style.display = 'block';
|
||||||
var countdown = setInterval(function() {
|
endRec.style.display = 'none';
|
||||||
// 更新剩余时间
|
statusTxt.value = '';
|
||||||
totalTime --;
|
voiceTxt.innerText = '';
|
||||||
if (totalTime <= 0) {
|
voice.stop();
|
||||||
// 停止倒计时
|
replayVideoSegment(0, 60);
|
||||||
startRec.style.display = 'block';
|
hideModal()
|
||||||
endRec.style.display = 'none';
|
});
|
||||||
statusTxt.value = '';
|
|
||||||
voiceTxt.innerText = '';
|
|
||||||
clearInterval(countdown);
|
|
||||||
voice.stop();
|
|
||||||
replayVideoSegment(0, 60);
|
|
||||||
}
|
|
||||||
}, 1000);
|
|
||||||
hideModal()
|
|
||||||
}).catch(e => {
|
}).catch(e => {
|
||||||
hideModal();
|
hideModal();
|
||||||
});
|
});
|
||||||
|
|
@ -496,27 +489,18 @@
|
||||||
// 循环视频
|
// 循环视频
|
||||||
replayVideoSegment(60, 120);
|
replayVideoSegment(60, 120);
|
||||||
|
|
||||||
// 计算所需时间
|
// 监听播放技术
|
||||||
const speakingTime = calculateSpeakingTime(voiceTxt.innerText);
|
myAudio.addEventListener('ended', function() {
|
||||||
|
console.log('音频播放已结束!');
|
||||||
// 开始倒计时
|
// 停止倒计时
|
||||||
var totalTime = speakingTime;
|
startRec.style.display = 'block';
|
||||||
var countdown = setInterval(function() {
|
endRec.style.display = 'none';
|
||||||
// 更新剩余时间
|
statusTxt.value = '';
|
||||||
totalTime --;
|
voiceTxt.innerText = '';
|
||||||
if (totalTime <= 0) {
|
voice.stop();
|
||||||
// 停止倒计时
|
replayVideoSegment(0, 60);
|
||||||
startRec.style.display = 'block';
|
hideModal()
|
||||||
endRec.style.display = 'none';
|
});
|
||||||
statusTxt.value = '';
|
|
||||||
voiceTxt.innerText = '';
|
|
||||||
clearInterval(countdown);
|
|
||||||
voice.stop();
|
|
||||||
replayVideoSegment(0, 60);
|
|
||||||
}
|
|
||||||
}, 1000);
|
|
||||||
|
|
||||||
hideModal()
|
|
||||||
}).catch(e => {
|
}).catch(e => {
|
||||||
hideModal();
|
hideModal();
|
||||||
});
|
});
|
||||||
|
|
@ -660,26 +644,18 @@
|
||||||
// 循环视频
|
// 循环视频
|
||||||
replayVideoSegment(60, 120);
|
replayVideoSegment(60, 120);
|
||||||
|
|
||||||
// 计算所需时间
|
// 监听播放技术
|
||||||
const speakingTime = calculateSpeakingTime(content.data.choices[0].text);
|
myAudio.addEventListener('ended', function() {
|
||||||
|
console.log('音频播放已结束!');
|
||||||
// 开始倒计时
|
// 停止倒计时
|
||||||
var totalTime = speakingTime;
|
startRec.style.display = 'block';
|
||||||
var countdown = setInterval(function() {
|
endRec.style.display = 'none';
|
||||||
// 更新剩余时间
|
statusTxt.value = '';
|
||||||
totalTime --;
|
voiceTxt.innerText = '';
|
||||||
if (totalTime <= 0) {
|
voice.stop();
|
||||||
// 停止倒计时
|
replayVideoSegment(0, 60);
|
||||||
startRec.style.display = 'block';
|
hideModal()
|
||||||
endRec.style.display = 'none';
|
});
|
||||||
statusTxt.value = '';
|
|
||||||
voiceTxt.innerText = '';
|
|
||||||
clearInterval(countdown);
|
|
||||||
replayVideoSegment(0, 60);
|
|
||||||
}
|
|
||||||
}, 1000);
|
|
||||||
|
|
||||||
hideModal()
|
|
||||||
}).catch(e => {
|
}).catch(e => {
|
||||||
hideModal();
|
hideModal();
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -159,6 +159,7 @@
|
||||||
const speakingTime = wordCount / wordsPerMinute;
|
const speakingTime = wordCount / wordsPerMinute;
|
||||||
// 转换为秒数
|
// 转换为秒数
|
||||||
const speakingTimeInSeconds = speakingTime * 60;
|
const speakingTimeInSeconds = speakingTime * 60;
|
||||||
|
console.log(speakingTimeInSeconds, '说完需要多少秒')
|
||||||
return speakingTimeInSeconds;
|
return speakingTimeInSeconds;
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
@ -407,26 +408,18 @@
|
||||||
// 循环视频
|
// 循环视频
|
||||||
replayVideoSegment(60, 120);
|
replayVideoSegment(60, 120);
|
||||||
|
|
||||||
// 计算所需时间
|
// 监听播放技术
|
||||||
const speakingTime = calculateSpeakingTime(filterString(str.output.text, ['*', ' ']));
|
myAudio.addEventListener('ended', function() {
|
||||||
|
console.log('音频播放已结束!');
|
||||||
// 开始倒计时
|
// 停止倒计时
|
||||||
var totalTime = speakingTime;
|
startRec.style.display = 'block';
|
||||||
var countdown = setInterval(function() {
|
endRec.style.display = 'none';
|
||||||
// 更新剩余时间
|
statusTxt.value = '';
|
||||||
totalTime --;
|
voiceTxt.innerText = '';
|
||||||
if (totalTime <= 0) {
|
voice.stop();
|
||||||
// 停止倒计时
|
replayVideoSegment(0, 60);
|
||||||
startRec.style.display = 'block';
|
hideModal()
|
||||||
endRec.style.display = 'none';
|
});
|
||||||
statusTxt.value = '';
|
|
||||||
voiceTxt.innerText = '';
|
|
||||||
clearInterval(countdown);
|
|
||||||
voice.stop();
|
|
||||||
replayVideoSegment(0, 60);
|
|
||||||
}
|
|
||||||
}, 1000);
|
|
||||||
hideModal()
|
|
||||||
}).catch(e => {
|
}).catch(e => {
|
||||||
hideModal();
|
hideModal();
|
||||||
});
|
});
|
||||||
|
|
@ -496,27 +489,18 @@
|
||||||
// 循环视频
|
// 循环视频
|
||||||
replayVideoSegment(60, 120);
|
replayVideoSegment(60, 120);
|
||||||
|
|
||||||
// 计算所需时间
|
// 监听播放技术
|
||||||
const speakingTime = calculateSpeakingTime(voiceTxt.innerText);
|
myAudio.addEventListener('ended', function() {
|
||||||
|
console.log('音频播放已结束!');
|
||||||
// 开始倒计时
|
// 停止倒计时
|
||||||
var totalTime = speakingTime;
|
startRec.style.display = 'block';
|
||||||
var countdown = setInterval(function() {
|
endRec.style.display = 'none';
|
||||||
// 更新剩余时间
|
statusTxt.value = '';
|
||||||
totalTime --;
|
voiceTxt.innerText = '';
|
||||||
if (totalTime <= 0) {
|
voice.stop();
|
||||||
// 停止倒计时
|
replayVideoSegment(0, 60);
|
||||||
startRec.style.display = 'block';
|
hideModal()
|
||||||
endRec.style.display = 'none';
|
});
|
||||||
statusTxt.value = '';
|
|
||||||
voiceTxt.innerText = '';
|
|
||||||
clearInterval(countdown);
|
|
||||||
voice.stop();
|
|
||||||
replayVideoSegment(0, 60);
|
|
||||||
}
|
|
||||||
}, 1000);
|
|
||||||
|
|
||||||
hideModal()
|
|
||||||
}).catch(e => {
|
}).catch(e => {
|
||||||
hideModal();
|
hideModal();
|
||||||
});
|
});
|
||||||
|
|
@ -660,26 +644,18 @@
|
||||||
// 循环视频
|
// 循环视频
|
||||||
replayVideoSegment(60, 120);
|
replayVideoSegment(60, 120);
|
||||||
|
|
||||||
// 计算所需时间
|
// 监听播放技术
|
||||||
const speakingTime = calculateSpeakingTime(content.data.choices[0].text);
|
myAudio.addEventListener('ended', function() {
|
||||||
|
console.log('音频播放已结束!');
|
||||||
// 开始倒计时
|
// 停止倒计时
|
||||||
var totalTime = speakingTime;
|
startRec.style.display = 'block';
|
||||||
var countdown = setInterval(function() {
|
endRec.style.display = 'none';
|
||||||
// 更新剩余时间
|
statusTxt.value = '';
|
||||||
totalTime --;
|
voiceTxt.innerText = '';
|
||||||
if (totalTime <= 0) {
|
voice.stop();
|
||||||
// 停止倒计时
|
replayVideoSegment(0, 60);
|
||||||
startRec.style.display = 'block';
|
hideModal()
|
||||||
endRec.style.display = 'none';
|
});
|
||||||
statusTxt.value = '';
|
|
||||||
voiceTxt.innerText = '';
|
|
||||||
clearInterval(countdown);
|
|
||||||
replayVideoSegment(0, 60);
|
|
||||||
}
|
|
||||||
}, 1000);
|
|
||||||
|
|
||||||
hideModal()
|
|
||||||
}).catch(e => {
|
}).catch(e => {
|
||||||
hideModal();
|
hideModal();
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue