Home Assistant esp32 sound recorder?
Home Assistant esp32 sound recorder?
Author
Discussion

clockworks

Original Poster:

7,123 posts

168 months

Thursday
quotequote all
I'm trying to put together an esp32-based sound recorder. Needs to record to a file so that I can visually scroll through the timeliness and look for sequences of sound events - clock chimes in this case.
No need for audio playback or good sound quality, just need to see the peaks on a graph of the "dings" to check that I got the correct sequence at the right time.

Hardware is working with a dB meter yaml, I can see the output in "history", but the sampling rate is too low to be useful.

Someone suggested using a webcam in Frigate, but Frigate needs an RTSP stream which cheap webcam don't do?

nyt

1,918 posts

173 months

Thursday
quotequote all
I hve a few cheap cameras that do RTSP - Sonoffs I think.

But Amazon turn up: https://www.amazon.co.uk/Tapo-Security-Detection-T...

(and many others)

clockworks

Original Poster:

7,123 posts

168 months

Thursday
quotequote all
nyt said:
I hve a few cheap cameras that do RTSP - Sonoffs I think.

But Amazon turn up: https://www.amazon.co.uk/Tapo-Security-Detection-T...

(and many others)
Thanks for the Tapo link - ordered one to try.

I was obviously searching for the wrong thing

Somebody

1,658 posts

106 months

Thursday
quotequote all
I have a RSTP stream off this bargain of a camera https://www.amazon.co.uk/FAMVIVA-Security-Waterpro...

ARH

1,550 posts

262 months

You are searching for the wrong thing

https://esphome.io/components/sensor/sound_level/

clockworks

Original Poster:

7,123 posts

168 months

ARH said:
You are searching for the wrong thing

https://esphome.io/components/sensor/sound_level/
That's the code I'm using for the esp32 and microphone. It works fine when viewed live from the dashboard, but I can't figure out how to "record" the output for viewing later. I can look back at it using "history", but that only gives me the average sound level at one second intervals. I need to be able to view the output at least 4 times a second so that I can see individual "dongs". On a clock with "8 bells" (Whittington or St Michael chimes), it generally chimes 8 notes in 3 or 4 seconds. I want to see each note as a separate peak.

If I could "record" and view at a higher sampling rate, say 20 times a second, I could catch and diagnose escapement ("ticking") problems too.
I could go real-time sampling (if I could figure out the capture and playback), but the files might get a bit too big?

Back in the day, I could do all this using my proper clock/watch analysis tool - Microset. This could capture the data using a PC, but that won't work with anything newer than Windows XP. These days it's purely a real-time device that I have to sit and watch. Useful as a bench tool, but no good for longterm analysis.
I could just buy an updated version, but they cost hundreds of pounds. Not really worth buying if I can make something that does the job for £20

ARH

1,550 posts

262 months

Ok I see what you are trying to do now, not really sure HA will be the easiest choice smile

When i first started messing about with voice stuff I used this in my configuration.yaml to save the audio from the mic, it might be helpful I don't really know.

  1. use for recording voice commands
assist_pipeline:
debug_recording_dir: /share/assist_pipeline

I guess you can set up some kind of automation to turn on the mic, this was used with voice assist though so may need a voice setup to work.

Just an idea but it may point you in a direction that helps.

Good luck, and it may be worth asking on the discord chat as they know far more than I do.

JoshSm

3,426 posts

60 months

The easiest way to get that function would be to treat it like sound/video event capture as been done since forever; stream the timestamped signal to a short buffer & trigger a fixed length capture (30 seconds or whatever is useful) on the buffered output when the trigger event happens.

Anything else around triggering on multiple events to count them becomes complicated vs just triggering capture & reviewing it later manually.

Wonder if you could use a game camera of some description to do it, are any of those sound triggerable?

clockworks

Original Poster:

7,123 posts

168 months

JoshSm said:
The easiest way to get that function would be to treat it like sound/video event capture as been done since forever; stream the timestamped signal to a short buffer & trigger a fixed length capture (30 seconds or whatever is useful) on the buffered output when the trigger event happens.

Anything else around triggering on multiple events to count them becomes complicated vs just triggering capture & reviewing it later manually.

Wonder if you could use a game camera of some description to do it, are any of those sound triggerable?
What do you actually use to capture and review the sound in Home Assistant though?

That's the part I can't figure out, probably because I'm looking using the wrong terminology.
I can find voice assistant stuff for realtime use, things that'll let you talk via your phone, and media players for music playback.

I can't find anything in Home Assistant that'll "record" using the microphone device for later review/playback


I haven't been thinking of doing anything "fancy" with automations, just a simple graphic representation of the sound output overnight or whatever that I can scroll through and check for anomalies


Edited by clockworks on Friday 6th March 15:33

clockworks

Original Poster:

7,123 posts

168 months

Yesterday (14:24)
quotequote all
Seems like recording an audio stream from a microphone to a file for later playback in HA is pretty much impossible, so I've dropped that idea.

The Tapo C211 camera arrived, so I've spent about 4 hours getting it to work in Frigate. Not easy, but I've now got it recording continuously with audio on playback (audio was tricky to configure), but haven't figured out how to get audio in the live view, or how to get the pan/tilt controls to work in Frigate. Maybe I need an ONVIF config for that?
Pan and tilt work from the dashboard so the basic comms is there, just not from within Frigate?


Proof of concept, but I think I really need a camera with zoom feature, and a better microphone would be good - it's not very sensitive at a distance.
Threaded tripod base would be useful too.

Edit:

Adding an ONVIF section to the Frigate yaml sorted out the pan/tilt controls.

I got a bit confused about Zoom - Tapo's spec for the C211 clearly states it does PTZ, as does the packaging. What they actually mean is it does hardware PT, but the zoom is purely digital from within the Tapo app. It doesn't do optical zoom at all. That's a bit naughty.

Edited by clockworks on Sunday 8th March 15:27