mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-05-01 19:17:41 +03:00
frontend changes for speech events
This commit is contained in:
parent
53dc069c6d
commit
216fc46410
@ -77,6 +77,7 @@ import { Trans, useTranslation } from "react-i18next";
|
||||
import { TbFaceId } from "react-icons/tb";
|
||||
import { useIsAdmin } from "@/hooks/use-is-admin";
|
||||
import FaceSelectionDialog from "../FaceSelectionDialog";
|
||||
import { CgTranscript } from "react-icons/cg";
|
||||
|
||||
const SEARCH_TABS = [
|
||||
"details",
|
||||
@ -709,6 +710,34 @@ function ObjectDetailsTab({
|
||||
[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 (
|
||||
<div className="flex flex-col gap-5">
|
||||
<div className="flex w-full flex-row">
|
||||
@ -894,6 +923,16 @@ function ObjectDetailsTab({
|
||||
</Button>
|
||||
</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>
|
||||
|
||||
@ -246,15 +246,13 @@ export default function Explore() {
|
||||
|
||||
// mutation and revalidation
|
||||
|
||||
const trackedObjectUpdate = useTrackedObjectUpdate();
|
||||
const { payload: wsUpdate } = useTrackedObjectUpdate();
|
||||
|
||||
useEffect(() => {
|
||||
if (trackedObjectUpdate) {
|
||||
if (wsUpdate && wsUpdate.type == "description") {
|
||||
mutate();
|
||||
}
|
||||
// mutate / revalidate when event description updates come in
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [trackedObjectUpdate]);
|
||||
}, [wsUpdate, mutate]);
|
||||
|
||||
// embeddings reindex progress
|
||||
|
||||
|
||||
@ -74,13 +74,13 @@ export default function ExploreView({
|
||||
}, {});
|
||||
}, [events]);
|
||||
|
||||
const trackedObjectUpdate = useTrackedObjectUpdate();
|
||||
const { payload: wsUpdate } = useTrackedObjectUpdate();
|
||||
|
||||
useEffect(() => {
|
||||
mutate();
|
||||
// mutate / revalidate when event description updates come in
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [trackedObjectUpdate]);
|
||||
if (wsUpdate && wsUpdate.type == "description") {
|
||||
mutate();
|
||||
}
|
||||
}, [wsUpdate, mutate]);
|
||||
|
||||
// update search detail when results change
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user