Skip to content

Commit

Permalink
Mark model readiness
Browse files Browse the repository at this point in the history
  • Loading branch information
ertrzyiks committed Jan 20, 2025
1 parent c3eed08 commit b63fab2
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/components/search/search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ function SearchForm({
results = [],
}: Props) {
const searchInputRef = useRef<HTMLInputElement>(null);
const [ready, setReady] = useState(false);
const [isWebGPUAvailable, setIsWebGPUAvailable] = useState(false);
const { startRecording, blob } = useAudioInput();
const { processAudio, loadModels, status, text } = useWhisperWorker();
Expand Down Expand Up @@ -87,9 +86,10 @@ function SearchForm({
}, []);

useEffect(() => {
if (text.trim().length > 0) {
const trimmed = text.trim().replace(/\./g, "");
if (trimmed.length > 0) {
searchInputRef.current?.focus();
onChange(text);
onChange(trimmed);
}
}, [text]);

Expand All @@ -99,7 +99,11 @@ function SearchForm({
{isWebGPUAvailable ? (
<button
onClick={() => startRecording()}
className={[ready ? "text-green-400" : "", "mr-2"].join(" ")}
className={[
"border-transparent",
status === "ready" ? "border-b-green-400" : "",
"border rounded-full mr-2",
].join(" ")}
>
<MicrophoneIcon
className="h-5 w-5 text-inherit"
Expand Down

0 comments on commit b63fab2

Please sign in to comment.