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