frontend changes for speech events

This commit is contained in:
Josh Hawkins 2025-05-26 07:25:01 -05:00
parent 53dc069c6d
commit 216fc46410
3 changed files with 47 additions and 10 deletions

View File

@ -77,6 +77,7 @@ import { Trans, useTranslation } from "react-i18next";
import { TbFaceId } from "react-icons/tb"; import { TbFaceId } from "react-icons/tb";
import { useIsAdmin } from "@/hooks/use-is-admin"; import { useIsAdmin } from "@/hooks/use-is-admin";
import FaceSelectionDialog from "../FaceSelectionDialog"; import FaceSelectionDialog from "../FaceSelectionDialog";
import { CgTranscript } from "react-icons/cg";
const SEARCH_TABS = [ const SEARCH_TABS = [
"details", "details",
@ -709,6 +710,34 @@ function ObjectDetailsTab({
[search, t], [search, t],
); );
// speech transcription
const onTranscribe = useCallback(() => {
axios
.put(`/audio/transcribe`, { event_id: search.id })
.then((resp) => {
if (resp.status == 202) {
toast.success(t("details.item.toast.success.audioTranscription"), {
position: "top-center",
});
}
})
.catch((error) => {
const errorMessage =
error.response?.data?.message ||
error.response?.data?.detail ||
"Unknown error";
toast.error(
t("details.item.toast.error.audioTranscription", {
errorMessage,
}),
{
position: "top-center",
},
);
});
}, [search, t]);
return ( return (
<div className="flex flex-col gap-5"> <div className="flex flex-col gap-5">
<div className="flex w-full flex-row"> <div className="flex w-full flex-row">
@ -894,6 +923,16 @@ function ObjectDetailsTab({
</Button> </Button>
</FaceSelectionDialog> </FaceSelectionDialog>
)} )}
{config?.cameras[search?.camera].audio_transcription.enabled &&
search?.label == "speech" &&
search?.end_time && (
<Button className="w-full" onClick={onTranscribe}>
<div className="flex gap-1">
<CgTranscript />
{t("itemMenu.audioTranscription.label")}
</div>
</Button>
)}
</div> </div>
</div> </div>
</div> </div>

View File

@ -246,15 +246,13 @@ export default function Explore() {
// mutation and revalidation // mutation and revalidation
const trackedObjectUpdate = useTrackedObjectUpdate(); const { payload: wsUpdate } = useTrackedObjectUpdate();
useEffect(() => { useEffect(() => {
if (trackedObjectUpdate) { if (wsUpdate && wsUpdate.type == "description") {
mutate(); mutate();
} }
// mutate / revalidate when event description updates come in }, [wsUpdate, mutate]);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [trackedObjectUpdate]);
// embeddings reindex progress // embeddings reindex progress

View File

@ -74,13 +74,13 @@ export default function ExploreView({
}, {}); }, {});
}, [events]); }, [events]);
const trackedObjectUpdate = useTrackedObjectUpdate(); const { payload: wsUpdate } = useTrackedObjectUpdate();
useEffect(() => { useEffect(() => {
mutate(); if (wsUpdate && wsUpdate.type == "description") {
// mutate / revalidate when event description updates come in mutate();
// eslint-disable-next-line react-hooks/exhaustive-deps }
}, [trackedObjectUpdate]); }, [wsUpdate, mutate]);
// update search detail when results change // update search detail when results change