import React, { useState, useEffect } from "react"; import VoiceIcon from "@/app/icons/voice.svg"; import { getLang, formatLang } from "@/app/locales"; type SpeechRecognitionType = | typeof window.SpeechRecognition | typeof window.webkitSpeechRecognition; export default function SpeechRecorder({ textUpdater, onStop, }: { textUpdater: (text: string) => void; onStop?: () => void; }) { const [speechRecognition, setSpeechRecognition] = useState(null); const [isRecording, setIsRecording] = useState(false); useEffect(() => { if ("SpeechRecognition" in window) { setSpeechRecognition(new (window as any).SpeechRecognition()); } else if ("webkitSpeechRecognition" in window) { setSpeechRecognition(new (window as any).webkitSpeechRecognition()); } }, []); return ( <> {speechRecognition && (
) : ( )}
)} ); }