From 6a40741384b38f153e08814f700182b6ad96434a Mon Sep 17 00:00:00 2001 From: imrany Date: Mon, 21 Oct 2024 16:47:12 +0300 Subject: [PATCH] fixing TypeErrors --- src/App.tsx | 12 +++++---- src/components/ui/Microphone.tsx | 4 +-- src/pages/LandingPage.tsx | 43 ++++++++++++++------------------ src/pages/MainPage.tsx | 38 +++++++++++++++++++++++----- src/types/index.d.ts | 8 ++++++ tsconfig.json | 2 +- 6 files changed, 69 insertions(+), 38 deletions(-) create mode 100644 src/types/index.d.ts diff --git a/src/App.tsx b/src/App.tsx index 4a934b4..b8aca89 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -7,7 +7,6 @@ import SearchPage from "./pages/SearchPage.tsx"; import LandingPage from "./pages/LandingPage.tsx"; import * as cocossd from "@tensorflow-models/coco-ssd"; import { GlobalContext } from "./context"; -import { textToSpeech } from "./components/utilities.ts" export default function App(){ const API_URL=`https://gemmie.onrender.com` @@ -21,7 +20,7 @@ export default function App(){ height: 720, facingMode: "user" }) - const voiceCommands=["SPEAK","SEARCH","RELOAD","UNMUTE","MUTE","START", "BACK"] + const voiceCommands=["SPEAK","SEARCH","RELOAD","UNMUTE","MUTE","START", "BACK", "READ"] // Main function const runCoco = async () => { @@ -49,7 +48,8 @@ export default function App(){ } } - let recognition:any = window.SpeechRecognition ? window.SpeechRecognition : window.webkitSpeechRecognition; + let recognition = + window.SpeechRecognition || window.webkitSpeechRecognition; if(recognition){ recognition = new recognition(); recognition.continuous = true; @@ -67,8 +67,10 @@ export default function App(){ .join('') */ const result=e.results - const transcript=result[result.length-1][result[0].length-1].transcript - setVoiceInput(transcript.toUpperCase()); + const transcript=result[result.length-1][result[0].length-1].transcript.toUpperCase() + const update=transcript.includes('.')?transcript.replace('.',''):transcript; + setVoiceInput(update); + recognition.stop() }); //if (speech) { diff --git a/src/components/ui/Microphone.tsx b/src/components/ui/Microphone.tsx index 37daead..1d072f0 100644 --- a/src/components/ui/Microphone.tsx +++ b/src/components/ui/Microphone.tsx @@ -6,9 +6,9 @@ export default function Microphone(){ const { recognition }=useContext(GlobalContext); return( -
{ - localStorage.setItem("audio","unmute") - middleSectionContent.map((content:string)=>{ - textToSpeech(content) - }) - }} className="mx-3 my-10"> +
readSection(middleSectionContent)} className="mx-3 my-10">

{middleSectionContent[0]}

{middleSectionContent[1]}

{middleSectionContent[2]}

-