Spaces:
Sleeping
Sleeping
add speech recognition
Browse filesFiles changed (6)
1declare module "react-speech-recognition";21 unmodified lines2223242526273 unmodified lines3132333435361571 unmodified lines160816091610161116121613116 unmodified lines1730173117321733173417353634 unmodified lines53705371537253735374537521 unmodified lines"react-dom": "^19.0.0","react-icons": "^5.5.0","react-markdown": "^10.1.0","react-toastify": "^11.0.5","react-use": "^17.6.0","tailwindcss": "^4.0.15"3 unmodified lines"@types/express": "^5.0.1","@types/react": "^19.0.10","@types/react-dom": "^19.0.4","@vitejs/plugin-react": "^4.3.4","eslint": "^9.21.0","eslint-plugin-react-hooks": "^5.1.0",1571 unmodified lines"@types/ms": "*"}},"node_modules/@types/estree": {"version": "1.0.6","resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.6.tgz",116 unmodified lines"@types/react": "^19.0.0"}},"node_modules/@types/send": {"version": "0.17.4","resolved": "https://registry.npmjs.org/@types/send/-/send-0.17.4.tgz",3634 unmodified lines"node": ">=0.10.0"}},"node_modules/react-toastify": {"version": "11.0.5","resolved": "https://registry.npmjs.org/react-toastify/-/react-toastify-11.0.5.tgz",21 unmodified lines222324252627283 unmodified lines323334353637381571 unmodified lines161016111612161316141615161616171618161916201621116 unmodified lines1738173917401741174217431744174517461747174817491750175117523634 unmodified lines5387538853895390539153925393539453955396539753985399540021 unmodified lines"react-dom": "^19.0.0","react-icons": "^5.5.0","react-markdown": "^10.1.0","react-speech-recognition": "^4.0.0","react-toastify": "^11.0.5","react-use": "^17.6.0","tailwindcss": "^4.0.15"3 unmodified lines"@types/express": "^5.0.1","@types/react": "^19.0.10","@types/react-dom": "^19.0.4","@types/react-speech-recognition": "^3.9.6","@vitejs/plugin-react": "^4.3.4","eslint": "^9.21.0","eslint-plugin-react-hooks": "^5.1.0",1571 unmodified lines"@types/ms": "*"}},"node_modules/@types/dom-speech-recognition": {"version": "0.0.6","resolved": "https://registry.npmjs.org/@types/dom-speech-recognition/-/dom-speech-recognition-0.0.6.tgz","integrity": "sha512-o7pAVq9UQPJL5RDjO1f/fcpfFHdgiMnR4PoIU2N/ZQrYOS3C5rzdOJMsrpqeBCbii2EE9mERXgqspQqPDdPahw==","dev": true},"node_modules/@types/estree": {"version": "1.0.6","resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.6.tgz",116 unmodified lines"@types/react": "^19.0.0"}},"node_modules/@types/react-speech-recognition": {"version": "3.9.6","resolved": "https://registry.npmjs.org/@types/react-speech-recognition/-/react-speech-recognition-3.9.6.tgz","integrity": "sha512-cdzwXIZXWyp8zfM2XI7APDW1rZf4Nz73T4SIS2y+cC7zHnZluCdumYKH6HacxgxJH+zemAq2oXbHWXcyW0eT3A==","dev": true,"dependencies": {"@types/dom-speech-recognition": "*"}},"node_modules/@types/send": {"version": "0.17.4","resolved": "https://registry.npmjs.org/@types/send/-/send-0.17.4.tgz",3634 unmodified lines"node": ">=0.10.0"}},"node_modules/react-speech-recognition": {"version": "4.0.0","resolved": "https://registry.npmjs.org/react-speech-recognition/-/react-speech-recognition-4.0.0.tgz","integrity": "sha512-hz1OsRhjAW70rOMVXN84PR+1L2I1j8xS1TXpwpd4vlDaRY9i/LbAaxEklqscgObECTTuyxNeGBdVdcq/pX3bqQ==","peerDependencies": {"react": ">=16.8.0"}},"node_modules/react-toastify": {"version": "11.0.5","resolved": "https://registry.npmjs.org/react-toastify/-/react-toastify-11.0.5.tgz",
24 unmodified lines2526272829303 unmodified lines34353637383924 unmodified lines"react-dom": "^19.0.0","react-icons": "^5.5.0","react-markdown": "^10.1.0","react-toastify": "^11.0.5","react-use": "^17.6.0","tailwindcss": "^4.0.15"3 unmodified lines"@types/express": "^5.0.1","@types/react": "^19.0.10","@types/react-dom": "^19.0.4","@vitejs/plugin-react": "^4.3.4","eslint": "^9.21.0","eslint-plugin-react-hooks": "^5.1.0",24 unmodified lines252627282930313 unmodified lines3536373839404124 unmodified lines"react-dom": "^19.0.0","react-icons": "^5.5.0","react-markdown": "^10.1.0","react-speech-recognition": "^4.0.0","react-toastify": "^11.0.5","react-use": "^17.6.0","tailwindcss": "^4.0.15"3 unmodified lines"@types/express": "^5.0.1","@types/react": "^19.0.10","@types/react-dom": "^19.0.4","@types/react-speech-recognition": "^3.9.6","@vitejs/plugin-react": "^4.3.4","eslint": "^9.21.0","eslint-plugin-react-hooks": "^5.1.0",
22 unmodified lines232425262728293022 unmodified linesconst [htmlStorage, , removeHtmlStorage] = useLocalStorage("html_content");const remix = useSearchParam("remix");console.log("REMIX => ", remix);const preview = useRef<HTMLDivElement>(null);const editor = useRef<HTMLDivElement>(null);const resizer = useRef<HTMLDivElement>(null);22 unmodified lines23242526272822 unmodified linesconst [htmlStorage, , removeHtmlStorage] = useLocalStorage("html_content");const remix = useSearchParam("remix");const preview = useRef<HTMLDivElement>(null);const editor = useRef<HTMLDivElement>(null);const resizer = useRef<HTMLDivElement>(null);
1236 unmodified lines101112131415150 unmodified lines166167168169170171import { useState } from "react";import { RiSparkling2Fill } from "react-icons/ri";import { GrSend } from "react-icons/gr";6 unmodified linesimport { defaultHTML } from "./../../../utils/consts";import SuccessSound from "./../../assets/success.mp3";import Settings from "../settings/settings";function AskAI({html,150 unmodified lines}}/><div className="flex items-center justify-end gap-2"><Settingsprovider={provider as string}onChange={setProvider}12346 unmodified lines11121314151617150 unmodified lines168169170171172173174/* eslint-disable @typescript-eslint/no-explicit-any */import { useState } from "react";import { RiSparkling2Fill } from "react-icons/ri";import { GrSend } from "react-icons/gr";6 unmodified linesimport { defaultHTML } from "./../../../utils/consts";import SuccessSound from "./../../assets/success.mp3";import Settings from "../settings/settings";import SpeechPrompt from "../speech-prompt/speech-prompt";function AskAI({html,150 unmodified lines}}/><div className="flex items-center justify-end gap-2"><SpeechPrompt setPrompt={setPrompt} /><Settingsprovider={provider as string}onChange={setProvider}
12345678910111213141516171819202122232425262728293031323334353637383940414243444546import classNames from "classnames";import { FaMicrophone } from "react-icons/fa";import SpeechRecognition, { useSpeechRecognition,} from "react-speech-recognition";import { useUpdateEffect } from "react-use";
function SpeechPrompt({ setPrompt,}: { setPrompt: React.Dispatch<React.SetStateAction<string>>;}) { const { transcript, listening, browserSupportsSpeechRecognition } = useSpeechRecognition();
const startListening = () => SpeechRecognition.startListening({ continuous: true });
if (!browserSupportsSpeechRecognition) { return null; }
// eslint-disable-next-line react-hooks/rules-of-hooks useUpdateEffect(() => { if (transcript) setPrompt(transcript); }, [transcript]);
return ( <button className={classNames( "flex cursor-pointer flex-none items-center justify-center rounded-full text-sm font-semibold size-8 text-center bg-gray-800 hover:bg-gray-700 text-white shadow-sm dark:shadow-highlight/20 disabled:bg-gray-300 disabled:text-gray-500 disabled:cursor-not-allowed disabled:hover:bg-gray-300", { "animate-pulse !bg-orange-500": listening, } )} onTouchStart={startListening} onMouseDown={startListening} onTouchEnd={SpeechRecognition.stopListening} onMouseUp={SpeechRecognition.stopListening} > <FaMicrophone className="text-base" /> </button> );}
export default SpeechPrompt;module.d.tsAdded+1
package-lock.json+25
package.json+2
src/components/App.tsx-2
src/components/ask-ai/ask-ai.tsx+3
src/components/speech-prompt/speech-prompt.tsxAdded+46