Compare commits

...

2 Commits

Author SHA1 Message Date
Josh Hawkins
506ddba346 mypy 2026-05-12 08:15:10 -05:00
Josh Hawkins
cccfc3a152 fix nested translation extraction for Optional dict and list fields 2026-05-12 07:45:11 -05:00
4 changed files with 51 additions and 20 deletions

View File

@ -121,7 +121,8 @@ class AudioProcessor(FrigateProcess):
)
def spawn_if_needed(camera: CameraConfig) -> None:
if camera.name in audio_threads:
name = camera.name
if name is None or name in audio_threads:
return
if not camera.enabled or not camera.audio.enabled:
return
@ -135,9 +136,9 @@ class AudioProcessor(FrigateProcess):
self.transcription_model_runner,
self.stop_event, # type: ignore[arg-type]
)
audio_threads[camera.name] = thread
audio_threads[name] = thread
thread.start()
self.logger.info(f"Audio maintainer started for {camera.name}")
self.logger.info(f"Audio maintainer started for {name}")
for camera in self.config.cameras.values():
spawn_if_needed(camera)

View File

@ -150,29 +150,51 @@ def extract_translations_from_schema(
# Handle anyOf cases
elif "anyOf" in field_schema:
for item in field_schema["anyOf"]:
nested = None
if item.get("type") == "null":
continue
if "properties" in item:
nested = extract_translations_from_schema(item, defs=defs)
elif "$ref" in item:
ref_path = item["$ref"]
if ref_path.startswith("#/$defs/"):
ref_name = ref_path.split("/")[-1]
if ref_name in defs:
nested = extract_translations_from_schema(
defs[ref_name], defs=defs
)
elif (
"additionalProperties" in item
and isinstance(item["additionalProperties"], dict)
and "$ref" in item["additionalProperties"]
):
ref_path = item["additionalProperties"]["$ref"]
if ref_path.startswith("#/$defs/"):
ref_name = ref_path.split("/")[-1]
if ref_name in defs:
nested = extract_translations_from_schema(
defs[ref_name], defs=defs
)
elif (
"items" in item
and isinstance(item["items"], dict)
and ("$ref" in item["items"])
):
ref_path = item["items"]["$ref"]
if ref_path.startswith("#/$defs/"):
ref_name = ref_path.split("/")[-1]
if ref_name in defs:
nested = extract_translations_from_schema(
defs[ref_name], defs=defs
)
if nested:
nested_without_root = {
k: v
for k, v in nested.items()
if k not in ("label", "description")
}
field_translations.update(nested_without_root)
elif "$ref" in item:
ref_path = item["$ref"]
if ref_path.startswith("#/$defs/"):
ref_name = ref_path.split("/")[-1]
if ref_name in defs:
ref_schema = defs[ref_name]
nested = extract_translations_from_schema(
ref_schema, defs=defs
)
nested_without_root = {
k: v
for k, v in nested.items()
if k not in ("label", "description")
}
field_translations.update(nested_without_root)
if field_translations:
translations[field_name] = field_translations

View File

@ -33,7 +33,11 @@
},
"filters": {
"label": "Audio filters",
"description": "Per-audio-type filter settings such as confidence thresholds used to reduce false positives."
"description": "Per-audio-type filter settings such as confidence thresholds used to reduce false positives.",
"threshold": {
"label": "Minimum audio confidence",
"description": "Minimum confidence threshold for the audio event to be counted."
}
},
"enabled_in_config": {
"label": "Original audio state",

View File

@ -559,7 +559,11 @@
},
"filters": {
"label": "Audio filters",
"description": "Per-audio-type filter settings such as confidence thresholds used to reduce false positives."
"description": "Per-audio-type filter settings such as confidence thresholds used to reduce false positives.",
"threshold": {
"label": "Minimum audio confidence",
"description": "Minimum confidence threshold for the audio event to be counted."
}
},
"enabled_in_config": {
"label": "Original audio state",