File tree Expand file tree Collapse file tree 1 file changed +19
-8
lines changed
Expand file tree Collapse file tree 1 file changed +19
-8
lines changed Original file line number Diff line number Diff line change 6161
6262 .read-word-text textarea {
6363 height : 120px ;
64- width : 265 px ;
64+ width : 360 px ;
6565 resize : none;
6666 }
67+
68+ .input-image {
69+ margin-left : 10px ;
70+ }
6771 </ style >
6872</ head >
6973
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
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 >
You can’t perform that action at this time.
0 commit comments