Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 24 Apr 2020 00:53:28 -0600
From:      "@lbutlr" <>
To:        FreeBSD <>
Subject:   Re: Audio recording on demand (level + duration)
Message-ID:  <>
In-Reply-To: <>
References:  <>

Next in thread | Previous in thread | Raw E-Mail | Index | Archive | Help
On 23 Apr 2020, at 09:51, Polytropon <> wrote:
> 	continuously monitor audio input
> 	if volume > 0:
> 		create UTC timestamp (YYYY-MM-DD_HH:MM:SS)
> 		start recording (in background)
> 	if volume still =3D 0 again
> 		send TERM signal do recorder
> 		recorder closes file (valid file!)
> 		if duration of file > 10 seconds:
> 			convert file to MP3 (in background)
> 			rename file using timestamp
> 		else:
> 			remove file

My guess is that you need to do something like this:

cat /dev/dsp > tmpfile
   Periodically copy and scan tmpfile for portions that have sound =
levels above x%
      Clip those parts into new file
      Repeat scan until reaching ends fo file
   When entire file is scanned, delete copy and cat > /dev/null tmpfile

The exact methods probably depend on the output of cat /dev/sndstat

> I'd like to create the "wrapper" as a simple shell script.
> So when this system runs for a while, I will have certain
> files, let's say
> 	2020-04-23_17:00:01.mp3
> 	2020-04-23_17:35:28.mp3
> 	2020-04-23_21:19:57.mp3
> 	... and so on ...

If you process the file once per day, this is trivial, simply get the =
start of the sound duration from the copy and add this to the dat =
eyesteray. Even if you want to process the sound more frequently, it is =
not difficult, just more tedious.

> An option would be to add the duration
> to the filename (2020-04-23_21:19:57_00:24:13.mp3 - a file
> that contains 24 min 13 sec audio).

Very easy to get the duration of your sound file from, for example, =

Keep in mind, I=E2=80=99m guessing here, but hopefully this will help at =
least look at another direction and maybe figure out or find the answer =
you need.

I intend to live forever. So far, so good.

Want to link to this message? Use this URL: <>