Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
ledouxm committed Feb 27, 2025
1 parent 0b2b80a commit 93bf37a
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import Button from "@codegouvfr/react-dsfr/Button";
import { useState, useRef, useEffect } from "react";

const SpeechRecognition = (window as any).SpeechRecognition || (window as any).webkitSpeechRecognition;

export const SpeechRecorder = ({
onInterimText,
onFinalText,
Expand All @@ -16,13 +18,12 @@ export const SpeechRecorder = ({
const [error, setError] = useState("");
const recognitionRef = useRef<any>(null);

const isSupported = Boolean((window as any).SpeechRecognition || (window as any).webkitSpeechRecognition);
const isSupported = Boolean(SpeechRecognition);

useEffect(() => {
if (recognitionRef.current) {
recognitionRef.current.stop();
}
const SpeechRecognition = (window as any).SpeechRecognition || (window as any).webkitSpeechRecognition;

if (!SpeechRecognition) {
setError("Speech recognition not supported");
Expand Down

0 comments on commit 93bf37a

Please sign in to comment.