它仅将语音记录的成绩单输出为文本脚本。我想将所有脚本保存为字符串,然后将其插入数据库(PHP,JS,MySQL)。
<div class="words" contenteditable>
</div>
<script>
window.SpeechRecognition = window.SpeechRecognition ||
window.webkitSpeechRecognition;
const recognition = new SpeechRecognition();
recognition.interimResults = true;
recognition.lang = 'en-US';
let p = document.createElement('p');
const words = document.querySelector('.words');
words.appendChild(p);
recognition.addEventListener('result', e => {
const transcript = Array.from(e.results)
.map(result => result[0])
.map(result => result.transcript)
.join('');
const poopScript = transcript.replace(/poop|poo|shit|dump/gi, '');
p.textContent = poopScript;
if (e.results[0].isFinal) {
p = document.createElement('p');
words.appendChild(p);
}
});
recognition.addEventListener('end', recognition.start);
recognition.start();
</script>
它仅将语音记录的成绩单输出为文本脚本。我想将所有脚本保存为字符串,然后将其插入数据库(PHP,JS,MySQL)。