Eoin Mac Aodha
Posts: 1
Joined: Sun Jan 12, 2020 9:20 pm

Non Verbal - start music using digital decibel level

Sun Jan 12, 2020 9:41 pm

Hi

I have a disabled brother who is non verbal. He loves music and we are looking for a solution to play music for him in the morning when he wakes and makes noise. He can wake quite early and will make noise. Music will calm and relax him.

We have run a script on a PI using an analog microphone. We are testing it now with him. The issue is its very difficult to monitor and adjust the necessary noise level so that it is at the right noise level. For example, I don't want it to walk him during the night if he makes a Noise.

Ideally I would like to use a digital decibel meter to test the level of sounds he makes in the morning when he wakes. I can then adjust the script so that music will play when a certain db is reached. Can you tell me if there is a digital db which is compatible with what I want to do or what tech components I need?

I know lots of people who would really benefit from this. He does not have the cognitive ability to press a button. I've seen an example of a Google home being used with pictures and on this site also. My brother communicates through noise but it is not intelligible.

Any assistance would be appreciated. I've seen some stuff on forums but mainly about recording db rather that using it as a trigger.

Kind regards

User avatar
davidcoton
Posts: 4541
Joined: Mon Sep 01, 2014 2:37 pm
Location: Cambridge, UK

Re: Non Verbal - start music using digital decibel level

Mon Jan 13, 2020 10:58 am

I don't know how to use a Pi to measure the sound level, but...

An independent measurement of noise level will not help, because the Pi will not be calibrated. You need to get that part of the software working first, and use it to record noise levels through the night and at waking. There may or may not be a margin in which to set the trigger.

You could also make the music trigger dependent on time, so the music cannot start too early.
Signature retired

User avatar
rin67630
Posts: 884
Joined: Fri Mar 04, 2016 10:15 am

Re: Non Verbal - start music using digital decibel level

Thu Feb 06, 2020 4:32 am

Hi,
I have an extensive sound level recorder project involving cheap sound level meters and evaluating/plotting the sound over time.
It measures the noise level every 2mS and records Max-Min-weighted average for each second. The max-min comparison to the average gives an indication if the sound is pulsed or continuous.
It involves an Arduino that runs a part of the job and the RPI finishes. That would need several soldering points.

I have also a python script to get the dB level of a meter with USB-interface.
That cheap chinese meter the WENSN WS1361 sometimes called GM1361 was popular and is now unfortunately replaced by a very similar one running a different protocol. You may find the old one, but be sure it is a xx1361.

Interested?

User avatar
rin67630
Posts: 884
Joined: Fri Mar 04, 2016 10:15 am

Re: Non Verbal - start music using digital decibel level

Thu Feb 06, 2020 2:46 pm

You may probably get the best results using that method:
https://github.com/BenSandeen/surveilla ... classifier
It could require a bit of training and tweaking but should be pretty accurate without any additional hardware.

bls
Posts: 406
Joined: Mon Oct 22, 2018 11:25 pm
Location: Seattle, WA
Contact: Twitter

Re: Non Verbal - start music using digital decibel level

Thu Feb 06, 2020 7:40 pm

I have a python script that automatically records as long as the sound is above a certain level (which can be dynamically changed). It could be modified in a straightforward manner to run a script (he says without having a peek at the code). You could use this to do both the testing to set the correct level, and then to run a music player.

If this is at all interesting, LMK here.

User avatar
rin67630
Posts: 884
Joined: Fri Mar 04, 2016 10:15 am

Re: Non Verbal - start music using digital decibel level

Thu Feb 06, 2020 8:34 pm

bls wrote:
Thu Feb 06, 2020 7:40 pm
I have a python script that automatically records as long as the sound is above a certain level (which can be dynamically changed). It could be modified in a straightforward manner to run a script (he says without having a peek at the code). You could use this to do both the testing to set the correct level, and then to run a music player.

If this is at all interesting, LMK here.
Could you post your script to me, hoping it is well commented?
I am currently trying to combine another python script that is conceived to delay radio by around 30 seconds to match TV broadcastings.
What I want to achieve is to automatically record as long as the sound is above a certain level, but get the 30-60 preceding seconds as well on the record. does it record in a size reduced form at, or as .wav?

Maybe you could have been interested as well?

bls
Posts: 406
Joined: Mon Oct 22, 2018 11:25 pm
Location: Seattle, WA
Contact: Twitter

Re: Non Verbal - start music using digital decibel level

Thu Feb 06, 2020 8:45 pm

rin67630 wrote:
Thu Feb 06, 2020 8:34 pm
Could you post your script to me, hoping it is well commented?
I am currently trying to combine another python script that is conceived to delay radio by around 30 seconds to match TV broadcastings.
What I want to achieve is to automatically record as long as the sound is above a certain level, but get the 30-60 preceding seconds as well on the record. does it record in a size reduced form at, or as .wav?

Maybe you could have been interested as well?
Well-commented is always in the eye of the reader :lol:.

The current script, which does sound-activated recording, is at https://github.com/gitbls/voxel. It does know how to save the previous N records; I suppose if you make N large enough it will capture 30-60 seconds. Sound is recorded as WAV files.

I've started looking at the changes to accomplish the OP's goals (as I understand them), but that's still on the side.

User avatar
rin67630
Posts: 884
Joined: Fri Mar 04, 2016 10:15 am

Re: Non Verbal - start music using digital decibel level

Thu Feb 06, 2020 9:15 pm

bls wrote:
Thu Feb 06, 2020 8:45 pm
rin67630 wrote:
Thu Feb 06, 2020 8:34 pm
Could you post your script to me, hoping it is well commented?
I am currently trying to combine another python script that is conceived to delay radio by around 30 seconds to match TV broadcastings.
What I want to achieve is to automatically record as long as the sound is above a certain level, but get the 30-60 preceding seconds as well on the record. does it record in a size reduced form at, or as .wav?

Maybe you could have been interested as well?
Well-commented is always in the eye of the reader :lol:.

The current script, which does sound-activated recording, is at https://github.com/gitbls/voxel. It does know how to save the previous N records; I suppose if you make N large enough it will capture 30-60 seconds. Sound is recorded as WAV files.

I've started looking at the changes to accomplish the OP's goals (as I understand them), but that's still on the side.
Thank you, sounds nice! could we please follow the discussion here, where it should be on topic?
https://www.raspberrypi.org/forums/view ... 4#p1607264
cu there?

bls
Posts: 406
Joined: Mon Oct 22, 2018 11:25 pm
Location: Seattle, WA
Contact: Twitter

Re: Non Verbal - start music using digital decibel level

Thu Feb 06, 2020 11:46 pm

bls wrote:
Thu Feb 06, 2020 8:45 pm
I've started looking at the changes to accomplish the OP's goals (as I understand them), but that's still on the side.
I have something up and running now. Still needs some polishing, but here's what it does at the moment. Command is called tbd until I decide what to name it :lol:

While it's running, it listens for keyboard input, and accepts the following commands:
  • h - Print help text
  • k - Show current Peak and Threshold levels
  • p - Print observed peak every second until another p command
  • v - Set a new Threshold
  • q - Quit the program
Here are some sample commands:
  • tbd listen --reportpeak - Runs until a peak sound is heard or until q is typed on the keyboard. Reports the Peak observed level on exit.
  • tbd listen --threshold nn --bash "some-bash-command" - Runs until the peak level exceeds the specified threshold, at which time it executes the specified command. If --echo is specified, the command is echoed before it's executed. If --output is specified, the output of the command is printed on the terminal. some-bash-command can be any command you can type at the bash command line.
  • tbd listdevs - List the sound devices and exit
For the OP, using this program you would run the script one or more nights to measure the peak observed sound, and then set it up to run with a --threshold that is higher than the observed peak. Once you have that threshold, you can run it with the --bash and --threshold switches to do exactly what you want.

Feedback welcome!

User avatar
rin67630
Posts: 884
Joined: Fri Mar 04, 2016 10:15 am

Re: Non Verbal - start music using digital decibel level

Fri Feb 07, 2020 9:10 am

bls wrote:
Thu Feb 06, 2020 11:46 pm
Command is called tbd until I decide what to name it...
You may want to call it "peakemon"
;)

Return to “Assistive technology and accessibility”