Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix audio event creation #15299

Merged
merged 1 commit into from
Dec 2, 2024

Conversation

jameslivulpi
Copy link
Contributor

@jameslivulpi jameslivulpi commented Dec 2, 2024

Proposed change

Fix issue with audio events creation. The numpy multi-d array check with is not fails and causes the issue because numpy doesn't know whether you want to check if all elements of the array are True or if any of them are as seen by error msg below. So Just check if is None.

Latest dev build showed the following when audio event runs post:

docker logs frigate  | grep -A2 audio

--
2024-12-01 19:47:08.832614559  [2024-12-01 19:47:08] audio.crib                     WARNING : Failed to create audio event with status code 500
2024-12-01 19:47:21.480054088  [2024-12-01 19:47:21] frigate.api.event              ERROR   : The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
2024-12-01 19:47:21.482088304  127.0.0.1 - - [01/Dec/2024:19:47:21 -0500] "POST /api/events/crib/crying/create HTTP/1.1" 500 55 "-" "python-requests/2.32.3" "-"
2024-12-01 19:47:21.484325971  [2024-12-01 19:47:21] audio.crib                     WARNING : Failed to create audio event with status code 500
2024-12-01 19:47:21.498257244  [2024-12-01 19:47:21] frigate.api.event              ERROR   : The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
2024-12-01 19:47:21.499582765  127.0.0.1 - - [01/Dec/2024:19:47:21 -0500] "POST /api/events/crib/crying/create HTTP/1.1" 500 55 "-" "python-requests/2.32.3" "-"
2024-12-01 19:47:21.500668425  [2024-12-01 19:47:21] audio.crib                     WARNING : Failed to create audio event with status code 500

Created a small reproducer:

from frigate.const import (
    AUDIO_DURATION,
    AUDIO_FORMAT,
    AUDIO_MAX_BIT_RANGE,
    AUDIO_MIN_CONFIDENCE,
    AUDIO_SAMPLE_RATE,
    FRIGATE_LOCALHOST,
)
import requests
score=100
resp = requests.post(
        f"{FRIGATE_LOCALHOST}/api/events/crib/crying/create",
        json={"duration": None, "score": score, "source_type": "audio"},
)

print(resp)

Before this change:

python3 test.py
<Response [500]>

after the change in this PR:

python3 test.py
<Response [200]>

ref: #15097 (reply in thread)

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New feature
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code
  • Documentation Update

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:

Checklist

  • [X ] The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • The code has been formatted using Ruff (ruff format frigate)

Copy link

netlify bot commented Dec 2, 2024

Deploy Preview for frigate-docs ready!

Name Link
🔨 Latest commit dfe8d61
🔍 Latest deploy log https://app.netlify.com/sites/frigate-docs/deploys/674d123645d9620008da15f8
😎 Deploy Preview https://deploy-preview-15299--frigate-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@NickM-27 NickM-27 merged commit 833cdcb into blakeblackshear:dev Dec 2, 2024
10 checks passed
@jameslivulpi jameslivulpi deleted the fix_audio_event_create branch December 2, 2024 02:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants