@@ -29,7 +29,7 @@ let textContent;
2929let imageUrl ;
3030let isLactoseIntolerant ;
3131let dishOriginCountry ;
32- let currentChar
32+ let currentChar ;
3333
3434const defaultRecipe = `
3535Apologies, but our AI Recipe-Making expert is unavailable. Please try again later. In the meantime, please find one of our favourite recipes below.
@@ -283,17 +283,18 @@ recipeButtons.forEach((button) => {
283283
284284 const utterance = new SpeechSynthesisUtterance ( ) ;
285285
286- const speechBtns = Array . from ( document . querySelectorAll ( ".fa-solid" ) ) ;
286+ const speechBtns = Array . from (
287+ document . querySelectorAll ( ".fa-solid" )
288+ ) ;
287289 const speedBtn = document . querySelector ( "#speed" ) ;
288290
289- console . log ( speechBtns )
290-
291+ console . log ( speechBtns ) ;
291292
292293 function readRecipe ( recipe ) {
293- if ( speechSynthesis . paused && speechSynthesis . speaking ) {
294+ if ( speechSynthesis . paused && speechSynthesis . speaking ) {
294295 return speechSynthesis . resume ( ) ;
295296 }
296- if ( speechSynthesis . speaking ) return
297+ if ( speechSynthesis . speaking ) return ;
297298 utterance . text = recipe ;
298299 utterance . rate = speedBtn . value || 1 ;
299300 speechSynthesis . speak ( utterance ) ;
@@ -307,71 +308,23 @@ recipeButtons.forEach((button) => {
307308 speechSynthesis . cancel ( ) ;
308309 }
309310
310- // speechBtns.forEach( speechBtn => {
311- // const btnName = speechBtn.getAttribute("name")
312- // if(btnName === "microphone") {
313- // console.log(btnName)
314- // readRecipe(`${textContent}`);
315- // } else if (btnName === "pause") {
316- // pauseReading();
317- // } else if (btnName === "stop") {
318- // stopREeading();
319- // }
320- // })
321-
322- speechBtns . forEach ( speechBtn => {
311+ speechBtns . forEach ( ( speechBtn ) => {
323312 speechBtn . addEventListener ( "click" , ( ) => {
324313 const btnName = speechBtn . getAttribute ( "name" ) ;
325- if ( btnName === "microphone" ) {
314+ if ( btnName === "microphone" ) {
326315 console . log ( btnName ) ;
327316 readRecipe ( `${ textContent } ` ) ;
328317 } else if ( btnName === "pause" ) {
329318 pauseReading ( ) ;
330319 } else if ( btnName === "stop" ) {
331320 stopREeading ( ) ;
332321 }
333- } )
334- } )
335-
336- console . log ( speechBtns )
337-
338-
339-
340-
341- // const microphoneBtn = document.querySelector(".fa-microphone");
342- // const pauseBtn = document.querySelector(".fa-pause");
343- // const stopBtn = document.querySelector(".fa-stop");
344-
345-
346- console . log ( speedBtn )
347-
348-
349-
350-
351-
352-
353-
354-
355- // speedBtn.addEventListener("input", () => {
356- // stopREeading();
357- // readRecipe(utterance.text.substring(currentChar));
358-
359- // console.log("speed has been incremented")
360- // })
361-
362- // utterance.addEventListener("boundary", (e) => {
363- // currentChar = e.charIndex;
364- // })
365-
366- // stopBtn.addEventListener("click", stopREeading);
367-
368- // pauseBtn.addEventListener("click", pauseReading);
322+ } ) ;
323+ } ) ;
369324
370-
325+ console . log ( speechBtns ) ;
371326
372- // microphoneBtn.addEventListener("click", () => {
373- // readRecipe(`${textContent}`);
374- // });
327+ console . log ( speedBtn ) ;
375328 } )
376329 . catch ( ( error ) => {
377330 console . error ( "Error:" , error ) ;
0 commit comments