Skip to content

Commit 23d01ef

Browse files
author
linyisonger
committed
0秒阅读长篇内容没有感情的机器
1 parent a051b9b commit 23d01ef

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

097.听写词语.html

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,13 @@
6161

6262
.read-word-text textarea {
6363
height: 120px;
64-
width: 265px;
64+
width: 360px;
6565
resize: none;
6666
}
67+
68+
.input-image {
69+
margin-left: 10px;
70+
}
6771
</style>
6872
</head>
6973

@@ -78,7 +82,7 @@
7882
间隔
7983
</div>
8084
<div class="form-item-input">
81-
<input class="read-interval" type="range" min="1" max="5" value="2">
85+
<input class="read-interval" type="range" min="0" max="5" value="2">
8286
</div>
8387
<div class="form-item-text">
8488
2s
@@ -285,15 +289,22 @@
285289
textDOM.textContent = e.target.value + 's';
286290
})
287291
async function readWord() {
288-
let wordsSelected = readWordTextDOM.value.split(' ')
289-
for (let i = 0; i < wordsSelected.length; i++) {
290-
const words = wordsSelected[i];
291-
const utterThis = new SpeechSynthesisUtterance(words);
292+
293+
if (+readIntervalDOM.value == 0) {
294+
const utterThis = new SpeechSynthesisUtterance(readWordTextDOM.value);
292295
utterThis.voice = voices[0];
293296
synth.speak(utterThis);
294-
await new Promise(r => setTimeout(r, +readIntervalDOM.value * 1000))
295297
}
296-
298+
else {
299+
let wordsSelected = readWordTextDOM.value.split(' ').filter(w => w)
300+
for (let i = 0; i < wordsSelected.length; i++) {
301+
const words = wordsSelected[i];
302+
const utterThis = new SpeechSynthesisUtterance(words);
303+
utterThis.voice = voices[0];
304+
synth.speak(utterThis);
305+
await new Promise(r => setTimeout(r, +readIntervalDOM.value * 1000))
306+
}
307+
}
297308
}
298309

299310
</script>

0 commit comments

Comments
 (0)