mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-08-02 17:12:16 +03:00
Improve audio detection debugging (#19753)
* create audio activity manager move publishing logic out of audio detector * dispatcher changes * correctly publish full array of audio detections in onConnect * frontend websocket hooks * line graph * debug tab and i18n * docs * clean up * fix i18n key
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import {
|
||||
useAudioDetections,
|
||||
useEnabledState,
|
||||
useFrigateEvents,
|
||||
useInitialCameraState,
|
||||
@@ -8,7 +9,7 @@ import { CameraConfig, FrigateConfig } from "@/types/frigateConfig";
|
||||
import { MotionData, ReviewSegment } from "@/types/review";
|
||||
import { useCallback, useEffect, useMemo, useState } from "react";
|
||||
import { useTimelineUtils } from "./use-timeline-utils";
|
||||
import { ObjectType } from "@/types/ws";
|
||||
import { AudioDetection, ObjectType } from "@/types/ws";
|
||||
import useDeepMemo from "./use-deep-memo";
|
||||
import { isEqual } from "lodash";
|
||||
import { useAutoFrigateStats } from "./use-stats";
|
||||
@@ -20,6 +21,7 @@ type useCameraActivityReturn = {
|
||||
activeTracking: boolean;
|
||||
activeMotion: boolean;
|
||||
objects: ObjectType[];
|
||||
audio_detections: AudioDetection[];
|
||||
offline: boolean;
|
||||
};
|
||||
|
||||
@@ -38,6 +40,9 @@ export function useCameraActivity(
|
||||
return getAttributeLabels(config);
|
||||
}, [config]);
|
||||
const [objects, setObjects] = useState<ObjectType[] | undefined>([]);
|
||||
const [audioDetections, setAudioDetections] = useState<
|
||||
AudioDetection[] | undefined
|
||||
>([]);
|
||||
|
||||
// init camera activity
|
||||
|
||||
@@ -51,6 +56,15 @@ export function useCameraActivity(
|
||||
}
|
||||
}, [updatedCameraState, camera]);
|
||||
|
||||
const { payload: updatedAudioState } = useAudioDetections();
|
||||
const memoizedAudioState = useDeepMemo(updatedAudioState);
|
||||
|
||||
useEffect(() => {
|
||||
if (memoizedAudioState) {
|
||||
setAudioDetections(memoizedAudioState[camera.name]);
|
||||
}
|
||||
}, [memoizedAudioState, camera]);
|
||||
|
||||
// handle camera activity
|
||||
|
||||
const hasActiveObjects = useMemo(
|
||||
@@ -160,6 +174,7 @@ export function useCameraActivity(
|
||||
: updatedCameraState?.motion === true
|
||||
: false,
|
||||
objects: isCameraEnabled ? (objects ?? []) : [],
|
||||
audio_detections: isCameraEnabled ? (audioDetections ?? []) : [],
|
||||
offline,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user